Added double type test cases for context history 00/124200/3
authorSomin Kim <somin926.kim@samsung.com>
Mon, 10 Apr 2017 12:46:05 +0000 (21:46 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Tue, 11 Apr 2017 02:31:56 +0000 (19:31 -0700)
Change-Id: I5803cfee70c83b76f2f9427aa4b19780786fe7f3
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
testsuite/src/history/history.cpp
testsuite/src/history/history.h
testsuite/src/shared.cpp
testsuite/src/shared.h

index 41184f2..5738baa 100644 (file)
@@ -56,6 +56,7 @@ int test_history(int *argc, char ***argv)
                g_print("   5. Peak Time for Music         6. Peak Time for Video\n");
                g_print("   7. Common Setting for App      8. Common Setting for Music\n");
                g_print("   9. Common Setting for Video   10. Frequently Communicated Address\n");
+               g_print("  11. Battery Usage              12. Recent Battery Usage\n");
 
                while (!get_input_int("(to exit, ctrl-c)? ")) {;}
 
@@ -90,6 +91,12 @@ int test_history(int *argc, char ***argv)
                case 10:
                        run_testcase("/history/frequently_communicated_address", _history_comm_frequently);
                        break;
+               case 11:
+                       run_testcase("/history/battery_usage", _history_battery);
+                       break;
+               case 12:
+                       run_testcase("/history/recent_battery_usage", _history_battery_recent);
+                       break;
                default:
                        g_print("Invalid number\n");
                        break;
@@ -144,7 +151,7 @@ static bool __get_list(context_history_data_e type)
        return true;
 }
 
-static bool __iterate_list(const char *int_attr[], const char *str_attr[])
+static bool __iterate_list(const char *int_attr[], const char *double_attr[], const char *str_attr[])
 {
        int cnt = 0;
        err = context_history_list_get_count(list_h, &cnt);
@@ -162,6 +169,13 @@ static bool __iterate_list(const char *int_attr[], const char *str_attr[])
                        g_print("%s(%d) ", int_attr[j], int_val);
                }
 
+               /* Double attributes */
+               for (int j = 0; double_attr[j] != NULL; ++j) {
+                       err = context_history_record_get_double(record_h, double_attr[j], &double_val);
+                       ASSERT_CMPINT(err, ==, ERR_NONE);
+                       g_print("%s(%f) ", double_attr[j], double_val);
+               }
+
                /* String attributes */
                for (int j = 0; str_attr[j] != NULL; ++j) {
                        char *tmp = NULL;
@@ -188,6 +202,7 @@ bool _history_app_recently()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
        const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -199,7 +214,7 @@ bool _history_app_recently()
        bool_val = __get_list(CONTEXT_HISTORY_RECENTLY_USED_APP);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -209,6 +224,7 @@ bool _history_app_frequently()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
        const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -220,7 +236,7 @@ bool _history_app_frequently()
        bool_val = __get_list(CONTEXT_HISTORY_FREQUENTLY_USED_APP);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -230,6 +246,7 @@ bool _history_app_rarely()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
        const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -239,7 +256,7 @@ bool _history_app_rarely()
        bool_val = __get_list(CONTEXT_HISTORY_RARELY_USED_APP);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -249,6 +266,7 @@ bool _history_app_peak_time()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -260,7 +278,7 @@ bool _history_app_peak_time()
        bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_APP);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -270,6 +288,7 @@ bool _history_app_setting()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
        __filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
@@ -279,7 +298,7 @@ bool _history_app_setting()
        bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_APP);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -289,6 +308,7 @@ bool _history_music_peak_time()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -299,7 +319,7 @@ bool _history_music_peak_time()
        bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_MUSIC);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -309,6 +329,7 @@ bool _history_music_setting()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
        __filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
@@ -317,7 +338,7 @@ bool _history_music_setting()
        bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_MUSIC);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -327,6 +348,7 @@ bool _history_video_peak_time()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_HOUR_OF_DAY, CONTEXT_HISTORY_TOTAL_COUNT, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -337,7 +359,7 @@ bool _history_video_peak_time()
        bool_val = __get_list(CONTEXT_HISTORY_PEAK_TIME_FOR_VIDEO);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -347,6 +369,7 @@ bool _history_video_setting()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_AUDIO_JACK, CONTEXT_HISTORY_SYSTEM_VOLUME, CONTEXT_HISTORY_MEDIA_VOLUME, NULL};
        const char *str_attr[] = {NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
        __filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
@@ -355,7 +378,7 @@ bool _history_video_setting()
        bool_val = __get_list(CONTEXT_HISTORY_COMMON_SETTING_FOR_VIDEO);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
@@ -365,6 +388,7 @@ bool _history_comm_frequently()
 {
        const char *int_attr[] = {CONTEXT_HISTORY_TOTAL_COUNT, CONTEXT_HISTORY_TOTAL_DURATION, CONTEXT_HISTORY_LAST_TIME, NULL};
        const char *str_attr[] = {CONTEXT_HISTORY_ADDRESS, NULL};
+       const char *double_attr[] = {NULL};
 
        __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
        __filter_set_int(CONTEXT_HISTORY_FILTER_TIME_SPAN, KEY_TIME_SPAN);
@@ -375,7 +399,44 @@ bool _history_comm_frequently()
        bool_val = __get_list(CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS);
        IF_FAIL_RETURN(bool_val, false);
 
-       bool_val = __iterate_list(int_attr, str_attr);
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
+       IF_FAIL_RETURN(bool_val, false);
+
+       return true;
+}
+
+bool _history_battery()
+{
+       const char *int_attr[] = {NULL};
+       const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+       const char *double_attr[] = {CONTEXT_HISTORY_TOTAL_AMOUNT, NULL};
+
+       __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
+       __filter_set_int(CONTEXT_HISTORY_FILTER_START_TIME, KEY_START_TIME);
+       __filter_set_int(CONTEXT_HISTORY_FILTER_END_TIME, KEY_END_TIME);
+
+       bool_val = __get_list(CONTEXT_HISTORY_BATTERY_USAGE);
+       IF_FAIL_RETURN(bool_val, false);
+
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
+       IF_FAIL_RETURN(bool_val, false);
+
+       return true;
+}
+
+bool _history_battery_recent()
+{
+       const char *int_attr[] = {"UsedTime", NULL};
+       const char *str_attr[] = {CONTEXT_HISTORY_APP_ID, NULL};
+       const char *double_attr[] = {CONTEXT_HISTORY_TOTAL_AMOUNT, NULL};
+
+       __filter_set_int(CONTEXT_HISTORY_FILTER_RESULT_SIZE, KEY_RESULT_SIZE);
+       __filter_set_int(CONTEXT_HISTORY_FILTER_END_TIME, KEY_END_TIME);
+
+       bool_val = __get_list(CONTEXT_HISTORY_RECENT_BATTERY_USAGE);
+       IF_FAIL_RETURN(bool_val, false);
+
+       bool_val = __iterate_list(int_attr, double_attr, str_attr);
        IF_FAIL_RETURN(bool_val, false);
 
        return true;
index 18cb075..52aa2f0 100644 (file)
@@ -32,4 +32,7 @@ bool _history_video_setting();
 
 bool _history_comm_frequently();
 
+bool _history_battery();
+bool _history_battery_recent();
+
 #endif
index b301b1d..6c0d8a5 100644 (file)
@@ -25,6 +25,7 @@ namespace ctx {
                int err = 0;
                int req_id = 0;
                int int_val = 0;
+               double double_val = 0;
                bool bool_val = false;
                bool skip_tc = false;
                bool newline_after_tcname = false;
@@ -65,6 +66,7 @@ void ctx::test::cleanup_vars()
        ctx::test::json_val = EMPTY_JSON_OBJECT;
        ctx::test::bool_val = false;
        ctx::test::int_val = 0;
+       ctx::test::double_val = 0;
        ctx::test::str_val = "";
        ctx::test::skip_tc = false;
 }
index 30e72f9..71bc726 100644 (file)
@@ -77,6 +77,7 @@ namespace ctx {
                extern int err;
                extern int req_id;
                extern int int_val;
+               extern double double_val;
                extern bool bool_val;
                extern bool skip_tc;
                extern bool newline_after_tcname;