+#include "test.h"
+#if TEST_MODE
+
+#include "feature_test.h"
+#include "cluster_view.h"
+#include "view.h"
+#include "homescreen-efl.h"
+
+#include <Elementary.h>
+#include <string.h>
+
+extern void __t__cluster_view_scroll_to_page(int page_idx, bool animation);
+extern int __t__cluster_view_get_current_page();
+extern Evas_Object * __t__cluster_view_get_scroller(void);
+extern cluster_page_t *__t__cluster_view_page_new(void);
+
+static const int CASE_COUNT = 6;
+static void __case_scroll_to_page(bool * is_passed);
+static void __case_scroll_to_2_page(bool * is_passed);
+static void __case_show_all_page(bool * is_passed);
+static void __case_click_back_key(bool * is_passed);
+
+static struct {
+ Ecore_Timer * group_timer;
+ unit_group_t * group;
+ int current_case;
+ void(*case_pool[CASE_COUNT + 1])(bool * is_passed);
+} s_info = {
+ .group_timer = NULL,
+ .group = NULL,
+ .current_case = 0,
+ .case_pool = {
+ __case_scroll_to_page,
+ __case_scroll_to_2_page,
+ __case_show_all_page,
+ __case_click_back_key,
+ __case_show_all_page,
+ __case_click_back_key,
+ NULL,
+ },
+};
+
+static Eina_Bool __group_timer_callback(void * data);
+
+static void __set_up(void) { unit_clear_log(); }
+static void __tear_down(void) { unit_clear_log(); }
+
+static void __case_scroll_to_page(bool * is_passed)
+{
+ __t__cluster_view_scroll_to_page(0, false);
+ TEST_ASSERT_EQUAL_INT(0, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(1, false);
+ TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(2, false);
+ TEST_ASSERT_EQUAL_INT(2, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(3, false);
+ TEST_ASSERT_EQUAL_INT(3, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(5, false);
+ TEST_ASSERT_EQUAL_INT(5, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(2, false);
+ TEST_ASSERT_EQUAL_INT(2, __t__cluster_view_get_current_page());
+
+ __t__cluster_view_scroll_to_page(0, false);
+ TEST_ASSERT_EQUAL_INT(0, __t__cluster_view_get_current_page());
+
+ Evas_Object * scroller = __t__cluster_view_get_scroller();
+ elm_scroller_page_show(scroller, 0, 0);
+ int page = -1;
+ elm_scroller_current_page_get(scroller, &page, NULL);
+ TEST_ASSERT_EQUAL_INT(0, page);
+
+ elm_scroller_page_show(scroller, 1, 0);
+ elm_scroller_current_page_get(scroller, &page, NULL);
+ TEST_ASSERT_EQUAL_INT(1, page);
+
+ elm_scroller_page_show(scroller, 3, 0);
+ elm_scroller_current_page_get(scroller, &page, NULL);
+ TEST_ASSERT_EQUAL_INT(3, page);
+
+ *is_passed = true;
+
+}
+
+static void __case_scroll_to_2_page(bool * is_passed)
+{
+ __t__cluster_view_scroll_to_page(1, true);
+
+ char buf[1024] = { 0, };
+ strcat(buf, "bring in 1 page\n");
+ TEST_ASSERT_EQUAL_LOG(buf);
+
+ *is_passed = true;
+}
+
+static void __case_show_all_page(bool * is_passed)
+{
+ Evas_Object * scroller = __t__cluster_view_get_scroller();
+
+ TEST_ASSERT_TRUE(evas_object_visible_get(scroller) == EINA_TRUE);
+ TEST_ASSERT_EQUAL_INT(VIEW_STATE_NORMAL, cluster_view_get_state());
+ TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
+
+ cluster_view_set_state(VIEW_STATE_ALL_PAGE);
+
+ TEST_ASSERT_EQUAL_INT(VIEW_STATE_ALL_PAGE, cluster_view_get_state());
+
+ *is_passed = true;
+}
+
+static void __case_click_back_key(bool * is_passed)
+{
+ TEST_ASSERT_EQUAL_INT(VIEW_STATE_ALL_PAGE, cluster_view_get_state());
+ TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
+
+ homescreen_efl_hw_back_key_release();
+
+ TEST_ASSERT_EQUAL_INT(VIEW_STATE_NORMAL, cluster_view_get_state());
+ TEST_ASSERT_EQUAL_INT(1, __t__cluster_view_get_current_page());
+
+ Evas_Object * scroller = __t__cluster_view_get_scroller();
+ TEST_ASSERT_TRUE(evas_object_visible_get(scroller) == EINA_FALSE);
+
+ *is_passed = true;
+}
+
+void group_feature_all_page_back(unit_group_t * group)
+{
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+ __t__cluster_view_page_new();
+
+
+ if (s_info.group_timer) {
+ ecore_timer_del(s_info.group_timer);
+ s_info.group_timer = NULL;
+ }
+
+ s_info.current_case = 0;
+ s_info.group = group;
+ s_info.group_timer = ecore_timer_add(1.5, __group_timer_callback, NULL);
+}
+
+static Eina_Bool __group_timer_callback(void * data)
+{
+ if (s_info.case_pool[s_info.current_case] == NULL) {
+ s_info.group->finish(s_info.group);
+
+ s_info.group_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ TEST_CASE(s_info.group, s_info.case_pool[s_info.current_case]);
+ s_info.current_case += 1;
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+#endif
+