summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-07-12 12:24:58 -0700
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-17 21:58:01 +0200
commitd902989b74cba94053b57daaa528d05b277ed3dd (patch)
tree429b639fa9daf182e0340cf38eae9b7b87d0e0cd
parent33d2e55e9707ac0bbee1adb85ba3de6b7cf712a4 (diff)
elementary: add a test for Efl.Ui.View interface.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9308
-rw-r--r--src/tests/elementary/spec/efl_test_ui_view.c65
-rw-r--r--src/tests/elementary/spec/efl_ui_spec_suite.h1
-rw-r--r--src/tests/elementary/spec/meson.build1
3 files changed, 67 insertions, 0 deletions
diff --git a/src/tests/elementary/spec/efl_test_ui_view.c b/src/tests/elementary/spec/efl_test_ui_view.c
new file mode 100644
index 0000000000..064da03080
--- /dev/null
+++ b/src/tests/elementary/spec/efl_test_ui_view.c
@@ -0,0 +1,65 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6#include "efl_ui_spec_suite.h"
7#include "suite_helpers.h"
8
9/* spec-meta-start
10 {"test-interface":"Efl.Ui.View",
11 "test-widgets": ["Efl.Ui.Image", "Efl.Ui.Layout", "Efl.Ui.Button"]}
12 spec-meta-end */
13
14typedef struct _Efl_Ui_Image_Model_Change Efl_Ui_Image_Model_Change;
15struct _Efl_Ui_Image_Model_Change
16{
17 Efl_Model *expected_current;
18
19 Eina_Bool called;
20 Eina_Bool previous;
21 Eina_Bool current;
22};
23
24static void
25_efl_ui_image_model_changed(void *data, const Efl_Event *event)
26{
27 Efl_Ui_Image_Model_Change *change = data;
28 Efl_Model_Changed_Event *ev = event->info;
29
30 ck_assert(!change->called);
31 change->called = EINA_TRUE;
32 change->previous = ev->previous ? EINA_TRUE : EINA_FALSE;
33 ck_assert_ptr_eq(ev->current, change->expected_current);
34 change->current = ev->current ? EINA_TRUE : EINA_FALSE;
35}
36
37EFL_START_TEST(model_change_event)
38{
39 Efl_Model *model = efl_add(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
40 Efl_Ui_Image_Model_Change test = { NULL, EINA_FALSE, EINA_FALSE, EINA_FALSE };
41
42 efl_event_callback_add(widget, EFL_UI_VIEW_EVENT_MODEL_CHANGED,
43 _efl_ui_image_model_changed, &test);
44
45 ck_assert_int_eq(test.called, EINA_FALSE);
46 test.expected_current = model;
47 efl_ui_view_model_set(widget, model);
48 ck_assert_int_eq(test.called, EINA_TRUE);
49 ck_assert_int_eq(test.previous, EINA_FALSE);
50 ck_assert_int_eq(test.current, EINA_TRUE);
51
52 test.called = EINA_FALSE;
53 test.expected_current = NULL;
54 efl_ui_view_model_set(widget, NULL);
55 ck_assert_int_eq(test.called, EINA_TRUE);
56 ck_assert_int_eq(test.previous, EINA_TRUE);
57 ck_assert_int_eq(test.current, EINA_FALSE);
58}
59EFL_END_TEST
60
61void
62efl_ui_view_behavior_test(TCase *tc)
63{
64 tcase_add_test(tc, model_change_event);
65}
diff --git a/src/tests/elementary/spec/efl_ui_spec_suite.h b/src/tests/elementary/spec/efl_ui_spec_suite.h
index a1ecbd59ed..01be37652d 100644
--- a/src/tests/elementary/spec/efl_ui_spec_suite.h
+++ b/src/tests/elementary/spec/efl_ui_spec_suite.h
@@ -18,6 +18,7 @@ void efl_ui_clickable_behavior_test(TCase *tc);
18void efl_ui_format_behavior_test(TCase *tc); 18void efl_ui_format_behavior_test(TCase *tc);
19void efl_ui_range_display_behavior_test(TCase *tc); 19void efl_ui_range_display_behavior_test(TCase *tc);
20void efl_ui_range_display_interactive_behavior_test(TCase *tc); 20void efl_ui_range_display_interactive_behavior_test(TCase *tc);
21void efl_ui_view_behavior_test(TCase *tc);
21 22
22void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len); 23void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len);
23void efl_test_container_expect_evt_content_added(Efl_Ui_Widget *widget, const Efl_Event_Description *ev, Eina_Bool *flag, void *event_data); 24void efl_test_container_expect_evt_content_added(Efl_Ui_Widget *widget, const Efl_Event_Description *ev, Eina_Bool *flag, void *event_data);
diff --git a/src/tests/elementary/spec/meson.build b/src/tests/elementary/spec/meson.build
index e80a24d166..eb047ed957 100644
--- a/src/tests/elementary/spec/meson.build
+++ b/src/tests/elementary/spec/meson.build
@@ -8,6 +8,7 @@ efl_ui_suite_behavior_test_files = files([
8 'efl_test_format.c', 8 'efl_test_format.c',
9 'efl_test_range_display.c', 9 'efl_test_range_display.c',
10 'efl_test_range_interactive.c', 10 'efl_test_range_interactive.c',
11 'efl_test_ui_view.c',
11]) 12])
12 13
13efl_ui_suite_behavior_src = files([ 14efl_ui_suite_behavior_src = files([