summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-09 09:11:36 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-09 16:01:05 +0200
commit244b1446fc487b6254e02a180e44a3d67b197b44 (patch)
tree1ace9cc819d34058489afa95239a9102dff0722d
parent0fe216420c71468f86965ff73923637c17fa79a1 (diff)
tests/efl_ui: add event test for slider
this verifies event emission for slider like in legacy tests Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9246
-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_slider.c58
-rw-r--r--src/tests/elementary/meson.build1
4 files changed, 61 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 87e4e8c696..74a9f909fc 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -28,6 +28,7 @@ static const Efl_Test_Case etc[] = {
28 { "efl_ui_check", efl_ui_test_check }, 28 { "efl_ui_check", efl_ui_test_check },
29 { "efl_ui_progressbar", efl_ui_test_progressbar }, 29 { "efl_ui_progressbar", efl_ui_test_progressbar },
30 { "efl_ui_radio_group", efl_ui_test_radio_group }, 30 { "efl_ui_radio_group", efl_ui_test_radio_group },
31 { "efl_ui_slider", efl_ui_test_slider },
31 { "efl_ui_win", efl_ui_test_win }, 32 { "efl_ui_win", efl_ui_test_win },
32 { "efl_ui_spin", efl_ui_test_spin }, 33 { "efl_ui_spin", efl_ui_test_spin },
33 { "efl_ui_spin_button", efl_ui_test_spin_button }, 34 { "efl_ui_spin_button", efl_ui_test_spin_button },
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 0e8be968ff..7fd8665f96 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -39,6 +39,7 @@ void efl_ui_test_spotlight(TCase *tc);
39void efl_ui_test_check(TCase *tc); 39void efl_ui_test_check(TCase *tc);
40void efl_ui_test_progressbar(TCase *tc); 40void efl_ui_test_progressbar(TCase *tc);
41void efl_ui_test_radio_group(TCase *tc); 41void efl_ui_test_radio_group(TCase *tc);
42void efl_ui_test_slider(TCase *tc);
42void efl_ui_test_win(TCase *tc); 43void efl_ui_test_win(TCase *tc);
43void efl_ui_test_spin(TCase *tc); 44void efl_ui_test_spin(TCase *tc);
44void efl_ui_test_spin_button(TCase *tc); 45void efl_ui_test_spin_button(TCase *tc);
diff --git a/src/tests/elementary/efl_ui_test_slider.c b/src/tests/elementary/efl_ui_test_slider.c
new file mode 100644
index 0000000000..55f5f938c2
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_slider.c
@@ -0,0 +1,58 @@
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 unsigned int event_counter;
10
11static void
12slider_changed(void *data EINA_UNUSED, const Efl_Event *ev)
13{
14 event_counter++;
15 if (event_counter == 1)
16 efl_event_callback_del(ev->object, EFL_UI_SLIDER_EVENT_CHANGED, slider_changed, NULL);
17 else if (event_counter == 2)
18 ecore_main_loop_quit();
19}
20
21EFL_START_TEST(efl_ui_test_slider_events)
22{
23 Eo *slider;
24 Evas *e;
25 Eo *win = win_add();
26
27 efl_gfx_entity_size_set(win, EINA_SIZE2D(400, 100));
28 slider = efl_add(EFL_UI_SLIDER_CLASS, win,
29 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_CHANGED, slider_changed, NULL),
30 efl_event_callback_add(efl_added, EFL_UI_SLIDER_EVENT_STEADY, slider_changed, NULL),
31 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(400, 100))
32 );
33
34 e = evas_object_evas_get(win);
35
36 efl_layout_signal_process(slider, EINA_TRUE);
37 get_me_to_those_events(slider);
38
39
40 int x, y, w, h;
41 int sx, sy, sw, sh;
42
43 evas_object_geometry_get(elm_object_part_content_get(slider, "efl.bar"), &x, &y, &w, &h);
44 evas_object_geometry_get(slider, &sx, &sy, &sw, &sh);
45 evas_event_feed_mouse_in(e, 0, NULL);
46 evas_event_feed_mouse_move(e, x + (w / 2), y + (h / 2), 0, NULL);
47 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
48 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL);
49 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
50 ecore_main_loop_begin();
51 ck_assert_int_eq(event_counter, 2);
52}
53EFL_END_TEST
54
55void efl_ui_test_slider(TCase *tc)
56{
57 tcase_add_test(tc, efl_ui_test_slider_events);
58}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 4dc1bd1305..7e9454fd95 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -145,6 +145,7 @@ efl_ui_suite_src = [
145 'efl_ui_test_progressbar.c', 145 'efl_ui_test_progressbar.c',
146 'efl_ui_test_spin.c', 146 'efl_ui_test_spin.c',
147 'efl_ui_test_spin_button.c', 147 'efl_ui_test_spin_button.c',
148 'efl_ui_test_slider.c',
148] 149]
149 150
150efl_ui_suite = executable('efl_ui_suite', 151efl_ui_suite = executable('efl_ui_suite',