[ITC][context][Non-ACR][TNEXT-2012: Fixed TC]
authorSomin Kim <somin926.kim@samsung.com>
Mon, 31 Jul 2017 07:57:09 +0000 (16:57 +0900)
committerJihun Park <jihun87.park@samsung.com>
Tue, 1 Aug 2017 01:21:15 +0000 (01:21 +0000)
- context_history_get_list() can return CONTEXT_HISTORY_ERROR_NO_DATA if there's no suitable data.
Added defense code for NO DATA case, and re-arranged other error cases(NOT_SUPPORTED)
- Removed trailing spaces, tabs

Change-Id: Ib6e703ddc1bf38ac6feb86134debe9defa77dc62
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
src/itc/context/ITs-context-history.c

index 0738796..dafdaeb 100755 (executable)
@@ -77,7 +77,7 @@ void ITs_context_history_cleanup(void)
 * @description                 Creates a context history handle and Releases the resources occupied by a handle
 * @scenario                            Create a context history handle\n
 *                                              Release the resources occupied by a handle
-* @apicovered                  context_history_create, context_history_destroy                                         
+* @apicovered                  context_history_create, context_history_destroy
 * @passcase                            When context_history_create and context_history_destroy are successful and return 0
 * @failcase                            If target API context_history_create or context_history_destroy fails or not return 0
 * @precondition                        context_history_create() for context_history_destroy
@@ -86,7 +86,7 @@ void ITs_context_history_cleanup(void)
 int ITc_context_history_create_destroy_p(void)
 {
        START_TEST;
-       
+
        //Target API
        int nRet = context_history_create(&g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_create", ContextHistoryGetError(nRet));
@@ -94,7 +94,7 @@ int ITc_context_history_create_destroy_p(void)
        //Target API
        nRet = context_history_destroy(g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -109,7 +109,7 @@ int ITc_context_history_create_destroy_p(void)
 * @description                 Creates a history filter and Releases the resources occupied by a filter
 * @scenario                            Create a history filter
 *                                              Release the memory allocated for the for the filter
-* @apicovered                  context_history_filter_create, context_history_filter_destroy                                           
+* @apicovered                  context_history_filter_create, context_history_filter_destroy
 * @passcase                            When context_history_filter_create and context_history_filter_destroy are successful and return 0
 * @failcase                            If target API context_history_filter_create or context_history_filter_destroy fails or return negative value
 * @precondition                        context_history_filter_create for context_history_filter_destroy.
@@ -118,7 +118,7 @@ int ITc_context_history_create_destroy_p(void)
 int ITc_context_history_filter_create_destroy_p(void)
 {
        START_TEST;
-       
+
        //Target API
        int nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet));
@@ -126,11 +126,11 @@ int ITc_context_history_filter_create_destroy_p(void)
        //Target API
        nRet = context_history_filter_destroy(g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
-//& purpose: Sets an integer value to a filter 
+//& purpose: Sets an integer value to a filter
 //& type: auto
 /**
 * @testcase                    ITc_context_history_filter_set_int_p
@@ -140,7 +140,7 @@ int ITc_context_history_filter_create_destroy_p(void)
 * @type                                auto
 * @description                 This sets the integer value to a filter
 * @scenario                            Set an integer value to a filter
-* @apicovered                  context_history_filter_set_int                                  
+* @apicovered                  context_history_filter_set_int
 * @passcase                            When context_history_filter_set_int are execute successful and return 0
 * @failcase                            If target API context_history_filter_set_int are return negative number
 * @precondition                        context_history_filter_create must be create.
@@ -149,17 +149,17 @@ int ITc_context_history_filter_create_destroy_p(void)
 int ITc_context_history_filter_set_int_p(void)
 {
        START_TEST;
-       
+
        int nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet));
-       
+
        //Target API
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE,10);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter));
-       
+
        nRet = context_history_filter_destroy(g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -182,17 +182,17 @@ int ITc_context_history_filter_set_int_p(void)
 int ITc_context_history_filter_set_string_p(void)
 {
        START_TEST;
-       
+
        int nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet));
-       
+
        //Target API
        nRet = context_history_filter_set_string(g_filter, CONTEXT_HISTORY_FILTER_APP_ID, TEST_TESTAPPLICATION_APPID);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_string", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter));
 
        nRet = context_history_filter_destroy(g_filter);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -216,23 +216,23 @@ int ITc_context_history_filter_set_string_p(void)
 int ITc_context_history_get_list_destroy_p(void)
 {
        START_TEST;
-       
+
        int nRet = context_history_create(&g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_create", ContextHistoryGetError(nRet));
 
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_TIME_SPAN,INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE,INT_VAL2);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
+
        //Target API
        nRet = context_history_get_list(g_Handle, CONTEXT_HISTORY_RARELY_USED_APP, g_filter, &g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-       
+
        //Target API
        nRet = context_history_list_destroy(g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_destroy", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
@@ -242,7 +242,7 @@ int ITc_context_history_get_list_destroy_p(void)
 
        nRet = context_history_destroy(g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -265,7 +265,7 @@ int ITc_context_history_get_list_destroy_p(void)
 int ITc_context_history_list_get_count_p(void)
 {
        START_TEST;
-       
+
        int nListCount;
 
        int nRet = context_history_create(&g_Handle);
@@ -273,20 +273,20 @@ int ITc_context_history_list_get_count_p(void)
 
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_TIME_SPAN,INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, INT_VAL2);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
+
        nRet = context_history_get_list(g_Handle, CONTEXT_HISTORY_RARELY_USED_APP, g_filter, &g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        //Target API
        nRet = context_history_list_get_count(g_history_list, &nListCount);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_get_count", ContextHistoryGetError(nRet), context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-       
+
        nRet = context_history_list_destroy(g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_destroy", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
@@ -295,7 +295,7 @@ int ITc_context_history_list_get_count_p(void)
 
        nRet = context_history_destroy(g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -326,23 +326,23 @@ int ITc_context_history_list_get_current_p(void)
 
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, INT_VAL2);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
+
        nRet = context_history_get_list(g_Handle, CONTEXT_HISTORY_RARELY_USED_APP, g_filter, &g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        //Target API
        nRet = context_history_list_get_current(g_history_list, &g_history_record);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_get_current", ContextHistoryGetError(nRet), context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-       
+
        nRet = context_history_record_destroy(g_history_record);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_record_destroy", ContextHistoryGetError(nRet), context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-       
+
        nRet = context_history_list_destroy(g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_destroy", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
@@ -425,22 +425,22 @@ int ITc_context_history_list_move_first_p(void)
 int ITc_context_history_list_move_next_p(void)
 {
        START_TEST;
-       
+
        int nRet = context_history_create(&g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_create", ContextHistoryGetError(nRet));
 
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, INT_VAL2);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
+
        nRet = context_history_get_list(g_Handle, CONTEXT_HISTORY_RARELY_USED_APP, g_filter, &g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-       
+
        //Target API
        nRet = context_history_list_move_next(g_history_list);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_move_next", ContextHistoryGetError(nRet), context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
@@ -453,7 +453,7 @@ int ITc_context_history_list_move_next_p(void)
 
        nRet = context_history_destroy(g_Handle);
        PRINT_RESULT(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_destroy", ContextHistoryGetError(nRet));
-       
+
        return 0;
 }
 
@@ -559,24 +559,24 @@ int ITc_context_history_record_get_double_p(void)
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
        CHECK_HANDLE_CLEANUP(g_filter,"context_history_filter_create",context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_TIME_SPAN, INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
+
        nRet = context_history_get_list(g_Handle, CONTEXT_HISTORY_BATTERY_USAGE, g_filter, &g_history_list);
-       if (nRet == CONTEXT_HISTORY_ERROR_NO_DATA) 
+       if (nRet == CONTEXT_HISTORY_ERROR_NO_DATA)
        {
                FPRINTF("[Line : %d][%s] Skip context_history_get_list() for CONTEXT_HISTORY_BATTERY_USAGE. Data not exist.\\n", __LINE__, API_NAMESPACE);
-       } 
+       }
        else
        {
                PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
                CHECK_HANDLE_CLEANUP(g_history_list,"context_history_get_list",context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-               
+
                nRet = context_history_list_get_current(g_history_list, &g_history_record);
                PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_list_get_current", ContextHistoryGetError(nRet), context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
                CHECK_HANDLE_CLEANUP(g_history_record,"context_history_list_get_current",context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
-               
+
                //Target API
                nRet = context_history_record_get_double(g_history_record, CONTEXT_HISTORY_TOTAL_AMOUNT, &nValue);
                PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_record_get_double", ContextHistoryGetError(nRet), context_history_record_destroy(g_history_record);context_history_list_destroy(g_history_list);context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
@@ -619,7 +619,7 @@ int ITc_context_history_get_list_p(void)
        START_TEST;
 
        context_history_data_e eContextHistory[]={
-                                                       CONTEXT_HISTORY_RECENTLY_USED_APP, 
+                                                       CONTEXT_HISTORY_RECENTLY_USED_APP,
                                                        CONTEXT_HISTORY_FREQUENTLY_USED_APP,
                                                        CONTEXT_HISTORY_BATTERY_USAGE,
                                                        CONTEXT_HISTORY_RECENT_BATTERY_USAGE
@@ -634,30 +634,30 @@ int ITc_context_history_get_list_p(void)
        nRet = context_history_filter_create(&g_filter);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_create", ContextHistoryGetError(nRet), context_history_destroy(g_Handle));
        CHECK_HANDLE_CLEANUP(g_filter,"context_history_filter_create",context_history_destroy(g_Handle));
-       
+
        nRet = context_history_filter_set_int(g_filter, CONTEXT_HISTORY_FILTER_RESULT_SIZE, INT_VAL1);
        PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_filter_set_int", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
 
        for(int nLoopEnumCount = 0; nLoopEnumCount < nEnumLength; nLoopEnumCount++)
        {
-               
                nRet = context_history_get_list(g_Handle, eContextHistory[nLoopEnumCount], g_filter, &g_history_list);
-               if(eContextHistory[nLoopEnumCount] == CONTEXT_HISTORY_BATTERY_USAGE || eContextHistory[nLoopEnumCount] == CONTEXT_HISTORY_RECENT_BATTERY_USAGE)
+               if (nRet == CONTEXT_HISTORY_ERROR_NO_DATA)
                {
-                       if(!bFeatureIsSupported)
+                       FPRINTF("[Line : %d][%s] Skip context_history_get_list() for %s. Data not exist.\\n", __LINE__, API_NAMESPACE,ContextHistoryGetHistoryData(eContextHistory[nLoopEnumCount]));
+                       continue;
+               }
+               else if (nRet == CONTEXT_HISTORY_ERROR_NOT_SUPPORTED)
+               {
+                       if(eContextHistory[nLoopEnumCount] == CONTEXT_HISTORY_BATTERY_USAGE || eContextHistory[nLoopEnumCount] == CONTEXT_HISTORY_RECENT_BATTERY_USAGE)
                        {
-                               if(nRet == CONTEXT_HISTORY_ERROR_NOT_SUPPORTED)
+                               if(!bFeatureIsSupported)
                                {
                                        FPRINTF("[Line : %d][%s] Feature Not Supported for api context_history_get_list\\n", __LINE__, API_NAMESPACE);
-                                       return 0;
-                               }
-                               else
-                               {
-                                       FPRINTF("[Line : %d][%s] Feature Mismatch for api context_history_get_list\\n", __LINE__, API_NAMESPACE);
-                                       return 1;
+                                       continue;
                                }
                        }
                }
+
                PRINT_RESULT_CLEANUP(CONTEXT_HISTORY_ERROR_NONE, nRet, "context_history_get_list", ContextHistoryGetError(nRet), context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
                CHECK_HANDLE_CLEANUP(g_history_list,"context_history_get_list",context_history_filter_destroy(g_filter);context_history_destroy(g_Handle));
                context_history_list_destroy(g_history_list);
@@ -689,7 +689,7 @@ int ITc_context_history_is_supported_p(void)
        START_TEST;
 
        context_history_data_e eContextHistory[]={
-                                                       CONTEXT_HISTORY_RECENTLY_USED_APP, 
+                                                       CONTEXT_HISTORY_RECENTLY_USED_APP,
                                                        CONTEXT_HISTORY_FREQUENTLY_USED_APP,
                                                        CONTEXT_HISTORY_BATTERY_USAGE,
                                                        CONTEXT_HISTORY_RECENT_BATTERY_USAGE