summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjin0.kim <jin0.kim@samsung.com>2017-05-19 18:51:59 +0830
committerjin0.kim <jin0.kim@samsung.com>2017-05-19 18:51:59 +0830
commit878f7c95c3fc5cd9bd6df815ca7e96f057457eac (patch)
tree9a2329b12cedc4a55b7f1c8b26b2c8d2cd7acf43
parentb1148cba2759e90a7c26074d5fa7137dc71cf064 (diff)
downloadw3-home-878f7c95c3fc5cd9bd6df815ca7e96f057457eac.tar.gz
w3-home-878f7c95c3fc5cd9bd6df815ca7e96f057457eac.tar.bz2
w3-home-878f7c95c3fc5cd9bd6df815ca7e96f057457eac.zip
Added functional test related to the coordinates of the control buttons
Change-Id: Ie1575ada012da4e91b4f7f389cd280c71b7c1ec0
-rwxr-xr-xinc/moments/moments_control_view.h2
-rwxr-xr-xinc/moments/moments_view_conf.h1
-rwxr-xr-xsrc/moments/moments_control_view.c28
-rwxr-xr-xtest/feature_test/group_feature_moments_controls_view.c2
-rwxr-xr-xtest/function_test/group_function_moments_view.c32
5 files changed, 58 insertions, 7 deletions
diff --git a/inc/moments/moments_control_view.h b/inc/moments/moments_control_view.h
index 6ea7ba9..7f45fcc 100755
--- a/inc/moments/moments_control_view.h
+++ b/inc/moments/moments_control_view.h
@@ -55,7 +55,7 @@ control_info_t *moments_control_create_button(Evas_Object *base_layout, int butt
void moments_control_push_to_button_list(control_info_t *button_info);
void moments_control_destroy_button(control_info_t *button_info);
void moments_control_update(void);
-position_t *moments_control_get_button_position(int index, int total_count);
+position_t *moments_control_get_button_position(int total_count, int index);
void moments_control_clear_button_list(void);
diff --git a/inc/moments/moments_view_conf.h b/inc/moments/moments_view_conf.h
index 150cfa9..eee27ef 100755
--- a/inc/moments/moments_view_conf.h
+++ b/inc/moments/moments_view_conf.h
@@ -50,6 +50,7 @@
#define MOMENTS_BUTTON_W (int)((64) * (SCALE_W))
#define MOMENTS_BUTTON_H (int)((64) * (SCALE_H))
+#define MOMENTS_BUTTON_MARGIN (int)((7) * (SCALE_H))
#define MOMENTS_BUTTON_1_X (int)((148) * (SCALE_W))
#define MOMENTS_BUTTON_1_Y (int)((289) * (SCALE_H))
diff --git a/src/moments/moments_control_view.c b/src/moments/moments_control_view.c
index 16d5a1e..9ad8948 100755
--- a/src/moments/moments_control_view.c
+++ b/src/moments/moments_control_view.c
@@ -178,13 +178,31 @@ void moments_control_clear_button_list(void)
s_info.button_list = NULL;
}
-position_t temp_pos[6] = {{148, 289}, {223, 268}, {73, 268}, {274, 211}, {22, 211}, {0, 0}};
+void __moments_control_get_coordinates(int radius, double angle, int *x, int *y)
+{
+ *x = radius * sin(angle * 3.141592 / 180);
+ *y = radius * cos(angle * 3.141592 / 180);
+
+ *x = *x + WINDOW_CENTER_X;
+ *y = WINDOW_CENTER_Y - *y;
+}
-position_t *moments_control_get_button_position(int index, int total_count)
+position_t *moments_control_get_button_position(int total_count, int index)
{
- static position_t pos = {148, 289};
+ static position_t pos = {0, 0};
+
+ int max_button_cnt = (total_count % 2 == 1 ? 5 : 6);
+
+ int button_idx = index + (max_button_cnt - total_count) / 2;
+
+ int default_angle = 360 / (max_button_cnt * 2);
+
+ int converted_angle = (default_angle * button_idx + 90) + (default_angle / 2);
+
+ __moments_control_get_coordinates(WINDOW_CENTER_X - MOMENTS_BUTTON_W/2 - MOMENTS_BUTTON_MARGIN, converted_angle, &pos.x, &pos.y);
- pos = temp_pos[index];
+ pos.x -= MOMENTS_BUTTON_W/2;
+ pos.y -= MOMENTS_BUTTON_H/2;
return &pos;
}
@@ -199,7 +217,7 @@ void moments_control_update(void)
int index = 0;
EINA_LIST_FOREACH(s_info.button_list, l, button) {
- position_t *pos = moments_control_get_button_position(index, count);
+ position_t *pos = moments_control_get_button_position(count, index);
elm_grid_pack(s_info.control_layout, button->button_layout, pos->x * (SCALE_W), pos->y * (SCALE_H), MOMENTS_BUTTON_W, MOMENTS_BUTTON_H);
index++;
}
diff --git a/test/feature_test/group_feature_moments_controls_view.c b/test/feature_test/group_feature_moments_controls_view.c
index b5ddce7..54d233c 100755
--- a/test/feature_test/group_feature_moments_controls_view.c
+++ b/test/feature_test/group_feature_moments_controls_view.c
@@ -74,7 +74,7 @@ static unit_case_func_t __continue_check_control_button(void * data)
evas_object_geometry_get(button->button_layout, &x, &y, &w, &h);
int total = eina_list_count(button_list);
- position_t *pos = moments_control_get_button_position(i, total);
+ position_t *pos = moments_control_get_button_position(total, i);
TEST_ASSERT_EQUAL_INT_UPGRADE(pos->x, x);
TEST_ASSERT_EQUAL_INT_UPGRADE(pos->y, y);
diff --git a/test/function_test/group_function_moments_view.c b/test/function_test/group_function_moments_view.c
index 18a9db1..e62e76d 100755
--- a/test/function_test/group_function_moments_view.c
+++ b/test/function_test/group_function_moments_view.c
@@ -21,6 +21,14 @@ static struct {
.group = NULL,
};
+position_t icon_position[7][7] = { {{0,0}},
+ {{148, 288}},
+ {{184, 284}, {112, 284}},
+ {{230, 262}, {148, 288}, {66, 262}},
+ {{247, 247}, {184, 284}, {112, 284}, {49, 247}},
+ {{282, 191}, {230, 262}, {148, 288}, {66, 262}, {14, 191}},
+ {{284, 184}, {247, 247}, {184, 284}, {112, 284}, {49, 247}, {12, 184}} };
+
static void __set_up(void)
{
@@ -169,6 +177,22 @@ static unit_case_func_t __case_control_button_create(void * data)
TEST_CASE_DONE(s_info.group);
}
+static unit_case_func_t __case_check_control_button_position(void * data)
+{
+
+ int total_count = (int)data;
+ int button_index = 0;
+
+ for (button_index = 0; button_index < total_count; button_index++) {
+ position_t *pos = moments_control_get_button_position(total_count, button_index);
+
+ TEST_ASSERT_EQUAL_INT_UPGRADE(icon_position[total_count][button_index].x, pos->x);
+ TEST_ASSERT_EQUAL_INT_UPGRADE(icon_position[total_count][button_index].y, pos->y);
+ }
+
+ TEST_CASE_DONE(s_info.group);
+}
+
void group_function_moments_view(unit_group_t * group)
{
s_info.group = group;
@@ -177,6 +201,7 @@ void group_function_moments_view(unit_group_t * group)
TEST_CASE_ADD(group, __case_check_view_position, NULL);
TEST_CASE_ADD(group, __case_control_layout_alpha, NULL);
+
TEST_CASE_ADD(group, __case_control_button_create, (void*)0);
TEST_CASE_ADD(group, __case_control_button_create, (void*)1);
TEST_CASE_ADD(group, __case_control_button_create, (void*)2);
@@ -184,6 +209,13 @@ void group_function_moments_view(unit_group_t * group)
TEST_CASE_ADD(group, __case_control_button_create, (void*)4);
TEST_CASE_ADD(group, __case_control_button_create, (void*)5);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)1);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)2);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)3);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)4);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)5);
+ TEST_CASE_ADD(group, __case_check_control_button_position, (void*)6);
+
TEST_GROUP_RUN(s_info.group);
}