4 #include "feature_test.h"
5 #include "cluster_view.h"
7 #include "homescreen-efl.h"
9 #include <Elementary.h>
12 extern void __t__cluster_view_scroll_to_page(int page_idx, bool animation);
13 extern int __t__cluster_view_get_current_page();
14 extern Evas_Object * __t__cluster_view_get_scroller(void);
15 extern cluster_page_t *__t__cluster_view_page_new(void);
17 static const int CASE_COUNT = 6;
18 static void __case_scroll_to_page(bool * is_passed);
19 static void __case_scroll_to_2_page(bool * is_passed);
20 static void __case_show_all_page(bool * is_passed);
21 static void __case_click_back_key(bool * is_passed);
24 Ecore_Timer * group_timer;
27 void(*case_pool[CASE_COUNT + 1])(bool * is_passed);
33 __case_scroll_to_page,
34 __case_scroll_to_2_page,
36 __case_click_back_key,
38 __case_click_back_key,
43 static Eina_Bool __group_timer_callback(void * data);
45 static void __set_up(void) { unit_clear_log(); }
46 static void __tear_down(void) { unit_clear_log(); }
48 static void __case_scroll_to_page(bool * is_passed)
50 __t__cluster_view_scroll_to_page(0, false);
51 TEST_ASSERT_EQUAL_INT(0, __t__cluster_view_get_current_page());
53 __t__cluster_view_scroll_to_page(1, false);
54 TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
56 __t__cluster_view_scroll_to_page(2, false);
57 TEST_ASSERT_EQUAL_INT(2, __t__cluster_view_get_current_page());
59 __t__cluster_view_scroll_to_page(3, false);
60 TEST_ASSERT_EQUAL_INT(3, __t__cluster_view_get_current_page());
62 __t__cluster_view_scroll_to_page(5, false);
63 TEST_ASSERT_EQUAL_INT(5, __t__cluster_view_get_current_page());
65 __t__cluster_view_scroll_to_page(2, false);
66 TEST_ASSERT_EQUAL_INT(2, __t__cluster_view_get_current_page());
68 __t__cluster_view_scroll_to_page(0, false);
69 TEST_ASSERT_EQUAL_INT(0, __t__cluster_view_get_current_page());
71 Evas_Object * scroller = __t__cluster_view_get_scroller();
72 elm_scroller_page_show(scroller, 0, 0);
74 elm_scroller_current_page_get(scroller, &page, NULL);
75 TEST_ASSERT_EQUAL_INT(0, page);
77 elm_scroller_page_show(scroller, 1, 0);
78 elm_scroller_current_page_get(scroller, &page, NULL);
79 TEST_ASSERT_EQUAL_INT(1, page);
81 elm_scroller_page_show(scroller, 3, 0);
82 elm_scroller_current_page_get(scroller, &page, NULL);
83 TEST_ASSERT_EQUAL_INT(3, page);
89 static void __case_scroll_to_2_page(bool * is_passed)
91 __t__cluster_view_scroll_to_page(1, true);
93 char buf[1024] = { 0, };
94 strcat(buf, "bring in 1 page\n");
95 TEST_ASSERT_EQUAL_LOG(buf);
100 static void __case_show_all_page(bool * is_passed)
102 Evas_Object * scroller = __t__cluster_view_get_scroller();
104 TEST_ASSERT_TRUE(evas_object_visible_get(scroller) == EINA_TRUE);
105 TEST_ASSERT_EQUAL_INT(VIEW_STATE_NORMAL, cluster_view_get_state());
106 TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
108 cluster_view_set_state(VIEW_STATE_ALL_PAGE);
110 TEST_ASSERT_EQUAL_INT(VIEW_STATE_ALL_PAGE, cluster_view_get_state());
115 static void __case_click_back_key(bool * is_passed)
117 TEST_ASSERT_EQUAL_INT(VIEW_STATE_ALL_PAGE, cluster_view_get_state());
118 TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
120 homescreen_efl_hw_back_key_release();
122 TEST_ASSERT_EQUAL_INT(VIEW_STATE_NORMAL, cluster_view_get_state());
123 TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
125 Evas_Object * scroller = __t__cluster_view_get_scroller();
126 TEST_ASSERT_TRUE(evas_object_visible_get(scroller) == EINA_FALSE);
131 void group_feature_all_page_back(unit_group_t * group)
133 __t__cluster_view_page_new();
134 __t__cluster_view_page_new();
135 __t__cluster_view_page_new();
136 __t__cluster_view_page_new();
137 __t__cluster_view_page_new();
138 __t__cluster_view_page_new();
139 __t__cluster_view_page_new();
142 if (s_info.group_timer) {
143 ecore_timer_del(s_info.group_timer);
144 s_info.group_timer = NULL;
147 s_info.current_case = 0;
148 s_info.group = group;
149 s_info.group_timer = ecore_timer_add(1.5, __group_timer_callback, NULL);
152 static Eina_Bool __group_timer_callback(void * data)
154 if (s_info.case_pool[s_info.current_case] == NULL) {
155 s_info.group->finish(s_info.group);
157 s_info.group_timer = NULL;
158 return ECORE_CALLBACK_CANCEL;
161 TEST_CASE(s_info.group, s_info.case_pool[s_info.current_case]);
162 s_info.current_case += 1;
164 return ECORE_CALLBACK_RENEW;