summaryrefslogtreecommitdiff
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
parent1114106f09fd98e7e4330befb9a15387817cc043 (diff)
downloadefl-6316455261a8e1d0a8f76b7d0e6a7b758f81d715.tar.gz
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
-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[] = {
{ "efl_ui_popup", efl_ui_test_popup },
{ "efl_ui_progressbar", efl_ui_test_progressbar },
{ "efl_ui_radio_group", efl_ui_test_radio_group },
+ { "efl_ui_scroller", efl_ui_test_scroller },
{ "efl_ui_slider", efl_ui_test_slider },
{ "efl_ui_win", efl_ui_test_win },
{ "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);
void efl_ui_test_grid_container(TCase *tc);
void efl_ui_test_config(TCase *tc);
void efl_ui_test_popup(TCase *tc);
+void efl_ui_test_scroller(TCase *tc);
void loop_timer_interval_set(Eo *obj, double in);
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 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Efl_Ui.h>
+#include <Elementary.h>
+#include "efl_ui_suite.h"
+
+static void
+_startstop_event_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+ int *called = data;
+ (*called)++;
+ /* start/stop always come in pairs */
+ if (*called == 2) ecore_main_loop_quit();
+}
+
+EFL_START_TEST(efl_ui_test_scroller_events)
+{
+ Eo *sc, *sc2, *sc3, *bx, *bx2, *gd, *gd2;
+ int i, j, called = 0, called2 = 0, called3 = 0;
+ Eo *win = win_add();
+ efl_gfx_entity_size_set(win, EINA_SIZE2D(500, 500));
+
+
+ sc = efl_add(EFL_UI_SCROLLER_CLASS, win,
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called),
+ efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(500, 500))
+ );
+
+ bx = efl_add(EFL_UI_BOX_CLASS, sc,
+ efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL),
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0),
+ efl_gfx_hint_align_set(efl_added, 0.5, 0),
+ efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
+ efl_content_set(sc, efl_added));
+
+ efl_add(EFL_UI_SLIDER_CLASS, bx,
+ efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(160, 0)),
+ efl_pack(bx, efl_added));
+
+ for (i = 0; i < 3; i++)
+ {
+ efl_add(EFL_UI_BUTTON_CLASS, bx,
+ efl_text_set(efl_added, "Vertical"),
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
+ efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
+ //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
+ efl_pack(bx, efl_added));
+ }
+
+ sc2 = efl_add(EFL_UI_SCROLLER_CLASS, bx,
+ efl_ui_scrollable_match_content_set(efl_added, EINA_FALSE, EINA_TRUE),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called2),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called2),
+ efl_pack(bx, efl_added));
+
+ bx2 = efl_add(EFL_UI_BOX_CLASS, sc2,
+ efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL),
+ efl_content_set(sc2, efl_added));
+
+ for (i = 0; i < 10; i++)
+ {
+ efl_add(EFL_UI_BUTTON_CLASS, bx2,
+ efl_text_set(efl_added, "... Horizontal scrolling ..."),
+ //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
+ efl_pack(bx2, efl_added));
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ efl_add(EFL_UI_BUTTON_CLASS, bx,
+ efl_text_set(efl_added, "Vertical"),
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
+ efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
+ //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
+ efl_pack(bx, efl_added));
+ }
+
+ gd = efl_add(EFL_UI_TABLE_CLASS, bx,
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
+ efl_gfx_hint_align_set(efl_added, 0.5, 0),
+ efl_pack(bx, efl_added));
+
+ efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
+ efl_gfx_color_set(efl_added, 0, 0, 0, 0),
+ efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(200, 120)),
+ efl_pack_table(gd, efl_added, 0, 0, 1, 1));
+
+ sc3 = efl_add(EFL_UI_SCROLLER_CLASS, win,
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
+ efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_TRUE),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_START, _startstop_event_cb, &called3),
+ efl_event_callback_add(efl_added, EFL_UI_EVENT_SCROLL_STOP, _startstop_event_cb, &called3),
+ efl_pack_table(gd, efl_added, 0, 0, 1, 1));
+
+ gd2 = efl_add(EFL_UI_TABLE_CLASS, sc3,
+ efl_content_set(sc3, efl_added));
+
+ for (j = 0; j < 4; j++)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ efl_add(EFL_UI_BUTTON_CLASS, win,
+ efl_text_set(efl_added, "Both"),
+ //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
+ efl_pack_table(gd2, efl_added, i, j, 1, 1));
+ }
+ }
+
+ for (i = 0; i < 10; i++)
+ {
+ efl_add(EFL_UI_BUTTON_CLASS, bx,
+ efl_text_set(efl_added, "Vertical"),
+ efl_gfx_hint_weight_set(efl_added, EVAS_HINT_EXPAND, 0.0),
+ efl_gfx_hint_fill_set(efl_added, EINA_TRUE, EINA_FALSE),
+ //efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED, _bt_clicked, NULL),
+ efl_pack(bx, efl_added));
+ }
+ get_me_to_those_events(sc);
+ /* this should only trigger the inner scroller */
+ wheel_object(sc3, 0, 1);
+ ecore_main_loop_begin();
+ ck_assert_int_eq(called3, 2);
+ ck_assert_int_eq(called2, 0);
+ ck_assert_int_eq(called, 0);
+ called3 = 0;
+
+ /* this should only trigger the horizontal scroller */
+ wheel_object(sc2, 1, 1);
+ ecore_main_loop_begin();
+ ck_assert_int_eq(called3, 0);
+ ck_assert_int_eq(called2, 2);
+ ck_assert_int_eq(called, 0);
+ called2 = 0;
+
+ /* this should only trigger the outer scroller */
+ wheel_object_at(sc, 250, 400, 0, 1);
+ ecore_main_loop_begin();
+ ck_assert_int_eq(called3, 0);
+ ck_assert_int_eq(called2, 0);
+ ck_assert_int_eq(called, 2);
+}
+EFL_END_TEST
+
+void efl_ui_test_scroller(TCase *tc)
+{
+ tcase_add_test(tc, efl_ui_test_scroller_events);
+}
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 = [
'efl_ui_test_grid_collection.c',
'efl_ui_test_position_manager_common.c',
'efl_ui_test_popup.c',
+ 'efl_ui_test_scroller.c',
]
efl_ui_suite = executable('efl_ui_suite',