summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-05 13:58:03 -0400
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-06 09:26:41 +0200
commit660d9937525c0b43d8d820507a50c2381ce9573c (patch)
treea635160a9b58d25f44904ef3a161a4833c546324
parent15eff4082011fd13cadc781916e4813a008d0b94 (diff)
tests/efl_ui_popup: add tests for this widget
these tests cover all the cases in the elm_test efl.ui.popup example Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9509
-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_popup.c183
-rw-r--r--src/tests/elementary/meson.build1
4 files changed, 186 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 707f450939..a9894a0003 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -27,6 +27,7 @@ static const Efl_Test_Case etc[] = {
27 { "efl_ui_widget", efl_ui_test_widget }, 27 { "efl_ui_widget", efl_ui_test_widget },
28 { "efl_ui_spotlight", efl_ui_test_spotlight}, 28 { "efl_ui_spotlight", efl_ui_test_spotlight},
29 { "efl_ui_check", efl_ui_test_check }, 29 { "efl_ui_check", efl_ui_test_check },
30 { "efl_ui_popup", efl_ui_test_popup },
30 { "efl_ui_progressbar", efl_ui_test_progressbar }, 31 { "efl_ui_progressbar", efl_ui_test_progressbar },
31 { "efl_ui_radio_group", efl_ui_test_radio_group }, 32 { "efl_ui_radio_group", efl_ui_test_radio_group },
32 { "efl_ui_slider", efl_ui_test_slider }, 33 { "efl_ui_slider", efl_ui_test_slider },
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index a2ad7945f7..3c6c708e2e 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -47,6 +47,7 @@ void efl_ui_test_item_container(TCase *tc);
47void efl_ui_test_list_container(TCase *tc); 47void 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);
50 51
51void loop_timer_interval_set(Eo *obj, double in); 52void loop_timer_interval_set(Eo *obj, double in);
52 53
diff --git a/src/tests/elementary/efl_ui_test_popup.c b/src/tests/elementary/efl_ui_test_popup.c
new file mode 100644
index 0000000000..45231674e4
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_popup.c
@@ -0,0 +1,183 @@
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
9#define WIN_SIZE 500
10
11EFL_START_TEST(efl_ui_test_popup_basic_align)
12{
13 Eo *win, *popup;
14
15 win = win_add();
16 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
17
18 popup = efl_add(EFL_UI_POPUP_CLASS, win);
19 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160));
20
21 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
22 efl_text_set(btn, "Efl.Ui.Popup");
23
24 efl_content_set(popup, btn);
25
26
27 get_me_to_those_events(popup);
28
29 {
30 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
31 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
32
33 /* verify centered */
34 ck_assert_int_eq(pos.x, WIN_SIZE / 2 - sz.w / 2);
35 ck_assert_int_eq(pos.y, WIN_SIZE / 2 - sz.h / 2);
36 }
37
38 efl_ui_popup_align_set(popup, EFL_UI_POPUP_ALIGN_LEFT);
39 efl_canvas_group_calculate(popup);
40 {
41 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
42 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
43
44 /* verify left */
45 ck_assert_int_eq(pos.x, 0);
46 ck_assert_int_eq(pos.y, WIN_SIZE / 2 - sz.h / 2);
47 }
48
49
50 efl_ui_popup_align_set(popup, EFL_UI_POPUP_ALIGN_RIGHT);
51 efl_canvas_group_calculate(popup);
52 {
53 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
54 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
55
56 /* verify right */
57 ck_assert_int_eq(pos.x, WIN_SIZE - sz.w);
58 ck_assert_int_eq(pos.y, WIN_SIZE / 2 - sz.h / 2);
59 }
60
61 efl_ui_popup_align_set(popup, EFL_UI_POPUP_ALIGN_TOP);
62 efl_canvas_group_calculate(popup);
63 {
64 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
65 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
66
67 /* verify top */
68 ck_assert_int_eq(pos.x, WIN_SIZE / 2 - sz.w / 2);
69 ck_assert_int_eq(pos.y, 0);
70 }
71
72 efl_ui_popup_align_set(popup, EFL_UI_POPUP_ALIGN_BOTTOM);
73 efl_canvas_group_calculate(popup);
74 {
75 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
76 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
77
78 /* verify bottom */
79 ck_assert_int_eq(pos.x, WIN_SIZE / 2 - sz.w / 2);
80 ck_assert_int_eq(pos.y, WIN_SIZE - sz.h);
81 }
82
83 efl_gfx_entity_position_set(popup, EINA_POSITION2D(0, 0));
84 efl_canvas_group_calculate(popup);
85 {
86 Eina_Position2D pos = efl_gfx_entity_position_get(popup);
87
88 /* verify bottom */
89 ck_assert_int_eq(pos.x, 0);
90 ck_assert_int_eq(pos.y, 0);
91 }
92}
93EFL_END_TEST
94
95EFL_START_TEST(efl_ui_test_popup_basic_sizing)
96{
97 Eo *win, *popup;
98
99 win = win_add();
100 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
101
102 popup = efl_add(EFL_UI_POPUP_CLASS, win);
103 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160));
104
105 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
106 efl_text_set(btn, "Efl.Ui.Popup");
107
108 efl_content_set(popup, btn);
109
110
111 get_me_to_those_events(popup);
112
113 Eina_Size2D sz = efl_gfx_entity_size_get(popup);
114 ck_assert_int_eq(sz.w, 160);
115 ck_assert_int_eq(sz.h, 160);
116}
117EFL_END_TEST
118
119EFL_START_TEST(efl_ui_test_popup_events)
120{
121 Eo *win, *popup;
122 int called = 0;
123
124 win = win_add();
125 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
126
127 popup = efl_add(EFL_UI_POPUP_CLASS, win);
128
129 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED,
130 (void*)event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called);
131 efl_event_callback_add(popup, EFL_UI_POPUP_EVENT_TIMEOUT, event_callback_that_quits_the_main_loop_when_called, NULL);
132 efl_ui_popup_size_set(popup, EINA_SIZE2D(160, 160));
133
134 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, popup);
135 efl_text_set(btn, "Efl.Ui.Popup");
136
137 efl_content_set(popup, btn);
138
139
140 get_me_to_those_events(popup);
141 click_object_at(win, 1, 1);
142 /* trigger signal process -> events */
143 ecore_main_loop_iterate();
144 ck_assert_int_eq(called, 1);
145 called = 0;
146
147 Eo *repeat_test_btn = efl_add(EFL_UI_BUTTON_CLASS, win);
148 efl_gfx_entity_position_set(repeat_test_btn, EINA_POSITION2D(0, 0));
149 efl_gfx_entity_size_set(repeat_test_btn, EINA_SIZE2D(100, 100));
150 efl_text_set(repeat_test_btn, "Repeat Event Test");
151 efl_event_callback_add(repeat_test_btn, EFL_INPUT_EVENT_CLICKED,
152 (void*)event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called, &called);
153 efl_ui_popup_part_backwall_repeat_events_set(efl_part(popup, "backwall"), EINA_TRUE);
154 click_object(repeat_test_btn);
155
156 efl_ui_popup_timeout_set(popup, 0.1);
157 ecore_main_loop_begin();
158}
159EFL_END_TEST
160
161EFL_START_TEST(efl_ui_test_popup_backwall_img)
162{
163 Eo *win, *popup;
164 char buf[PATH_MAX];
165
166 win = win_add();
167 efl_gfx_entity_size_set(win, EINA_SIZE2D(WIN_SIZE, WIN_SIZE));
168
169 popup = efl_add(EFL_UI_POPUP_CLASS, win);
170
171 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", ELM_IMAGE_DATA_DIR);
172 ck_assert(efl_file_simple_load(efl_part(popup, "backwall"), buf, NULL));
173 ck_assert_str_eq(efl_file_get(efl_part(popup, "backwall")), buf);
174}
175EFL_END_TEST
176
177void efl_ui_test_popup(TCase *tc)
178{
179 tcase_add_test(tc, efl_ui_test_popup_events);
180 tcase_add_test(tc, efl_ui_test_popup_basic_sizing);
181 tcase_add_test(tc, efl_ui_test_popup_basic_align);
182 tcase_add_test(tc, efl_ui_test_popup_backwall_img);
183}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 7046aa8862..dff90e788b 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -152,6 +152,7 @@ efl_ui_suite_src = [
152 'efl_ui_test_list_collection.c', 152 'efl_ui_test_list_collection.c',
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] 156]
156 157
157efl_ui_suite = executable('efl_ui_suite', 158efl_ui_suite = executable('efl_ui_suite',