summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-05 14:11:23 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-08 19:56:32 +0200
commit1e73201169473a92c26c233377b9e5747b3e0776 (patch)
treecddb39df084e209fcbeed571fc0ad1e1c2cf03b4
parent10acaa67d9e9fc065127dc09dc3f2f48988f811a (diff)
efl_ui_spin: add tests for basic spin features
this tests for the correct event emission. And checks the wheel interaction. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9221
-rw-r--r--src/lib/elementary/Efl_Ui.h1
-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_spin.c100
-rw-r--r--src/tests/elementary/meson.build1
5 files changed, 104 insertions, 0 deletions
diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h
index 774c3ba281..7b99cf3a23 100644
--- a/src/lib/elementary/Efl_Ui.h
+++ b/src/lib/elementary/Efl_Ui.h
@@ -247,6 +247,7 @@ typedef Eo Efl_Ui_Spotlight_Indicator;
247# include <efl_ui_clickable.eo.h> 247# include <efl_ui_clickable.eo.h>
248# include <efl_ui_clickable_util.eo.h> 248# include <efl_ui_clickable_util.eo.h>
249# include <efl_ui_format.eo.h> 249# include <efl_ui_format.eo.h>
250# include <efl_ui_spin.eo.h>
250 251
251/** 252/**
252 * Initialize Elementary 253 * Initialize Elementary
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 36bdd37a45..07c47cbd3e 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -29,6 +29,7 @@ static const Efl_Test_Case etc[] = {
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_win", efl_ui_test_win }, 31 { "efl_ui_win", efl_ui_test_win },
32 { "efl_ui_spin", efl_ui_test_spin },
32 { NULL, NULL } 33 { NULL, NULL }
33}; 34};
34 35
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 79c7cba890..1366494c38 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -40,6 +40,7 @@ void 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_win(TCase *tc); 42void efl_ui_test_win(TCase *tc);
43void efl_ui_test_spin(TCase *tc);
43 44
44void loop_timer_interval_set(Eo *obj, double in); 45void loop_timer_interval_set(Eo *obj, double in);
45 46
diff --git a/src/tests/elementary/efl_ui_test_spin.c b/src/tests/elementary/efl_ui_test_spin.c
new file mode 100644
index 0000000000..98c5432a9d
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_spin.c
@@ -0,0 +1,100 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6#include "efl_ui_suite.h"
7
8static Eo *win, *spin;
9
10static void
11spin_setup()
12{
13 win = win_add();
14
15 spin = efl_add(EFL_UI_SPIN_CLASS, win);
16 efl_content_set(win, spin);
17}
18
19static void
20_set_flag(void *data, const Efl_Event *ev)
21{
22 Eina_Bool *b = data;
23
24 ck_assert_int_eq(*b, EINA_FALSE);
25
26 *b = EINA_TRUE;
27 ck_assert_ptr_eq(ev->info, NULL);
28}
29
30EFL_START_TEST (spin_value_events)
31{
32 Eina_Bool changed = EINA_FALSE, min_reached = EINA_FALSE, max_reached = EINA_FALSE;
33
34 efl_ui_range_limits_set(spin, -3.0, 3.0);
35 efl_ui_range_value_set(spin, 0.0);
36 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_CHANGED, _set_flag, &changed);
37 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_MIN_REACHED, _set_flag, &min_reached);
38 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_MAX_REACHED, _set_flag, &max_reached);
39
40 efl_ui_range_value_set(spin, 1.0);
41 ck_assert_int_eq(changed, EINA_TRUE);
42 ck_assert_int_eq(min_reached, EINA_FALSE);
43 ck_assert_int_eq(max_reached, EINA_FALSE);
44 changed = EINA_FALSE;
45 min_reached = EINA_FALSE;
46 max_reached = EINA_FALSE;
47
48 efl_ui_range_value_set(spin, 3.0);
49 ck_assert_int_eq(changed, EINA_TRUE);
50 ck_assert_int_eq(min_reached, EINA_FALSE);
51 ck_assert_int_eq(max_reached, EINA_TRUE);
52 changed = EINA_FALSE;
53 min_reached = EINA_FALSE;
54 max_reached = EINA_FALSE;
55
56 efl_ui_range_value_set(spin, -3.0);
57 ck_assert_int_eq(changed, EINA_TRUE);
58 ck_assert_int_eq(min_reached, EINA_TRUE);
59 ck_assert_int_eq(max_reached, EINA_FALSE);
60}
61EFL_END_TEST
62
63EFL_START_TEST (spin_wheel_test)
64{
65 Eina_Bool changed = EINA_FALSE, min_reached = EINA_FALSE, max_reached = EINA_FALSE;
66
67 efl_ui_range_limits_set(spin, -100.0, 100.0);
68 efl_ui_range_value_set(spin, 0.0);
69 efl_ui_range_step_set(spin, 10.0);
70 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_CHANGED, _set_flag, &changed);
71 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_MIN_REACHED, _set_flag, &min_reached);
72 efl_event_callback_add(spin, EFL_UI_SPIN_EVENT_MAX_REACHED, _set_flag, &max_reached);
73
74 efl_gfx_entity_size_set(win, EINA_SIZE2D(60, 60));
75 get_me_to_those_events(spin);
76 evas_event_feed_mouse_move(evas_object_evas_get(spin), 30, 30, 1234, NULL);
77 evas_event_feed_mouse_wheel(evas_object_evas_get(spin), -1, -1, 12345, NULL);
78 ck_assert(efl_ui_range_value_get(spin) == 10.0);
79 ck_assert_int_eq(changed, EINA_TRUE);
80 ck_assert_int_eq(min_reached, EINA_FALSE);
81 ck_assert_int_eq(max_reached, EINA_FALSE);
82 changed = EINA_FALSE;
83 min_reached = EINA_FALSE;
84 max_reached = EINA_FALSE;
85
86 evas_event_feed_mouse_wheel(evas_object_evas_get(spin), -1, 1, 12345, NULL);
87 ck_assert(efl_ui_range_value_get(spin) == 0.0);
88 ck_assert_int_eq(changed, EINA_TRUE);
89 ck_assert_int_eq(min_reached, EINA_FALSE);
90 ck_assert_int_eq(max_reached, EINA_FALSE);
91}
92EFL_END_TEST
93
94void efl_ui_test_spin(TCase *tc)
95{
96 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
97 tcase_add_checked_fixture(tc, spin_setup, NULL);
98 tcase_add_test(tc, spin_value_events);
99 tcase_add_test(tc, spin_wheel_test);
100}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 2bdd76845b..17458f36e0 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -143,6 +143,7 @@ efl_ui_suite_src = [
143 'efl_ui_test_check.c', 143 'efl_ui_test_check.c',
144 'efl_ui_test_radio_group.c', 144 'efl_ui_test_radio_group.c',
145 'efl_ui_test_progressbar.c', 145 'efl_ui_test_progressbar.c',
146 'efl_ui_test_spin.c',
146] 147]
147 148
148efl_ui_suite = executable('efl_ui_suite', 149efl_ui_suite = executable('efl_ui_suite',