Add TEST_CODE for HEADSET 84/131584/1
authorjunkyu han <junkyu.han@samsung.com>
Tue, 30 May 2017 06:09:02 +0000 (15:09 +0900)
committerjunkyu han <junkyu.han@samsung.com>
Tue, 30 May 2017 06:09:02 +0000 (15:09 +0900)
Change-Id: Ib0630929a299b9575a28ec3d5a4e224ed09eecd3

inc/moments/moments_status_view.h
inc/moments/moments_view_edje_conf.h
res/edje/circle/moments_status_headset.edc [new file with mode: 0644]
res/edje/images/Headset/headset_on.png [new file with mode: 0644]
src/moments/moments_manager.c
src/moments/moments_status_view.c
test/feature_test/group_feature_moments_status_view_ui.c
test/test_function.h

index 57f66b0e1c27bad3f809057dbe68c0ab3b826b58..cc2b97e82fb19b0499e72da400d839ab67701012 100644 (file)
@@ -52,6 +52,9 @@ void moments_status_location_icon_hide(void);
 void moments_status_bluetooth_icon_show(void);
 void moments_status_bluetooth_icon_hide(void);
 
+void moments_status_headset_icon_show(void);
+void moments_status_headset_icon_hide(void);
+
 void moments_status_battery_update(int percent, int converted_percent, bool is_charging);
 void moments_status_callsignal_update(int strength, bool is_roaming);
 void moments_status_network_update(int network_type, int packet_type);
index 49da1db9885bd66f232caf2a717381ea5a09ee03..27c3443f9a3f10f58825db03f47c258f8a43ec31 100755 (executable)
@@ -25,6 +25,7 @@
 #define STATUS_SIMCARD_LAYOUT "status_simcard_layout"
 #define STATUS_LOCATION_LAYOUT "status_location_layout"
 #define STATUS_BLUETOOTH_LAYOUT "status_bluetooth_layout"
+#define STATUS_HEADSET_LAYOUT "status_headset_layout"
 #define SIZE_SETTER "size_setter"
 #define MOMENTS_BG "moments_bg"
 #define MOMENTS_CONTENT "moments_content"
diff --git a/res/edje/circle/moments_status_headset.edc b/res/edje/circle/moments_status_headset.edc
new file mode 100644 (file)
index 0000000..24f4c04
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../../../inc/moments/moments_view_edje_conf.h"
+
+#define HEADSET_DIR_PREFIX "Headset"
+
+collections {
+   group { STATUS_HEADSET_LAYOUT;
+      images {
+         image: HEADSET_DIR_PREFIX"/headset_on.png" COMP;
+      }
+      parts {
+         part {
+            name: "icon_image";
+            type: IMAGE;
+            description {
+                state: "default" 0.0;
+                align: 0.5 0.5;
+                rel1 { relative: 0.0 0.0; }
+                rel2 { relative: 1.0 1.0; }
+                image.normal: HEADSET_DIR_PREFIX"/headset_on.png";
+                color: 250 250 250 255;
+            }
+                }
+      }
+   }
+}
+
+
diff --git a/res/edje/images/Headset/headset_on.png b/res/edje/images/Headset/headset_on.png
new file mode 100644 (file)
index 0000000..22313f8
Binary files /dev/null and b/res/edje/images/Headset/headset_on.png differ
index ad9f68bf650f35f40d42660c6be10d18d421ba56..026533b28e7338055f198adbdd04da2dd4c7ac20 100755 (executable)
@@ -62,6 +62,7 @@ static void __wifi_state_changed_cb(keynode_t *node, void *user_data);
 static void __simcard_state_changed_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data);
 static void __location_service_state_changed_cb(runtime_info_key_e key, void *data);
 static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data);
+static void __headset_state_changed_cb(keynode_t *node, void *user_data);
 static void __get_callsignal_state(bool *is_roaming, int *strength);
 static void __get_network_strength_and_packet_type(int *network_type, int *packet_type);
 static void __get_wifi_strength_and_packet_type(int *strength, int *packet_type);
@@ -179,6 +180,7 @@ static void __initialize_status_view(void)
                __location_service_state_changed_cb(0, NULL);
        }
        __bluetooth_state_changed_cb(NULL, NULL);
+       __headset_state_changed_cb(NULL, NULL);
 
        s_info.on_initialization = false;
 }
@@ -245,6 +247,8 @@ static void __register_status_callback(void)
        /* BLUETOOTH */
        vconf_notify_key_changed(VCONFKEY_BT_STATUS, __bluetooth_state_changed_cb, NULL);
        vconf_notify_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb, NULL);
+       /* HEADSET */
+       vconf_notify_key_changed(VCONFKEY_BT_DEVICE, __headset_state_changed_cb, NULL);
 }
 
 static void __unregister_status_callback(void)
@@ -302,6 +306,8 @@ static void __unregister_status_callback(void)
 
        vconf_ignore_key_changed(VCONFKEY_BT_STATUS, __bluetooth_state_changed_cb);
        vconf_ignore_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb);
+
+       vconf_ignore_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __headset_state_changed_cb);
 }
 
 static void __battery_state_changed_cb(device_callback_e type, void *value, void *user_data)
@@ -416,12 +422,45 @@ static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data)
                        _E("Failed to get vconkey for BLUETOOTH CONNECTED");
                        return;
                }
+       } else {
+               // Disconnect HEADSET
        }
 
        moments_status_bluetooth_update(on_off, connected);
        moments_status_update_view();
 }
 
+static void __headset_state_changed_cb(keynode_t *node, void *user_data)
+{
+       _D("Headset State is changed");
+       int is_bt_on = 0;
+
+       if (vconf_get_int(VCONFKEY_BT_STATUS, &is_bt_on) < 0) {
+               _E("Failed to get vconfkey for bluetooth state");
+               return;
+       }
+
+       if (is_bt_on) {
+               int is_device_connected = 0;
+               if (vconf_get_int(VCONFKEY_BT_DEVICE, &is_device_connected) < 0) {
+                       _E("Failed to get bt is connected with device");
+                       return;
+               }
+
+               if (is_device_connected == VCONFKEY_BT_DEVICE_HEADSET_CONNECTED ||
+                               is_device_connected == VCONFKEY_BT_DEVICE_A2DP_HEADSET_CONNECTED) {
+                       _D("Headset is connected");
+                       moments_status_headset_icon_show();
+               } else {
+                       moments_status_headset_icon_hide();
+               }
+       } else {
+               moments_status_headset_icon_hide();
+       }
+
+       moments_status_update_view();
+}
+
 static void __network_type_changed_cb(keynode_t *node, void *user_data)
 {
        __call_network_service_state_changed_cb(NULL, 0, NULL, NULL);
@@ -583,6 +622,11 @@ void __t__moments_restore_status_bluetooth_state(void)
        __bluetooth_state_changed_cb(NULL, NULL);
 }
 
+void __t__moments_restore_status_headset_state(void)
+{
+       __headset_state_changed_cb(NULL, NULL);
+}
+
 void __t__moments_manager_update_status_view(int is_flight, int service_state, int wifi_state)
 {
        __update_status_view_by_call_network_changed(is_flight, service_state, wifi_state);
index 75422dd9f8278b3efbc8cca2fda14dee9a480eee..ec25b337a4af659c625d59883d9dfd15cad82477 100644 (file)
@@ -40,6 +40,7 @@
 #define STATUS_SIMCARD_EDJE EDJE_DIR"/circle/moments_status_simcard.edj"
 #define STATUS_LOCATION_EDJE EDJE_DIR"/circle/moments_status_location.edj"
 #define STATUS_BLUETOOTH_EDJE EDJE_DIR"/circle/moments_status_bluetooth.edj"
+#define STATUS_HEADSET_EDJE EDJE_DIR"/circle/moments_status_headset.edj"
 
 static struct __status_view_s {
        Evas_Object *status_layout;
@@ -50,6 +51,7 @@ static struct __status_view_s {
        Evas_Object *status_simcard;
        Evas_Object *status_location;
        Evas_Object *status_bluetooth;
+       Evas_Object *status_headset;
 } s_info = {
        .status_layout = NULL,
        .status_grid = NULL,
@@ -59,6 +61,7 @@ static struct __status_view_s {
        .status_simcard = NULL,
        .status_location = NULL,
        .status_bluetooth = NULL,
+       .status_headset = NULL,
 };
 
 static status_icon_type_e __status_icon_priority_bt[STATUS_ICON_MAX_COUNT_BT] = {
@@ -120,6 +123,7 @@ static Evas_Object *__create_network(Evas_Object *parent);
 static Evas_Object *__create_simcard(Evas_Object *parent);
 static Evas_Object *__create_location(Evas_Object *parent);
 static Evas_Object *__create_bluetooth(Evas_Object *parent);
+static Evas_Object *__create_headset(Evas_Object *parent);
 
 Evas_Object *moments_status_view_create(Evas_Object *parent)
 {
@@ -331,6 +335,28 @@ void moments_status_bluetooth_update(int on_off, int connected)
        }
 }
 
+void moments_status_headset_icon_show(void)
+{
+       if (s_info.status_headset) moments_status_headset_icon_hide();
+
+       s_info.status_headset = __create_headset(s_info.status_layout);
+
+       __status_icon_list[STATUS_ICON_HEADSET] = s_info.status_headset;
+       __status_icon_is_appended[STATUS_ICON_HEADSET] = true;
+
+       __register_icon_type_to_list(STATUS_ICON_HEADSET);
+}
+
+void moments_status_headset_icon_hide(void)
+{
+       __unregister_icon_type_from_list(STATUS_ICON_HEADSET);
+       __status_icon_is_appended[STATUS_ICON_HEADSET] = false;
+
+       if (s_info.status_headset) evas_object_del(s_info.status_headset);
+       s_info.status_headset = NULL;
+       __status_icon_list[STATUS_ICON_HEADSET] = NULL;
+}
+
 void moments_status_update_view(void)
 {
        _D("Update status icon list");
@@ -547,7 +573,7 @@ static Evas_Object *__create_bluetooth(Evas_Object *parent)
 {
        Evas_Object *bluetooth = elm_layout_add(parent);
        if (!bluetooth || !elm_layout_file_set(bluetooth, util_get_res_file_path(STATUS_BLUETOOTH_EDJE), STATUS_BLUETOOTH_LAYOUT)) {
-               _E("Failed to create location layout");
+               _E("Failed to create bluetooth layout");
                return NULL;
        }
        evas_object_size_hint_min_set(bluetooth, MOMENTS_STATUS_ICON_W, MOMENTS_STATUS_ICON_H);
@@ -559,6 +585,22 @@ static Evas_Object *__create_bluetooth(Evas_Object *parent)
        return bluetooth;
 }
 
+static Evas_Object *__create_headset(Evas_Object *parent)
+{
+       Evas_Object *headset = elm_layout_add(parent);
+       if (!headset || !elm_layout_file_set(headset, util_get_res_file_path(STATUS_HEADSET_EDJE), STATUS_HEADSET_LAYOUT)) {
+               _E("Failed to create headset layout");
+               return NULL;
+       }
+       evas_object_size_hint_min_set(headset, MOMENTS_STATUS_ICON_W, MOMENTS_STATUS_ICON_H);
+       evas_object_size_hint_align_set(headset, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_size_hint_weight_set(headset, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_move(headset, OUTSIDE_X, OUTSIDE_Y);
+       evas_object_show(headset);
+
+       return headset;
+}
+
 static int __get_icon_position_index(status_icon_type_e type)
 {
        Eina_List *list = NULL;
@@ -615,6 +657,11 @@ Evas_Object *__t__get_moments_status_bluetooth(void)
        return s_info.status_bluetooth;
 }
 
+Evas_Object *__t__get_moments_status_headset(void)
+{
+       return s_info.status_headset;
+}
+
 int __t__get_moments_status_icon_index(int type)
 {
        return __get_icon_position_index(type);
index c42a2d000a29d0590b0c61f8584888f3977d59c4..28d7f8886ae72753413b7a8b047e6bf6c0f44c5f 100755 (executable)
@@ -23,6 +23,7 @@ static unit_case_func_t __case_check_status_view_network(void *data);
 static unit_case_func_t __case_check_status_view_simcard(void *data);
 static unit_case_func_t __case_check_status_view_location(void *data);
 static unit_case_func_t __case_check_status_view_bluetooth(void *data);
+static unit_case_func_t __case_check_status_view_headset(void *data);
 
 static void __status_restore_icons(void);
 
@@ -429,6 +430,41 @@ static unit_case_func_t __continue_check_status_bluetooth_icon_change(void *data
        TEST_CASE_DONE(s_info.group);
 }
 
+static unit_case_func_t __continue_check_status_headset_icon_change(void *data);
+static unit_case_func_t __case_check_status_view_headset(void *data)
+{
+       Evas_Object *headset = __t__get_moments_status_headset();
+       if (!headset) {
+               moments_status_headset_icon_show();
+               moments_status_update_view();
+               TEST_CASE_CONTINUE(0.3, __case_check_status_view_headset, NULL);
+       }
+
+       TEST_ASSERT_TRUE_UPGRADE(evas_object_visible_get(headset));
+
+       int index = __t__get_moments_status_icon_index(STATUS_ICON_HEADSET);
+       TEST_ASSERT_TRUE_UPGRADE(index >= 0);
+
+       int x, y, w, h;
+       evas_object_geometry_get(headset, &x, &y, &w, &h);
+       TEST_ASSERT_EQUAL_INT_UPGRADE(__t_status_icon_position[index][0], x);
+       TEST_ASSERT_EQUAL_INT_UPGRADE(__t_status_icon_position[index][1], y);
+       TEST_ASSERT_EQUAL_INT_UPGRADE(MOMENTS_STATUS_ICON_W, w);
+       TEST_ASSERT_EQUAL_INT_UPGRADE(MOMENTS_STATUS_ICON_H, h);
+
+       moments_status_update_view();
+
+       TEST_CASE_CONTINUE(0.3, __continue_check_status_headset_icon_change, headset);
+}
+
+static unit_case_func_t __continue_check_status_headset_icon_change(void *data)
+{
+       double val = 0.0;
+       Evas_Object *headset = (Evas_Object *)data;
+
+       TEST_CASE_DONE(s_info.group);
+}
+
 void group_feature_moments_status_view_ui(unit_group_t * group)
 {
        s_info.group = group;
@@ -442,6 +478,7 @@ void group_feature_moments_status_view_ui(unit_group_t * group)
        TEST_CASE_ADD(s_info.group, __case_check_status_view_simcard, NULL);
        TEST_CASE_ADD(s_info.group, __case_check_status_view_location, NULL);
        TEST_CASE_ADD(s_info.group, __case_check_status_view_bluetooth, NULL);
+       TEST_CASE_ADD(s_info.group, __case_check_status_view_headset, NULL);
        TEST_GROUP_TEAR_DOWN(s_info.group, __group_tear_down);
 
        TEST_GROUP_RUN(s_info.group);
@@ -465,6 +502,7 @@ static void __status_restore_icons(void)
                __t__moments_restore_status_call_network_service_state();
        }
        __t__moments_restore_status_bluetooth_state();
+       __t__moments_restore_status_headset_state();
 }
 
 #endif
index 74b7b168a6470e3d7a7392ecf36e5b0f10e70086..fb19bf81bca5772f046e9c2dba60ae1e93cff83a 100755 (executable)
@@ -47,9 +47,11 @@ extern Evas_Object *__t__get_moments_status_simcard(void);
 extern Evas_Object *__t__get_moments_status_location(void);
 extern Evas_Object *__t__get_moments_status_location(void);
 extern Evas_Object *__t__get_moments_status_bluetooth(void);
+extern Evas_Object *__t__get_moments_status_headset(void);
 extern void __t__moments_restore_status_battery(void);
 extern void __t__moments_restore_status_call_network_service_state(void);
 extern void __t__moments_restore_status_bluetooth_state(void);
+extern void __t__moments_restore_status_headset_state(void);
 extern void __t__moments_flight_mode_just_turned_on_off(int turn_on);
 extern void __t__moments_manager_update_status_view(int is_flight, int service_state, int wifi_state);
 extern int __t__get_moments_status_icon_index(int type);