summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-12-12 13:58:39 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-12-12 14:00:53 +0900
commitb7419f4069baa7154c4e8c04587c682337fab992 (patch)
treeeb7a590a65804693d52ad73cb52aa865bcd9b43e /src/bin
parent116f24fd78b5ba8b07939ba6a007a5f77ea15dbc (diff)
elm test: Add test for Efl.Ui.Slider
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elementary/Makefile.am1
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_ui_slider.c120
3 files changed, 123 insertions, 0 deletions
diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am
index dbc4437bdc..8ce36a7a8d 100644
--- a/src/bin/elementary/Makefile.am
+++ b/src/bin/elementary/Makefile.am
@@ -125,6 +125,7 @@ test_scroller.c \
125test_segment_control.c \ 125test_segment_control.c \
126test_separator.c \ 126test_separator.c \
127test_slider.c \ 127test_slider.c \
128test_ui_slider.c \
128test_ui_slider_interval.c \ 129test_ui_slider_interval.c \
129test_slideshow.c \ 130test_slideshow.c \
130test_spinner.c \ 131test_spinner.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 577f600c91..8a592ab7d2 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -110,6 +110,7 @@ void test_scaling(void *data, Evas_Object *obj, void *event_info);
110void test_scaling2(void *data, Evas_Object *obj, void *event_info); 110void test_scaling2(void *data, Evas_Object *obj, void *event_info);
111void test_slider(void *data, Evas_Object *obj, void *event_info); 111void test_slider(void *data, Evas_Object *obj, void *event_info);
112void test_slider_interval(void *data, Evas_Object *obj, void *event_info); 112void test_slider_interval(void *data, Evas_Object *obj, void *event_info);
113void test_ui_slider(void *data, Evas_Object *obj, void *event_info);
113void test_actionslider(void *data, Evas_Object *obj, void *event_info); 114void test_actionslider(void *data, Evas_Object *obj, void *event_info);
114void test_genlist(void *data, Evas_Object *obj, void *event_info); 115void test_genlist(void *data, Evas_Object *obj, void *event_info);
115void test_genlist2(void *data, Evas_Object *obj, void *event_info); 116void test_genlist2(void *data, Evas_Object *obj, void *event_info);
@@ -1035,6 +1036,7 @@ add_tests:
1035 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2); 1036 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2);
1036 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate); 1037 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Nstate", test_nstate);
1037 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval); 1038 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider_Interval", test_slider_interval);
1039 ADD_TEST_EO(NULL, "Range Values", "Efl.Ui.Slider", test_ui_slider);
1038 1040
1039 //------------------------------// 1041 //------------------------------//
1040 ADD_TEST(NULL, "Booleans", "Check", test_check); 1042 ADD_TEST(NULL, "Booleans", "Check", test_check);
diff --git a/src/bin/elementary/test_ui_slider.c b/src/bin/elementary/test_ui_slider.c
new file mode 100644
index 0000000000..8fe7047778
--- /dev/null
+++ b/src/bin/elementary/test_ui_slider.c
@@ -0,0 +1,120 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static double
7_step_size_calculate(double min, double max)
8{
9 double step = 0.0;
10 int steps = 0;
11
12 steps = max - min;
13 if (steps) step = (1.0 / steps);
14 return step;
15}
16
17static void
18_slider_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
19{
20 double val;
21
22 val = efl_ui_range_value_get(ev->object);
23
24 printf("val = %f\n", val);
25 if (val > 100)
26 efl_ui_range_value_set(ev->object, 100);
27}
28
29void
30test_ui_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
31{
32 Eo *win, *bx, *hbx;
33 double step;
34
35 win = efl_add(EFL_UI_WIN_CLASS, NULL,
36 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
37 efl_text_set(efl_added, "Efl.Ui.Slider"),
38 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
39
40 bx = efl_add(EFL_UI_BOX_CLASS, win,
41 efl_content_set(win, efl_added));
42
43 efl_add(EFL_UI_SLIDER_CLASS, bx,
44 efl_text_set(efl_added, "Horizontal"),
45 efl_ui_slider_part_indicator_visible_mode_set(efl_part(efl_added, "indicator"),
46 EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_NONE),
47 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 0)),
48 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.5f"),
49 efl_pack(bx, efl_added));
50
51 step = _step_size_calculate(0, 9);
52 efl_add(EFL_UI_SLIDER_CLASS, bx,
53 efl_text_set(efl_added, "Manual step"),
54 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(120, 0)),
55 efl_ui_format_string_set(efl_added, "%1.1f units"),
56 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.1f"),
57 efl_ui_slider_step_set(efl_added, step),
58 efl_pack(bx, efl_added));
59
60 efl_add(EFL_UI_SLIDER_CLASS, bx,
61 efl_text_set(efl_added, "Disabled"),
62 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(120, 0)),
63 efl_ui_format_string_set(efl_added, "%1.0f units"),
64 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
65 efl_ui_range_min_max_set(efl_added, 10, 145),
66 efl_ui_slider_step_set(efl_added, step),
67 elm_object_disabled_set(efl_added, EINA_TRUE),
68 efl_pack(bx, efl_added));
69
70 hbx = efl_add(EFL_UI_BOX_CLASS, bx,
71 efl_ui_direction_set(efl_added, EFL_UI_DIR_HORIZONTAL),
72 efl_pack(bx, efl_added));
73
74 efl_add(EFL_UI_SLIDER_CLASS, hbx,
75 efl_text_set(efl_added, "Vertical"),
76 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(0, 160)),
77 efl_ui_format_string_set(efl_added, "%1.0f units"),
78 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
79 efl_ui_range_min_max_set(efl_added, 10, 145),
80 efl_ui_slider_step_set(efl_added, step),
81 efl_ui_range_value_set(efl_added, 70),
82 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
83 efl_pack(hbx, efl_added));
84
85 efl_add(EFL_UI_SLIDER_CLASS, hbx,
86 efl_text_set(efl_added, "Disabled"),
87 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(0, 160)),
88 efl_ui_format_string_set(efl_added, "%1.0f units"),
89 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
90 efl_ui_range_min_max_set(efl_added, 10, 145),
91 efl_ui_slider_step_set(efl_added, step),
92 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
93 elm_object_disabled_set(efl_added, EINA_TRUE),
94 efl_pack(hbx, efl_added));
95
96 efl_add(EFL_UI_SLIDER_CLASS, hbx,
97 efl_text_set(efl_added, "Always Show Indicator:"),
98 efl_ui_slider_part_indicator_visible_mode_set(efl_part(efl_added, "indicator"),
99 EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ALWAYS),
100 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(0, 160)),
101 efl_ui_format_string_set(efl_added, "%1.0f units"),
102 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
103 efl_ui_range_min_max_set(efl_added, 10, 145),
104 efl_ui_range_value_set(efl_added, 35),
105 efl_ui_slider_step_set(efl_added, step),
106 efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL),
107 efl_pack(hbx, efl_added));
108
109 efl_add(EFL_UI_SLIDER_CLASS, bx,
110 efl_text_set(efl_added, "Limited (0-100)"),
111 efl_ui_slider_part_indicator_visible_mode_set(efl_part(efl_added, "indicator"),
112 EFL_UI_SLIDER_INDICATOR_VISIBLE_MODE_ON_FOCUS),
113 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(260, 0)),
114 efl_ui_format_string_set(efl_added, "%1.0f units"),
115 efl_ui_format_string_set(efl_part(efl_added, "indicator"), "%1.0f"),
116 efl_ui_range_min_max_set(efl_added, 0, 150),
117 efl_ui_slider_step_set(efl_added, step),
118 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED, _slider_changed_cb, NULL),
119 efl_pack(bx, efl_added));
120}