2 * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <sys/types.h>
26 /* For multi-user support */
27 #include <tzplatform_config.h>
30 #include "rua_internal.h"
32 #include "rua_stat_internal.h"
34 static int __add_history()
38 char *pkgname = "org.tizen.ruatester";
40 app_path = (char *)tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
41 ret = rua_add_history_for_uid(pkgname, app_path, NULL, 5001);
45 static int __delete_history_with_pkgname()
48 char *pkgname = "org.tizen.ruatester";
50 ret = rua_delete_history_with_pkgname_for_uid(pkgname, 5001);
54 static int __load_rua_history()
59 struct rua_rec record;
61 if (rua_history_load_db_for_uid(&table, &rows, &cols, 5001) || !table) {
62 printf("fail to load rua history \n");
67 for (row = 0; row < rows; ++row) {
68 rua_history_get_rec(&record, table, rows, cols, row);
69 printf("pkgname : %s, time : %d \n", record.pkg_name, (int)record.launch_time);
72 rua_history_unload_db(&table);
76 static int __update_stat()
80 ret = rua_stat_update_for_uid("ruacaller", "org.tizen.ruatester", 5001);
84 static int __rua_stat_tag_iter_cb(const char *rua_stat_tag, void *data)
86 printf("rua_stat_tag : %s \n", rua_stat_tag);
91 static int __get_stat_tags()
94 ret = rua_stat_get_stat_tags_for_uid("ruacaller", __rua_stat_tag_iter_cb, NULL, 5001);
98 static gboolean run_test(int selected_number)
100 gboolean go_to_loop = TRUE;
102 switch (selected_number) {
112 __delete_history_with_pkgname();
116 __load_rua_history();
139 gboolean run_next = TRUE;
142 printf("==========================================\n");
143 printf(" Basic test menu \n");
144 printf("==========================================\n");
145 printf(" 0. EXIT\n");
146 printf(" 1. Add rua history to DEFAULT USER(5001)\n");
147 printf(" 2. Delete history with pkgname\n");
148 printf(" 3. Load RUA history\n");
149 printf(" 4. Update RUA stat\n");
150 printf(" 5. Get RUA stat tags\n");
151 printf("------------------------------------------\n");
152 ret = scanf("%d", &test_num);
154 printf("scanf fail %d", ret);
158 run_next = run_test(test_num);