summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-06-26 13:01:56 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-27 09:45:12 +0200
commit4c15ef65dd693a65a88603d1716fd6f36020decc (patch)
treef9ac5fbd3b6a9472b4fdc03b3421e06e29df2536
parent39833fe168699b4970567f0748b1b6f5e903df54 (diff)
tests/elm: replace bespoke win/loop fast-forwarding with helper function
now we can consistently do event emissions inline in tests using much simpler code Reviewed-by: Chris Michael <cp.michael@samsung.com> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9188
-rw-r--r--src/tests/elementary/efl_ui_test_win.c10
-rw-r--r--src/tests/elementary/elm_test_entry.c29
-rw-r--r--src/tests/elementary/elm_test_slider.c87
3 files changed, 42 insertions, 84 deletions
diff --git a/src/tests/elementary/efl_ui_test_win.c b/src/tests/elementary/efl_ui_test_win.c
index cfc57a7834..bc795ed237 100644
--- a/src/tests/elementary/efl_ui_test_win.c
+++ b/src/tests/elementary/efl_ui_test_win.c
@@ -96,13 +96,6 @@ EFL_END_TEST
96 96
97 97
98static void 98static void
99prepare_window_norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED)
100{
101 efl_task_end(efl_app_main_get());
102 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, prepare_window_norendered);
103}
104
105static void
106create_environment(Eo **win, Eo **rect) 99create_environment(Eo **win, Eo **rect)
107{ 100{
108 *win = efl_new(EFL_UI_WIN_CLASS); 101 *win = efl_new(EFL_UI_WIN_CLASS);
@@ -110,8 +103,7 @@ create_environment(Eo **win, Eo **rect)
110 efl_canvas_object_seat_focus_add(*rect, NULL); 103 efl_canvas_object_seat_focus_add(*rect, NULL);
111 efl_gfx_entity_geometry_set(*win, EINA_RECT(0, 0, 200, 200)); 104 efl_gfx_entity_geometry_set(*win, EINA_RECT(0, 0, 200, 200));
112 efl_gfx_entity_geometry_set(*rect, EINA_RECT(0, 0, 200, 200)); 105 efl_gfx_entity_geometry_set(*rect, EINA_RECT(0, 0, 200, 200));
113 evas_event_callback_add(evas_object_evas_get(*win), EVAS_CALLBACK_RENDER_POST, prepare_window_norendered, NULL); 106 get_me_to_those_events(evas_object_evas_get(*win));
114 efl_loop_begin(efl_main_loop_get());
115} 107}
116 108
117EFL_START_TEST(efl_ui_win_test_efl_input_interface_focus) 109EFL_START_TEST(efl_ui_win_test_efl_input_interface_focus)
diff --git a/src/tests/elementary/elm_test_entry.c b/src/tests/elementary/elm_test_entry.c
index 48e31d0b3c..1b383b2936 100644
--- a/src/tests/elementary/elm_test_entry.c
+++ b/src/tests/elementary/elm_test_entry.c
@@ -400,29 +400,14 @@ end_test()
400 return EINA_FALSE; 400 return EINA_FALSE;
401} 401}
402 402
403static void
404mag_job(void *e)
405{
406 evas_event_feed_mouse_out(e, 0, NULL);
407 evas_event_feed_mouse_in(e, 0, NULL);
408 evas_event_feed_mouse_move(e, 200, 100, 0, NULL);
409 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
410 real_timer_add(elm_config_longpress_timeout_get() + 0.1, end_test, NULL);
411}
412
413static void
414norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED)
415{
416 ecore_job_add(mag_job, e);
417 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, norendered);
418}
419
420EFL_START_TEST(elm_entry_magnifier) 403EFL_START_TEST(elm_entry_magnifier)
421{ 404{
422 Evas_Object *win, *entry; 405 Evas_Object *win, *entry;
406 Evas *e;
423 char buf[4096]; 407 char buf[4096];
424 408
425 win = win_add_focused(NULL, "entry", ELM_WIN_BASIC); 409 win = win_add_focused(NULL, "entry", ELM_WIN_BASIC);
410 e = evas_object_evas_get(win);
426 evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 411 evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
427 412
428 entry = elm_entry_add(win); 413 entry = elm_entry_add(win);
@@ -466,9 +451,13 @@ EFL_START_TEST(elm_entry_magnifier)
466 evas_object_show(win); 451 evas_object_show(win);
467 evas_object_resize(entry, 600, 400); 452 evas_object_resize(entry, 600, 400);
468 evas_object_resize(win, 600, 400); 453 evas_object_resize(win, 600, 400);
469 evas_smart_objects_calculate(evas_object_evas_get(win)); 454 get_me_to_those_events(e);
470 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, norendered, NULL); 455
471 ecore_main_loop_begin(); 456 evas_event_feed_mouse_out(e, 0, NULL);
457 evas_event_feed_mouse_in(e, 0, NULL);
458 evas_event_feed_mouse_move(e, 200, 100, 0, NULL);
459 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
460 real_timer_add(elm_config_longpress_timeout_get() + 0.1, end_test, NULL);
472} 461}
473EFL_END_TEST 462EFL_END_TEST
474 463
diff --git a/src/tests/elementary/elm_test_slider.c b/src/tests/elementary/elm_test_slider.c
index 7bc6fb84f3..14035b4e48 100644
--- a/src/tests/elementary/elm_test_slider.c
+++ b/src/tests/elementary/elm_test_slider.c
@@ -41,35 +41,13 @@ EFL_START_TEST(elm_atspi_role_get)
41} 41}
42EFL_END_TEST 42EFL_END_TEST
43 43
44static Evas_Object *fslider, *scroller;
45
46static void
47mag_job(void *e)
48{
49 int x, y, w, h;
50 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0);
51 evas_event_feed_mouse_in(e, 0, NULL);
52 evas_object_geometry_get(fslider, &x, &y, &w, &h);
53 evas_event_feed_mouse_move(e, x+w/2, y+h/2, 0, NULL);
54 //ensure that the scroller is on hold
55 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 1);
56 evas_event_feed_mouse_move(e, x+w+w/2, y+h+h/2, 0, NULL);
57 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0);
58 ecore_main_loop_quit();
59}
60
61static void
62norendered(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED)
63{
64 ecore_job_add(mag_job, e);
65 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, norendered);
66}
67
68EFL_START_TEST(elm_slider_in_scroller) 44EFL_START_TEST(elm_slider_in_scroller)
69{ 45{
70 Evas_Object *win, *slider, *box; 46 Evas_Object *win, *slider, *box, *scroller, *fslider;
47 Evas *e;
71 48
72 win = win_add(NULL, "slider", ELM_WIN_BASIC); 49 win = win_add(NULL, "slider", ELM_WIN_BASIC);
50 e = evas_object_evas_get(win);
73 evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 51 evas_object_size_hint_weight_set(win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74 52
75 scroller = elm_scroller_add(win); 53 scroller = elm_scroller_add(win);
@@ -96,11 +74,18 @@ EFL_START_TEST(elm_slider_in_scroller)
96 evas_object_resize(win, 100, 100); 74 evas_object_resize(win, 100, 100);
97 evas_object_show(win); 75 evas_object_show(win);
98 76
99 evas_smart_objects_calculate(evas_object_evas_get(win)); 77 get_me_to_those_events(scroller);
100 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, norendered, NULL);
101 78
102 elm_run(); 79 int x, y, w, h;
103 80
81 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0);
82 evas_event_feed_mouse_in(e, 0, NULL);
83 evas_object_geometry_get(fslider, &x, &y, &w, &h);
84 evas_event_feed_mouse_move(e, x+w/2, y+h/2, 0, NULL);
85 //ensure that the scroller is on hold
86 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 1);
87 evas_event_feed_mouse_move(e, x+w+w/2, y+h+h/2, 0, NULL);
88 ck_assert_int_eq(elm_object_scroll_hold_get(scroller), 0);
104} 89}
105EFL_END_TEST 90EFL_END_TEST
106 91
@@ -110,38 +95,19 @@ static void
110slider_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) 95slider_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
111{ 96{
112 event_counter++; 97 event_counter++;
113 if (event_counter == 2) ecore_main_loop_quit(); 98 if (event_counter == 1)
114 else evas_object_smart_callback_del(obj, "changed", slider_changed); 99 evas_object_smart_callback_del(obj, "changed", slider_changed);
115} 100 else if (event_counter == 2)
116 101 ecore_main_loop_quit();
117static void
118slider_change(void *data)
119{
120 int x, y, w, h;
121 int sx, sy, sw, sh;
122 Evas *e = evas_object_evas_get(data);
123
124 evas_object_geometry_get(elm_object_part_content_get(data, "elm.swallow.bar"), &x, &y, &w, &h);
125 evas_object_geometry_get(data, &sx, &sy, &sw, &sh);
126 evas_event_feed_mouse_in(e, 0, NULL);
127 evas_event_feed_mouse_move(e, x + (w / 2), y + (h / 2), 0, NULL);
128 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
129 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL);
130 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
131}
132
133static void
134events_norendered(void *data, Evas *e, void *event_info EINA_UNUSED)
135{
136 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, events_norendered);
137 ecore_job_add(slider_change, data);
138} 102}
139 103
140EFL_START_TEST(elm_slider_events) 104EFL_START_TEST(elm_slider_events)
141{ 105{
142 Evas_Object *win, *slider; 106 Evas_Object *win, *slider;
107 Evas *e;
143 108
144 win = win_add(NULL, "slider", ELM_WIN_BASIC); 109 win = win_add(NULL, "slider", ELM_WIN_BASIC);
110 e = evas_object_evas_get(win);
145 111
146 slider = elm_slider_add(win); 112 slider = elm_slider_add(win);
147 evas_object_smart_callback_add(slider, "changed", slider_changed, NULL); 113 evas_object_smart_callback_add(slider, "changed", slider_changed, NULL);
@@ -151,8 +117,19 @@ EFL_START_TEST(elm_slider_events)
151 evas_object_resize(slider, 400, 100); 117 evas_object_resize(slider, 400, 100);
152 evas_object_resize(win, 400, 100); 118 evas_object_resize(win, 400, 100);
153 edje_object_message_signal_process(elm_layout_edje_get(slider)); 119 edje_object_message_signal_process(elm_layout_edje_get(slider));
154 evas_smart_objects_calculate(evas_object_evas_get(win)); 120 get_me_to_those_events(slider);
155 evas_event_callback_add(evas_object_evas_get(win), EVAS_CALLBACK_RENDER_POST, events_norendered, slider); 121
122
123 int x, y, w, h;
124 int sx, sy, sw, sh;
125
126 evas_object_geometry_get(elm_object_part_content_get(slider, "elm.swallow.bar"), &x, &y, &w, &h);
127 evas_object_geometry_get(slider, &sx, &sy, &sw, &sh);
128 evas_event_feed_mouse_in(e, 0, NULL);
129 evas_event_feed_mouse_move(e, x + (w / 2), y + (h / 2), 0, NULL);
130 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
131 evas_event_feed_mouse_move(e, sx + (sw / 2), sy + (sh / 2), 0, NULL);
132 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
156 ecore_main_loop_begin(); 133 ecore_main_loop_begin();
157 ck_assert_int_eq(event_counter, 2); 134 ck_assert_int_eq(event_counter, 2);
158} 135}