summaryrefslogtreecommitdiff
path: root/src/tests/elementary/elm_test_naviframe.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-08-06 14:03:48 -0400
committerStefan Schmidt <s.schmidt@samsung.com>2018-08-15 09:51:18 +0200
commite47c2d7006a1641910857a97e2a2f314841fe0cb (patch)
tree737e9d653692b2d4b119be672e0e3ad2d7e3a500 /src/tests/elementary/elm_test_naviframe.c
parent1c029b8fd96599bbb14965fa436efa265da5dd96 (diff)
tests/naviframe: add test to verify preserve_on_pop functionality
this adds a naviframe with button content and pushes/pops the stack a couple times to see if a delete callback is called on the button ref T7236 Differential Revision: https://phab.enlightenment.org/D6762
Diffstat (limited to 'src/tests/elementary/elm_test_naviframe.c')
-rw-r--r--src/tests/elementary/elm_test_naviframe.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/tests/elementary/elm_test_naviframe.c b/src/tests/elementary/elm_test_naviframe.c
index 7a9a279..507711e 100644
--- a/src/tests/elementary/elm_test_naviframe.c
+++ b/src/tests/elementary/elm_test_naviframe.c
@@ -6,6 +6,9 @@
6#include <Elementary.h> 6#include <Elementary.h>
7#include "elm_suite.h" 7#include "elm_suite.h"
8 8
9static int prev_abort;
10static int prev_abort_level;
11
9EFL_START_TEST (elm_naviframe_test_legacy_type_check) 12EFL_START_TEST (elm_naviframe_test_legacy_type_check)
10{ 13{
11 Evas_Object *win, *naviframe; 14 Evas_Object *win, *naviframe;
@@ -41,8 +44,86 @@ EFL_START_TEST (elm_naviframe_test_atspi_role_get)
41} 44}
42EFL_END_TEST 45EFL_END_TEST
43 46
47static Evas_Object *preserve_on_pop_button;
48static Evas_Object *button;
49static Elm_Object_Item *popped_it;
50
51static void
52_test_fail(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{
54 ck_abort_msg("Object deleted!");
55}
56
57void
58_elm_naviframe_test_content_preserve_on_pop_button_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
59{
60 elm_naviframe_item_push(data, "Next Page", NULL, NULL, preserve_on_pop_button, NULL);
61}
62
63static void
64_transition_finished(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
65{
66 static int count;
67 if (popped_it)
68 {
69 if (count++)
70 {
71 evas_object_event_callback_del(preserve_on_pop_button, EVAS_CALLBACK_DEL, _test_fail);
72 ecore_main_loop_quit();
73 }
74 else
75 elm_object_signal_emit(button, "elm,action,click", "elm");
76 }
77 else
78 popped_it = elm_naviframe_item_pop(obj);
79}
80
81EFL_START_TEST (elm_naviframe_test_content_preserve_on_pop)
82{
83 Evas_Object *win, *naviframe;
84
85 win = win_add(NULL, "naviframe", ELM_WIN_BASIC);
86
87 prev_abort = eina_log_abort_on_critical_get();
88 prev_abort_level = eina_log_abort_on_critical_level_get();
89 eina_log_abort_on_critical_set(1);
90 eina_log_abort_on_critical_level_set(1);
91
92 naviframe = elm_naviframe_add(win);
93 elm_naviframe_content_preserve_on_pop_set(naviframe, EINA_TRUE);
94
95 evas_object_size_hint_weight_set(naviframe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
96 elm_win_resize_object_add(win, naviframe);
97 evas_object_show(naviframe);
98
99 button = elm_button_add(naviframe);
100 elm_object_text_set(button, "Go to Second Page.");
101 evas_object_smart_callback_add(button, "clicked", _elm_naviframe_test_content_preserve_on_pop_button_cb, naviframe);
102
103 preserve_on_pop_button = elm_button_add(naviframe);
104 evas_object_event_callback_add(preserve_on_pop_button, EVAS_CALLBACK_DEL, _test_fail, NULL);
105 elm_object_text_set(preserve_on_pop_button, "Go to Next Page.");
106 evas_object_smart_callback_add(preserve_on_pop_button, "clicked", _elm_naviframe_test_content_preserve_on_pop_button_cb, naviframe);
107
108 elm_naviframe_item_push(naviframe, "First Page", NULL, NULL, button, NULL);
109
110 evas_object_smart_callback_add(naviframe, "transition,finished", _transition_finished, NULL);
111
112 evas_object_resize(win, 400, 400);
113 evas_object_show(win);
114 /* trigger next page push */
115 elm_object_signal_emit(button, "elm,action,click", "elm");
116
117 ecore_main_loop_begin();
118 eina_log_abort_on_critical_set(prev_abort);
119 eina_log_abort_on_critical_level_set(prev_abort_level);
120}
121EFL_END_TEST
122
44void elm_test_naviframe(TCase *tc) 123void elm_test_naviframe(TCase *tc)
45{ 124{
46 tcase_add_test(tc, elm_naviframe_test_legacy_type_check); 125 tcase_add_test(tc, elm_naviframe_test_legacy_type_check);
47 tcase_add_test(tc, elm_naviframe_test_atspi_role_get); 126 tcase_add_test(tc, elm_naviframe_test_atspi_role_get);
127
128 tcase_add_test(tc, elm_naviframe_test_content_preserve_on_pop);
48} 129}