diff options
author | YoungHun Cho <hoon.cho@samsung.com> | 2017-04-19 10:31:27 +0900 |
---|---|---|
committer | YoungHun Cho <hoon.cho@samsung.com> | 2017-04-19 11:03:14 +0900 |
commit | a62c19fdb80fcf8e8779bc303a15687515731240 (patch) | |
tree | 8fbabd2e9e20c68304c5fa35d8787b5850c59781 | |
parent | e235fa2fdf920e9ad99f5d9f3e5d99029d902d2a (diff) | |
download | w3-home-a62c19fdb80fcf8e8779bc303a15687515731240.tar.gz w3-home-a62c19fdb80fcf8e8779bc303a15687515731240.tar.bz2 w3-home-a62c19fdb80fcf8e8779bc303a15687515731240.zip |
group_feature_moments_pull_down & group_function_moments_view
Change-Id: Iaf31ade43f79d6b7cfad919e1fe8dc617c84ffea
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | inc/moments/moments.h | 5 | ||||
-rwxr-xr-x | inc/moments/moments_view.h | 6 | ||||
-rwxr-xr-x | src/layout.c | 12 | ||||
-rwxr-xr-x | src/moments/moments_manager.c | 8 | ||||
-rwxr-xr-x | src/moments/moments_view.c | 105 | ||||
-rwxr-xr-x | test/feature_test/group_feature_moments_pull_down.c | 24 | ||||
-rwxr-xr-x | test/feature_test/group_feature_moments_show.c | 4 | ||||
-rwxr-xr-x | test/feature_test/group_feature_status_area_layer_show.c | 4 | ||||
-rwxr-xr-x | test/function_test/function_test.c | 50 | ||||
-rwxr-xr-x | test/function_test/function_test.h | 14 | ||||
-rwxr-xr-x | test/function_test/group_function_moments_view.c | 83 | ||||
-rwxr-xr-x | test/test_main.c | 3 | ||||
-rwxr-xr-x | test/unit/inc/unit.h | 2 |
14 files changed, 268 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 08178ac..816bbee 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,8 @@ ADD_EXECUTABLE(${PROJECT_NAME} src/moments/moments_view_animator.c src/home_app_manager.c + test/function_test/function_test.c + test/function_test/group_function_moments_view.c test/feature_test/feature_test.c test/feature_test/feature_test_log.c test/feature_test/group_feature_moments_show.c diff --git a/inc/moments/moments.h b/inc/moments/moments.h index a0c3ea7..3d88c12 100755 --- a/inc/moments/moments.h +++ b/inc/moments/moments.h @@ -26,8 +26,7 @@ void moments_fini(void); void moments_show(void); void moments_hide(void); - -void moments_draw(int x, int y); -void moments_put_down(int x, int y); +void moments_move(int from_y, int to_y); +void moments_put_down(void); #endif diff --git a/inc/moments/moments_view.h b/inc/moments/moments_view.h index 3bc590e..9ddf308 100755 --- a/inc/moments/moments_view.h +++ b/inc/moments/moments_view.h @@ -34,9 +34,7 @@ void moments_destroy_ui(void); bool moments_view_show(void); bool moments_view_hide(void); - -void moments_view_draw(int x, int y); -void moments_view_draw_down(int x, int y); -void moments_view_draw_up(int x, int y); +void moments_view_move(int from_y, int to_y); +void moments_view_put_down(void); #endif diff --git a/src/layout.c b/src/layout.c index 25f2bd2..ea382a3 100755 --- a/src/layout.c +++ b/src/layout.c @@ -289,16 +289,16 @@ static void __layout_mouse_move(Evas_Object *layout, int cur_x, int cur_y) int down_x, down_y, vec_x, vec_y; - if (moments_get_visible()) { - moments_draw(cur_x, cur_y); - return ; - } - if (!evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_PRESSED)) return; down_x = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_X); down_y = (int) evas_object_data_get(layout, PRIVATE_DATA_KEY_LAYOUT_DOWN_Y); + if (moments_get_visible()) { + moments_move(down_y, cur_y); + return ; + } + vec_x = cur_x - down_x; vec_y = cur_y - down_y; @@ -325,7 +325,7 @@ static void __layout_mouse_up(Evas_Object *layout, int up_x, int up_y) _D("Mouse is up on the layout"); if (moments_get_visible()) { - moments_put_down(up_x, up_y); + moments_put_down(); return ; } diff --git a/src/moments/moments_manager.c b/src/moments/moments_manager.c index c3bbfab..36ecac9 100755 --- a/src/moments/moments_manager.c +++ b/src/moments/moments_manager.c @@ -91,14 +91,14 @@ void moments_hide(void) scroller_unfreeze(s_info.bg_scroller); } -void moments_draw(int x, int y) +void moments_move(int from_y, int to_y) { - moments_view_draw(x, y); + moments_view_move(from_y, to_y); } -void moments_put_down(int x, int y) +void moments_put_down(void) { - moments_view_draw_down(x, y); + moments_view_put_down(); } static key_cb_ret_e __back_key_cb(void *data) diff --git a/src/moments/moments_view.c b/src/moments/moments_view.c index 3031756..314ade9 100755 --- a/src/moments/moments_view.c +++ b/src/moments/moments_view.c @@ -43,6 +43,7 @@ static struct __view_s { bool is_drawing_up; int down_y; bool is_pressed; + bool is_show; } s_info = { .win = NULL, .background_layout = NULL, @@ -53,15 +54,18 @@ static struct __view_s { .is_drawing_up = false, .down_y = -1, .is_pressed = false, + .is_show = false, }; +extern void moments_view_animator_move(Evas_Object *layout[2], MOVEMENT info[2], void(*cb)(void)); + static Evas_Object *__create_base_layout(Evas_Object *parent); static Evas_Object *__create_status_layout(Evas_Object *parent); static Evas_Object *__create_base_size_setter(Evas_Object *base_layout); //atic Evas_Object *__create_moments_content(Evas_Object *base_layout); -static void __put_down(int cur_y, int limit_y); +static void __put_down(void); static void __freeze_touch_event(void); static void __unfreeze_touch_event(void); static void __hide_complete_cb(void); @@ -69,9 +73,7 @@ static void __pull_down_complete_cb(void); static void __down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void __move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void __up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - -extern void moments_view_animator_move(Evas_Object *layout[2], MOVEMENT info[2], void(*cb)(void)); - +static void __get_dest_y(int from_y, int to_y, int * dest_y); Evas_Object *moments_create_ui(Evas_Object *base_win) { @@ -189,31 +191,26 @@ bool moments_view_hide(void) return true; } -void moments_view_draw(int x, int y) +void moments_view_move(int from_y, int to_y) { - if (animator_is_ongoing()) { - if (y < MOMENTS_INIT_H) { - return ; - } + int y = OUTSIDE_Y; + __get_dest_y(from_y, to_y, &y); + + if (y == OUTSIDE_Y) return ; + + if (animator_is_ongoing()) { animator_stop(); } - y = y - WINDOW_H + MOMENTS_INIT_H; - evas_object_move(s_info.background_layout, 0, y > 0 ? 0 : y); -} -void moments_view_draw_down(int x, int y) -{ - _D("%s", __func__); - - __put_down(y, MOMENT_DRAW_DOWN_LIMIT_Y); + evas_object_move(s_info.background_layout, 0, y); } -void moments_view_draw_up(int x, int y) +void moments_view_put_down(void) { _D("%s", __func__); - __put_down(y, MOMENT_DRAW_UP_LIMIT_Y); + __put_down(); } static Evas_Object *__create_base_layout(Evas_Object *parent) @@ -298,7 +295,7 @@ __fail: return NULL; } -static void __put_down(int cur_y, int limit_y) +static void __put_down(void) { if (animator_is_ongoing()) { animator_stop(); @@ -308,7 +305,10 @@ static void __put_down(int cur_y, int limit_y) MOVEMENT movement_info[2]; evas_object_geometry_get(s_info.background_layout, &x, &y, &w, &h); - if ((y + h) < limit_y) { + bool is_short_drag_down = y < (-WINDOW_H + MOMENTS_INIT_H + MOMENT_DRAW_LIMIT); + bool is_drag_up = s_info.is_show && y < (- MOMENT_DRAW_LIMIT); + + if (is_short_drag_down || is_drag_up) { moments_hide(); return ; } @@ -383,6 +383,8 @@ static void __unfreeze_touch_event(void) static void __hide_complete_cb(void) { + s_info.is_show = false; + __freeze_touch_event(); evas_object_hide(s_info.background_layout); @@ -394,6 +396,8 @@ static void __hide_complete_cb(void) static void __pull_down_complete_cb(void) { + s_info.is_show = true; + evas_object_move(s_info.background_layout, 0, 0); __unfreeze_touch_event(); @@ -417,7 +421,7 @@ static void __down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) static void __background_layout_mouse_move(int cur_x, int cur_y) { if (s_info.is_drawing_up) { - moments_draw(0, cur_y); + moments_move(s_info.down_y, cur_y); return ; } @@ -445,7 +449,7 @@ static void __background_layout_mouse_up(int up_x, int up_y) s_info.is_drawing_up = false; - moments_view_draw_up(0, up_y); + moments_view_put_down(); } @@ -458,6 +462,48 @@ static void __up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) __background_layout_mouse_up(ei->output.x, ei->output.y); } +static void __get_draw_up_view_y(int from_y, int to_y, int * dest_y) +{ + int y = * dest_y; + + if (from_y - to_y <= MOMENT_DRAW_LIMIT) return ; + + int start_y = -WINDOW_H + MOMENTS_INIT_H; + int dy = from_y - to_y - MOMENT_DRAW_LIMIT; + + y = 0 - dy; + if (y <= start_y) y = start_y; + + * dest_y = y; +} + +static void __get_draw_down_view_y(int from_y, int to_y, int * dest_y) +{ + int y = * dest_y; + + int start_y = -WINDOW_H + MOMENTS_INIT_H; + + if (from_y > MOMENTS_INIT_H) return ; + if (to_y <= MOMENTS_INIT_H) return ; + + if (from_y <= MOMENTS_INIT_H) from_y = MOMENTS_INIT_H; + + int dy = to_y - from_y; + + y = start_y + dy; + if (y > 0) y = 0; + + * dest_y = y; +} + +static void __get_dest_y(int from_y, int to_y, int * dest_y) +{ + if (s_info.is_show) + __get_draw_up_view_y(from_y, to_y, dest_y); + else + __get_draw_down_view_y(from_y, to_y, dest_y); +} + #include "test.h" #if TEST_MODE Evas_Object * __t__get_moments_view_layout(void) @@ -484,6 +530,17 @@ void __t__background_layout_mouse_up(int up_x, int up_y) { __background_layout_mouse_up(up_x, up_y); } - +void __t__get_dest_y(int from_y, int to_y, int * dest_y) +{ + __get_dest_y(from_y, to_y, dest_y); +} +void __t__get_draw_up_view_y(int from_y, int to_y, int * dest_y) +{ + __get_draw_up_view_y(from_y, to_y, dest_y); +} +void __t__get_draw_down_view_y(int from_y, int to_y, int * dest_y) +{ + __get_draw_down_view_y(from_y, to_y, dest_y); +} #endif diff --git a/test/feature_test/group_feature_moments_pull_down.c b/test/feature_test/group_feature_moments_pull_down.c index 7d0f6a5..51ade24 100755 --- a/test/feature_test/group_feature_moments_pull_down.c +++ b/test/feature_test/group_feature_moments_pull_down.c @@ -18,6 +18,7 @@ extern void __t__layout_mouse_move(Evas_Object *layout, int cur_x, int cur_y); extern Evas_Object * __t__get_moments_view_layout(void); extern void __t__layout_mouse_up(Evas_Object *layout, int up_x, int up_y); extern void __t__background_layout_mouse_move(int cur_x, int cur_y); +extern void __t__get_dest_y(int from_y, int to_y, int * dest_y); static void __case_touch_down_top(bool * is_passed); static void __case_drag_down(bool * is_passed); @@ -35,9 +36,8 @@ static void __case_moment_view_drag_down(bool *is_passed); #define DRAW_INC 20 -#define CASE_COUNT 29 - static struct { + int mouse_down_y; int last_mouse_x; int last_mouse_y; int current_step; @@ -45,8 +45,9 @@ static struct { Ecore_Timer * delay_timer; unit_group_t * group; int current_case; - void(*case_pool[CASE_COUNT + 1])(bool * is_passed); + void(*case_pool[TEST_CASE_MAX + 1])(bool * is_passed); } s_info = { + .mouse_down_y = 0, .last_mouse_x = 0, .last_mouse_y = 0, .current_step = 0, @@ -70,10 +71,12 @@ static struct { __case_drag_down, __case_check_position, /* x 10 */ __case_touch_up, + __case_for_delay, __case_check_bar_state_full, __case_touch_down_bottom, __case_moment_view_drag_up_short, __case_touch_up, + __case_for_delay, __case_check_bar_state_full, __case_touch_down_bottom, __case_moment_view_drag_up, @@ -83,6 +86,7 @@ static struct { __case_moment_view_drag_up, __case_check_position, /* x 10 */ __case_touch_up, + __case_for_delay, __case_check_bar_state_hide, NULL, }, @@ -106,6 +110,7 @@ static void __case_touch_down_top(bool * is_passed) TEST_ASSERT_TRUE(moments_get_visible() == false); __t__layout_mouse_down(info->layout, start_x, start_y); + s_info.mouse_down_y = start_y; TEST_ASSERT_TRUE(moments_get_visible()); @@ -175,6 +180,9 @@ static void __case_drag_up(bool * is_passed) __t__layout_mouse_move(info->layout, start_x, start_y + (s_info.current_step * DRAW_INC)); + s_info.last_mouse_x = start_x; + s_info.last_mouse_y = start_y + (s_info.current_step * DRAW_INC); + *is_passed = true; } @@ -187,8 +195,9 @@ static void __case_check_position(bool * is_passed) int x = 0, y = 0, w = 0, h = 0; evas_object_geometry_get(layout, &x, &y, &w, &h); - int expected_y = ((-WINDOW_H + MOMENTS_INIT_H) + start_y + (s_info.current_step * DRAW_INC)); - expected_y = expected_y > 0 ? 0 : expected_y; + int expected_y = y; + __t__get_dest_y(s_info.mouse_down_y, s_info.last_mouse_y, &expected_y); + TEST_ASSERT_EQUAL_INT(0, x); TEST_ASSERT_EQUAL_INT(expected_y, y); TEST_ASSERT_EQUAL_INT(WINDOW_W, w); @@ -222,10 +231,10 @@ static void __case_drag_down_short(bool * is_passed) TEST_ASSERT_TRUE(moments_get_visible()); - __t__layout_mouse_move(info->layout, start_x, DRAW_INC); + __t__layout_mouse_move(info->layout, start_x, start_y + DRAW_INC); s_info.last_mouse_x = start_x; - s_info.last_mouse_y = DRAW_INC; + s_info.last_mouse_y = start_y + DRAW_INC; *is_passed = true; } @@ -272,6 +281,7 @@ static void __case_touch_down_bottom(bool *is_passed) __t__background_layout_mouse_down(start_x, WINDOW_H - DRAW_INC); __t__background_layout_mouse_move(start_x, WINDOW_H - DRAW_INC - (MOMENT_DRAW_LIMIT + 1)); + s_info.mouse_down_y = WINDOW_H - DRAW_INC; s_info.last_mouse_x = start_x; s_info.last_mouse_y = WINDOW_H - DRAW_INC - (MOMENT_DRAW_LIMIT + 1); diff --git a/test/feature_test/group_feature_moments_show.c b/test/feature_test/group_feature_moments_show.c index 2ef8a30..1d013f3 100755 --- a/test/feature_test/group_feature_moments_show.c +++ b/test/feature_test/group_feature_moments_show.c @@ -20,14 +20,12 @@ static void __case_check_bar_state_half(bool * is_passed); static void __case_check_bar_state_hide(bool * is_passed); static void __case_touch_down_somewhere(bool * is_passed); -#define CASE_COUNT 13 - static struct { int current_step; Ecore_Timer * group_timer; unit_group_t * group; int current_case; - void(*case_pool[CASE_COUNT + 1])(bool * is_passed); + void(*case_pool[TEST_CASE_MAX + 1])(bool * is_passed); } s_info = { .current_step = 0, .group_timer = NULL, diff --git a/test/feature_test/group_feature_status_area_layer_show.c b/test/feature_test/group_feature_status_area_layer_show.c index 463336c..c76001e 100755 --- a/test/feature_test/group_feature_status_area_layer_show.c +++ b/test/feature_test/group_feature_status_area_layer_show.c @@ -19,14 +19,12 @@ static void __case_touch_up(bool * is_passed); static void __case_check_status_layout_state_show(bool * is_passed); static void __case_check_icon_state_show(bool * is_passed); -#define CASE_COUNT 4 - static struct { int current_step; Ecore_Timer * group_timer; unit_group_t * group; int current_case; - void(*case_pool[CASE_COUNT + 1])(bool * is_passed); + void(*case_pool[TEST_CASE_MAX + 1])(bool * is_passed); } s_info = { .current_step = 0, .group_timer = NULL, diff --git a/test/function_test/function_test.c b/test/function_test/function_test.c new file mode 100755 index 0000000..a1e2989 --- /dev/null +++ b/test/function_test/function_test.c @@ -0,0 +1,50 @@ +#include "test.h" +#if TEST_MODE + +#include "function_test.h" + +#define TEST_GROUP_COUNT 100 + +static struct { + int current_group; + char group_name[TEST_GROUP_COUNT + 1][128]; + void(*group_starter_pool[TEST_GROUP_COUNT + 1])(unit_group_t * group); +} s_info = { + .current_group = 0, + .group_name = { + "group_function_moments_view", + "" + }, + .group_starter_pool = { + group_function_moments_view, + NULL, + }, +}; + +static void __complete_group_cb(void); +static void __run_next_group(void); + +static void __complete_group_cb(void) +{ + s_info.current_group += 1; + + __run_next_group(); +} + +static void __run_next_group(void) +{ + if (s_info.group_starter_pool[s_info.current_group]) { + TEST_GROUP(s_info.group_name[s_info.current_group], s_info.group_starter_pool[s_info.current_group], __complete_group_cb); + } +} + +void function_test(void) +{ + unit_clear_log(); + + s_info.current_group = 0; + __run_next_group(); +} + +#endif + diff --git a/test/function_test/function_test.h b/test/function_test/function_test.h new file mode 100755 index 0000000..82107a8 --- /dev/null +++ b/test/function_test/function_test.h @@ -0,0 +1,14 @@ +#ifndef __FUNCTION_TEST__ +#define __FUNCTION_TEST__ + +#include "test.h" +#if TEST_MODE + +#include "../unit/inc/unit.h" + +void function_test(void); +void group_function_moments_view(unit_group_t * group); + +#endif + +#endif diff --git a/test/function_test/group_function_moments_view.c b/test/function_test/group_function_moments_view.c new file mode 100755 index 0000000..ccd9234 --- /dev/null +++ b/test/function_test/group_function_moments_view.c @@ -0,0 +1,83 @@ +#include "test.h" +#if TEST_MODE + +#include "function_test.h" +#include "common_conf.h" +#include "moments/moments_view_conf.h" + +#include <Elementary.h> + +extern void __t__get_draw_up_view_y(int from_y, int to_y, int * dest_y); +extern void __t__get_draw_down_view_y(int from_y, int to_y, int * dest_y); + +static void __set_up(void){} +static void __tear_down(void){} + +static void __case_check_view_position(bool * is_passed) +{ + int dest_y = 0; + __t__get_draw_up_view_y(0, 0, &dest_y); + TEST_ASSERT_EQUAL_INT(0, dest_y); + + dest_y = 0; + __t__get_draw_up_view_y(180, 180, &dest_y); + TEST_ASSERT_EQUAL_INT(0, dest_y); + + dest_y = 0; + __t__get_draw_up_view_y(100, 90, &dest_y); + TEST_ASSERT_EQUAL_INT(0, dest_y); + + dest_y = 0; + __t__get_draw_up_view_y(100, 89, &dest_y); + TEST_ASSERT_EQUAL_INT(-1, dest_y); + + dest_y = 0; + __t__get_draw_up_view_y(100, 10, &dest_y); + TEST_ASSERT_EQUAL_INT(-80, dest_y); + + dest_y = 0; + __t__get_draw_up_view_y(100, 130, &dest_y); + TEST_ASSERT_EQUAL_INT(0, dest_y); + + int start_y = -WINDOW_H + MOMENTS_INIT_H; + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(100, 100, &dest_y); + TEST_ASSERT_EQUAL_INT(OUTSIDE_Y, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(100, 30, &dest_y); + TEST_ASSERT_EQUAL_INT(OUTSIDE_Y, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(200, 300, &dest_y); + TEST_ASSERT_EQUAL_INT(OUTSIDE_Y, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(100, 111, &dest_y); + TEST_ASSERT_EQUAL_INT(OUTSIDE_Y, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(100, MOMENTS_INIT_H, &dest_y); + TEST_ASSERT_EQUAL_INT(OUTSIDE_Y, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(100, MOMENTS_INIT_H + 1, &dest_y); + TEST_ASSERT_EQUAL_INT(start_y + 1, dest_y); + + dest_y = OUTSIDE_Y; + __t__get_draw_down_view_y(50, MOMENTS_INIT_H + 100, &dest_y); + TEST_ASSERT_EQUAL_INT(start_y + 100, dest_y); + + *is_passed = true; +} + +void group_function_moments_view(unit_group_t * group) +{ + TEST_CASE(group, __case_check_view_position); + + group->finish(group); +} + +#endif + diff --git a/test/test_main.c b/test/test_main.c index 9f9e22c..b93a700 100755 --- a/test/test_main.c +++ b/test/test_main.c @@ -4,6 +4,7 @@ #include "unit/inc/unit.h" #include "home_app_manager.h" #include "feature_test/feature_test.h" +#include "function_test/function_test.h" static struct { Ecore_Timer * feature_test_run_timer; @@ -15,6 +16,8 @@ static Eina_Bool __run_timer_callback(void * data); static bool __create(void * data) { + function_test(); + if (s_info.feature_test_run_timer) { ecore_timer_del(s_info.feature_test_run_timer); s_info.feature_test_run_timer = NULL; diff --git a/test/unit/inc/unit.h b/test/unit/inc/unit.h index 3bc372f..bd17f25 100755 --- a/test/unit/inc/unit.h +++ b/test/unit/inc/unit.h @@ -22,6 +22,8 @@ else unit_result_fail((group)->result); \ } +#define TEST_CASE_MAX 100 + void unit_init(void); void unit_fini(void); void unit_add_group(const char * group_name, void(*group_starter)(unit_group_t * group), void(*group_complete_cb)(void)); |