summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-19 08:59:14 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-08-19 16:47:10 -0700
commit6316455261a8e1d0a8f76b7d0e6a7b758f81d715 (patch)
tree78e89e6baa51d73b97e3a9c1935eb93585d9d881 /src/tests
parent1114106f09fd98e7e4330befb9a15387817cc043 (diff)
tests/scroller: start unit tests for efl.ui.scroller
same layout as elm_test case, start by checking scroll events after wheel Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9634
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/efl_ui_suite.c1
-rw-r--r--src/tests/elementary/efl_ui_suite.h1
-rw-r--r--src/tests/elementary/efl_ui_test_scroller.c150
-rw-r--r--src/tests/elementary/meson.build1
4 files changed, 153 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index a9894a0003..07f3c40b06 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -30,6 +30,7 @@ static const Efl_Test_Case etc[] = {
30 { "efl_ui_popup", efl_ui_test_popup }, 30 { "efl_ui_popup", efl_ui_test_popup },
31 { "efl_ui_progressbar", efl_ui_test_progressbar }, 31 { "efl_ui_progressbar", efl_ui_test_progressbar },
32 { "efl_ui_radio_group", efl_ui_test_radio_group }, 32 { "efl_ui_radio_group", efl_ui_test_radio_group },
33 { "efl_ui_scroller", efl_ui_test_scroller },
33 { "efl_ui_slider", efl_ui_test_slider }, 34 { "efl_ui_slider", efl_ui_test_slider },
34 { "efl_ui_win", efl_ui_test_win }, 35 { "efl_ui_win", efl_ui_test_win },
35 { "efl_ui_spin", efl_ui_test_spin }, 36 { "efl_ui_spin", efl_ui_test_spin },
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 3c6c708e2e..0ddf9bd62f 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -48,6 +48,7 @@ void efl_ui_test_list_container(TCase *tc);
48void efl_ui_test_grid_container(TCase *tc); 48void efl_ui_test_grid_container(TCase *tc);
49void efl_ui_test_config(TCase *tc); 49void efl_ui_test_config(TCase *tc);
50void efl_ui_test_popup(TCase *tc); 50void efl_ui_test_popup(TCase *tc);
51void efl_ui_test_scroller(TCase *tc);
51 52
52void loop_timer_interval_set(Eo *obj, double in); 53void loop_timer_interval_set(Eo *obj, double in);
53 54
diff --git a/src/tests/elementary/efl_ui_test_scroller.c b/src/tests/elementary/efl_ui_test_scroller.c
new file mode 100644
index 0000000000..eeb9a84fd2
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_scroller.c
@@ -0,0 +1,150 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6#include <Elementary.h>
7#include "efl_ui_suite.h"
8
9static void
10_startstop_event_cb(void *data, const Efl_Event *ev EINA_UNUSED)
11{
12 int *called = data;
13 (*called)++;
14 /* start/stop always come in pairs */
15 if (*called == 2) ecore_main_loop_quit();
16}
17
18EFL_START_TEST(efl_ui_test_scroller_events)
19{
20 Eo *sc, *sc2, *sc3, *bx, *bx2, *gd, *gd2;
21 int i, j, called = 0, called2 = 0, called3 = 0;
22 Eo *win = win_add();
23 efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500));
24
25
26 sc = efl_add(EFL_UI_SCROLLER_CLASS, win,
27 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called),
28 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called),
29 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(500, 500))
30 );
31
32 bx = efl_add(EFL_UI_BOX_CLASS, sc,
33 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL),
34 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0),
35 efl_gfx_hint_align_set(efl_added, 0.5, 0),
36 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
37 efl_content_set(sc, efl_added));
38
39 efl_add(EFL_UI_SLIDER_CLASS, bx,
40 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(160, 0)),
41 efl_pack(bx, efl_added));
42
43 for (i = 0; i < 3; i++)
44 {
45 efl_add(EFL_UI_BUTTON_CLASS, bx,
46 efl_text_set(efl_added, "Vertical"),
47 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
48 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
49 //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
50 efl_pack(bx, efl_added));
51 }
52
53 sc2 = efl_add(EFL_UI_SCROLLER_CLASS, bx,
54 efl_ui_scrollable_match_content_set(efl_added, EINA_FALSE, EINA_TRUE),
55 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called2),
56 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called2),
57 efl_pack(bx, efl_added));
58
59 bx2 = efl_add(EFL_UI_BOX_CLASS, sc2,
60 efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
61 efl_content_set(sc2, efl_added));
62
63 for (i = 0; i < 10; i++)
64 {
65 efl_add(EFL_UI_BUTTON_CLASS, bx2,
66 efl_text_set(efl_added, "... Horizontal scrolling ..."),
67 //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
68 efl_pack(bx2, efl_added));
69 }
70
71 for (i = 0; i < 3; i++)
72 {
73 efl_add(EFL_UI_BUTTON_CLASS, bx,
74 efl_text_set(efl_added, "Vertical"),
75 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
76 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
77 //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
78 efl_pack(bx, efl_added));
79 }
80
81 gd = efl_add(EFL_UI_TABLE_CLASS, bx,
82 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
83 efl_gfx_hint_align_set(efl_added, 0.5, 0),
84 efl_pack(bx, efl_added));
85
86 efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
87 efl_gfx_color_set(efl_added, 0, 0, 0, 0),
88 efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(200, 120)),
89 efl_pack_table(gd, efl_added, 0, 0, 1, 1));
90
91 sc3 = efl_add(EFL_UI_SCROLLER_CLASS, win,
92 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
93 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE),
94 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called3),
95 efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called3),
96 efl_pack_table(gd, efl_added, 0, 0, 1, 1));
97
98 gd2 = efl_add(EFL_UI_TABLE_CLASS, sc3,
99 efl_content_set(sc3, efl_added));
100
101 for (j = 0; j < 4; j++)
102 {
103 for (i = 0; i < 4; i++)
104 {
105 efl_add(EFL_UI_BUTTON_CLASS, win,
106 efl_text_set(efl_added, "Both"),
107 //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
108 efl_pack_table(gd2, efl_added, i, j, 1, 1));
109 }
110 }
111
112 for (i = 0; i < 10; i++)
113 {
114 efl_add(EFL_UI_BUTTON_CLASS, bx,
115 efl_text_set(efl_added, "Vertical"),
116 efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
117 efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
118 //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
119 efl_pack(bx, efl_added));
120 }
121 get_me_to_those_events(sc);
122 /* this should only trigger the inner scroller */
123 wheel_object(sc3, 0, 1);
124 ecore_main_loop_begin();
125 ck_assert_int_eq(called3, 2);
126 ck_assert_int_eq(called2, 0);
127 ck_assert_int_eq(called, 0);
128 called3 = 0;
129
130 /* this should only trigger the horizontal scroller */
131 wheel_object(sc2, 1, 1);
132 ecore_main_loop_begin();
133 ck_assert_int_eq(called3, 0);
134 ck_assert_int_eq(called2, 2);
135 ck_assert_int_eq(called, 0);
136 called2 = 0;
137
138 /* this should only trigger the outer scroller */
139 wheel_object_at(sc, 250, 400, 0, 1);
140 ecore_main_loop_begin();
141 ck_assert_int_eq(called3, 0);
142 ck_assert_int_eq(called2, 0);
143 ck_assert_int_eq(called, 2);
144}
145EFL_END_TEST
146
147void efl_ui_test_scroller(TCase *tc)
148{
149 tcase_add_test(tc, efl_ui_test_scroller_events);
150}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index dff90e788b..5204c6473a 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -153,6 +153,7 @@ efl_ui_suite_src = [
153 'efl_ui_test_grid_collection.c', 153 'efl_ui_test_grid_collection.c',
154 'efl_ui_test_position_manager_common.c', 154 'efl_ui_test_position_manager_common.c',
155 'efl_ui_test_popup.c', 155 'efl_ui_test_popup.c',
156 'efl_ui_test_scroller.c',
156] 157]
157 158
158efl_ui_suite = executable('efl_ui_suite', 159efl_ui_suite = executable('efl_ui_suite',