summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-04-17 14:45:19 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-04-21 10:51:46 +0200
commit0bd3ab825281bffcd9a91a0f1a14835287a21f99 (patch)
treeec3b76cb233bbfc5c7864dfaa05e148de7d1ee2c
parent02ce09fbb47c6a64d22d23d511f520b8f8abbcae (diff)
efl_ui_spec: add tests for efl.content
Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D8640
-rw-r--r--src/tests/elementary/spec/efl_test_content.c114
-rw-r--r--src/tests/elementary/spec/efl_ui_spec_suite.c1
-rw-r--r--src/tests/elementary/spec/efl_ui_spec_suite.h2
-rwxr-xr-xsrc/tests/elementary/spec/generator.py4
-rw-r--r--src/tests/elementary/spec/meson.build1
5 files changed, 121 insertions, 1 deletions
diff --git a/src/tests/elementary/spec/efl_test_content.c b/src/tests/elementary/spec/efl_test_content.c
new file mode 100644
index 0000000000..e0652b6e02
--- /dev/null
+++ b/src/tests/elementary/spec/efl_test_content.c
@@ -0,0 +1,114 @@
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
9EFL_START_TEST(content_set_get)
10{
11 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
12
13 ck_assert_int_eq(efl_content_set(widget, w), EINA_TRUE);
14 ck_assert_ptr_eq(efl_ui_widget_parent_get(w), widget);
15 ck_assert_ptr_eq(efl_content_get(widget), w);
16
17 EXPECT_ERROR_START;
18 ck_assert_int_eq(efl_content_set(widget, (void*)0x1), EINA_FALSE);
19 EXPECT_ERROR_END;
20 ck_assert_ptr_eq(efl_content_get(widget), NULL);
21}
22EFL_END_TEST
23
24EFL_START_TEST(content_set_get2)
25{
26 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
27
28 ck_assert_int_eq(efl_content_set(widget, w), EINA_TRUE);
29 ck_assert_ptr_eq(efl_ui_widget_parent_get(w), widget);
30 ck_assert_ptr_eq(efl_content_get(widget), w);
31
32 ck_assert_int_eq(efl_content_set(widget, NULL), EINA_TRUE);
33 ck_assert_ptr_eq(efl_content_get(widget), NULL);
34}
35EFL_END_TEST
36
37
38EFL_START_TEST(content_unset)
39{
40 Efl_Ui_Widget *w = efl_add(WIDGET_CLASS, win);
41
42 ck_assert_int_eq(efl_content_set(widget, w), EINA_TRUE);
43 efl_content_unset(widget);
44 ck_assert_ptr_eq(efl_content_get(widget), NULL);
45}
46EFL_END_TEST
47
48EFL_START_TEST(content_lifetime1)
49{
50 Efl_Ui_Widget *w1 = efl_add(WIDGET_CLASS, win);
51
52 efl_wref_add(w1, &w1);
53 ck_assert_int_eq(efl_content_set(widget, w1), EINA_TRUE);
54 efl_del(widget);
55 ck_assert_ptr_eq(w1, NULL);
56}
57EFL_END_TEST
58
59EFL_START_TEST(content_lifetime2)
60{
61 Efl_Ui_Widget *w1 = efl_add(WIDGET_CLASS, win), *w2 = efl_add(WIDGET_CLASS, win);
62
63 efl_wref_add(w2, &w2);
64 efl_wref_add(w1, &w1);
65
66 ck_assert_int_eq(efl_content_set(widget, w1), EINA_TRUE);
67 ck_assert_int_eq(efl_content_set(widget, w2), EINA_TRUE);
68 ck_assert_ptr_eq(w1, NULL);
69 efl_del(widget);
70 ck_assert_ptr_eq(w2, NULL);
71}
72EFL_END_TEST
73
74EFL_START_TEST(content_lifetime3)
75{
76 Efl_Ui_Widget *w1 = efl_add(WIDGET_CLASS, win);
77 Eina_Bool content_changed_event = EINA_FALSE;
78
79 ck_assert_int_eq(efl_content_set(widget, w1), EINA_TRUE);
80 efl_test_container_expect_evt_content_added(widget, EFL_CONTENT_EVENT_CONTENT_CHANGED, &content_changed_event, NULL);
81 efl_del(w1);
82 ck_assert_int_eq(content_changed_event, EINA_TRUE);
83 ck_assert_ptr_eq(efl_content_get(widget), NULL);
84}
85EFL_END_TEST
86
87EFL_START_TEST(content_event)
88{
89 Efl_Ui_Widget *w1 = efl_add(WIDGET_CLASS, win), *w2 = efl_add(WIDGET_CLASS, win);
90 Eina_Bool content_changed_event;
91
92 content_changed_event = EINA_FALSE;
93 efl_test_container_expect_evt_content_added(widget, EFL_CONTENT_EVENT_CONTENT_CHANGED, &content_changed_event, w1);
94 ck_assert_int_eq(efl_content_set(widget, w1), EINA_TRUE);
95 ck_assert_int_eq(content_changed_event, EINA_TRUE);
96
97 content_changed_event = EINA_FALSE;
98 efl_test_container_expect_evt_content_added(widget, EFL_CONTENT_EVENT_CONTENT_CHANGED, &content_changed_event, w2);
99 ck_assert_int_eq(efl_content_set(widget, w2), EINA_TRUE);
100 ck_assert_int_eq(content_changed_event, EINA_TRUE);
101}
102EFL_END_TEST
103
104void
105efl_content_behavior_test(TCase *tc)
106{
107 tcase_add_test(tc, content_set_get);
108 tcase_add_test(tc, content_set_get2);
109 tcase_add_test(tc, content_lifetime1);
110 tcase_add_test(tc, content_lifetime2);
111 tcase_add_test(tc, content_lifetime3);
112 tcase_add_test(tc, content_unset);
113 tcase_add_test(tc, content_event);
114}
diff --git a/src/tests/elementary/spec/efl_ui_spec_suite.c b/src/tests/elementary/spec/efl_ui_spec_suite.c
index 1b84cf540e..22ed329647 100644
--- a/src/tests/elementary/spec/efl_ui_spec_suite.c
+++ b/src/tests/elementary/spec/efl_ui_spec_suite.c
@@ -2,6 +2,7 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#include <Elementary.h>
5#include <Efl_Ui.h> 6#include <Efl_Ui.h>
6#include "efl_ui_spec_suite.h" 7#include "efl_ui_spec_suite.h"
7#include "suite_helpers.h" 8#include "suite_helpers.h"
diff --git a/src/tests/elementary/spec/efl_ui_spec_suite.h b/src/tests/elementary/spec/efl_ui_spec_suite.h
index c8e008fa60..6585fb58bd 100644
--- a/src/tests/elementary/spec/efl_ui_spec_suite.h
+++ b/src/tests/elementary/spec/efl_ui_spec_suite.h
@@ -12,7 +12,7 @@ extern Evas_Object *widget;
12 12
13void efl_pack_behavior_test(TCase *tc); 13void efl_pack_behavior_test(TCase *tc);
14void efl_pack_linear_behavior_test(TCase *tc); 14void efl_pack_linear_behavior_test(TCase *tc);
15 15void efl_content_behavior_test(TCase *tc);
16 16
17void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len); 17void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len);
18void efl_test_container_expect_evt_content_added(Efl_Ui_Widget *widget, const Efl_Event_Description *ev, Eina_Bool *flag, void *event_data); 18void 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/generator.py b/src/tests/elementary/spec/generator.py
index 47749fac07..1c61efac6a 100755
--- a/src/tests/elementary/spec/generator.py
+++ b/src/tests/elementary/spec/generator.py
@@ -3,6 +3,10 @@
3tests = [ 3tests = [
4 ["Efl.Pack_Linear" , "Efl.Ui.Box"], 4 ["Efl.Pack_Linear" , "Efl.Ui.Box"],
5 ["Efl.Pack" , "Efl.Ui.Table"], 5 ["Efl.Pack" , "Efl.Ui.Table"],
6 ["Efl.Content" , "Efl.Ui.Button", "Efl.Ui.Frame", "Efl.Ui.Grid_Default_Item",
7 "Efl.Ui.List_Default_Item", "Efl.Ui.List_Empty_Item",
8 "Efl.Ui.Navigation_Layout", "Efl.Ui.Panel", "Efl.Ui.Progressbar",
9 "Efl.Ui.Radio"]
6] 10]
7 11
8fixture_gen_template = """ 12fixture_gen_template = """
diff --git a/src/tests/elementary/spec/meson.build b/src/tests/elementary/spec/meson.build
index 495d864bda..7f87d8e8e4 100644
--- a/src/tests/elementary/spec/meson.build
+++ b/src/tests/elementary/spec/meson.build
@@ -6,6 +6,7 @@ efl_ui_suite_behavior_src = [
6 'efl_test_pack.c', 6 'efl_test_pack.c',
7 'efl_test_pack_linear.c', 7 'efl_test_pack_linear.c',
8 'efl_test_container.c', 8 'efl_test_container.c',
9 'efl_test_content.c',
9] 10]
10 11
11test_generator = find_program('generator.py') 12test_generator = find_program('generator.py')