Add testcase for getting device state by id 14/145314/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 22 Aug 2017 05:24:27 +0000 (14:24 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 22 Aug 2017 05:25:32 +0000 (14:25 +0900)
[Version] 0.4.20
[Issue Type] Testcase

Change-Id: I55f9df7579d3bd1551edcbffb48faae067091c67
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-sound-manager.spec
test/sound_manager_test.c

index 6c00328..d24fdd1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.4.19
+Version:    0.4.20
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 193f758..e00b438 100644 (file)
@@ -58,6 +58,7 @@ enum {
        CURRENT_STATUS_FREE_DEVICE_LIST,
        CURRENT_STATUS_GET_DEVICE_NEXT,
        CURRENT_STATUS_GET_DEVICE_PREV,
+       CURRENT_STATUS_GET_DEVICE_STATE_BY_ID,
        CURRENT_STATUS_SET_DEVICE_CONNECTED_CB,
        CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB,
        CURRENT_STATUS_ADD_DEVICE_CONNECTION_CHANGED_CB,
@@ -148,6 +149,7 @@ void focus_watch_callback(int id, sound_stream_focus_mask_e  focus_mask, sound_s
        g_print("\n*** FOCUS WATCH callback is called, id(%d) ***\n", id);
        g_print(" - changed_focus_mask(%d), changed_focus_state(%d), change_reason(%d), extra_info(%s), user_data(%p)\n",
                        focus_mask, focus_state, reason, extra_info, user_data);
+
        return;
 }
 
@@ -214,6 +216,8 @@ void _interpret_main_menu(char *cmd)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_NEXT;
        else if (strncmp(cmd, "gp", 3) == 0)
                g_menu_state = CURRENT_STATUS_GET_DEVICE_PREV;
+       else if (strncmp(cmd, "gd", 3) == 0)
+               g_menu_state = CURRENT_STATUS_GET_DEVICE_STATE_BY_ID;
        else if (strncmp(cmd, "sd", 3) == 0)
                g_menu_state = CURRENT_STATUS_SET_DEVICE_CONNECTED_CB;
        else if (strncmp(cmd, "ud", 3) == 0)
@@ -350,6 +354,7 @@ void display_sub_basic()
        g_print("fl. Free Devices List\n");
        g_print("gn. Get Next Device\t\t");
        g_print("gp. Get Prev Device\n");
+       g_print("gd. *Get Device State by Id\n");
        g_print("sd. Set Device Connenected CB\t\t");
        g_print("ud. Unset Device Connenected CB\n");
        g_print("si. Set Device Information Changed CB\t");
@@ -461,6 +466,8 @@ static void displaymenu()
                g_print("*** press enter to get next device from the list\n");
        else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_PREV)
                g_print("*** press enter to get previous device from the list\n");
+       else if (g_menu_state == CURRENT_STATUS_GET_DEVICE_STATE_BY_ID)
+               g_print("*** press enter device id to get state\n");
        else if (g_menu_state == CURRENT_STATUS_SET_DEVICE_CONNECTED_CB)
                g_print("*** press enter to set device connected cb\n");
        else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_CONNECTED_CB)
@@ -1144,6 +1151,21 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_GET_DEVICE_STATE_BY_ID: {
+               int ret = SOUND_MANAGER_ERROR_NONE;
+               int device_id;
+               sound_device_state_e state;
+
+               device_id = atoi(cmd);
+
+               if ((ret = sound_manager_get_device_state_by_id(device_id, &state)))
+                       g_print("failed to get device state by id, ret[0x%x]\n", ret);
+               else
+                       g_print("device id[%d], state[%d] (0:deactivated, 1:activated)\n", device_id, state);
+
+               reset_menu_state();
+               break;
+       }
        case CURRENT_STATUS_SET_DEVICE_CONNECTED_CB: {
                if (sound_manager_set_device_connected_cb(g_device_mask, _set_device_connected_cb, NULL))
                        g_print("fail to set device connected cb\n");