4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
38 typedef struct _test_func_t{
45 __set_bundle_from_args(bundle * kb)
56 while( (opt = getopt(gargc,gargv,"d:o:m:u:p:")) != -1){
64 mime = strdup(optarg);
72 package = strdup(optarg);
77 key = strtok(optarg,",");
78 while(val_array[i] = strtok(NULL,","))
83 appsvc_add_data(kb, key, val_array[0]);
85 appsvc_add_data_array(kb, key, val_array, i);
92 appsvc_set_operation(kb,op);
96 appsvc_set_mime(kb,mime);
100 appsvc_set_uri(kb,uri);
104 appsvc_set_pkgname(kb,package);
114 kb = bundle_create();
117 printf("bundle creation fail\n");
120 printf("[run_svc test]\n");
122 __set_bundle_from_args(kb);
124 ret = appsvc_run_service(kb,0,NULL, NULL);
127 printf("open service success\n");
136 printf("open service fail\n");
146 static void prt_recvd_bundle(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
150 size_t *array_item_size;
156 if(bundle_keyval_type_is_array(kv) > 0) {
157 bundle_keyval_get_array_val(kv, &array_val, &array_len, &array_item_size);
159 for (i=0;i<array_len;i++)
161 printf("recvd - key: %s[%d], value: %s\n", key, i, array_val[i]);
165 bundle_keyval_get_basic_val(kv, &val, &size);
166 printf("recvd - key: %s, value: %s\n",key,val);
170 static void cb_func(bundle *kb, int request_code, appsvc_result_val result, void *data)
175 if(result == APPSVC_RES_CANCEL){
176 printf("==== %d : canceled(preemptted) my request ===\n",num);
179 printf("==== %d : result packet === result %d\n",num, (int)result);
180 //bundle_iterate(kb, prt_recvd_bundle, NULL);
182 bundle_foreach(kb, prt_recvd_bundle, NULL);
186 if(strcmp(cmd,"run_svc_res")==0){
187 printf("==== end of appsvc_run() ====\n");
188 ecore_main_loop_quit();
204 kb = bundle_create();
207 printf("bundle creation fail\n");
211 printf("[run_svc_res test]\n");
213 __set_bundle_from_args(kb);
215 ret = appsvc_run_service(kb, 0, cb_func, (void*)num);
218 printf("open service success\n");
227 printf("open service fail\n");
238 static test_func_t test_func[] = {
241 {"run_svc", run_svc, "run_svc test",
242 "[usage] run_svc -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
243 {"run_svc_res", run_svc_res, "run_svc_res test",
244 "[usage] run_svc_res -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
248 int callfunc(char* testname)
254 for(i=0; i<sizeof(test_func)/sizeof(test_func_t); i++)
257 if(strcmp(testname,tmp->name)==0){
259 if(strcmp(testname,"all")){
261 printf("... test failed\n");
263 printf("... test successs ret = %d\n", res);
271 void print_usage(char* progname)
276 printf("[usage] %s <cmd> ...\n",progname);
277 printf(" - available cmd list\n");
279 for(i=0; i<sizeof(test_func)/sizeof(test_func_t); i++)
282 printf("\t%s : %s\n",tmp->name, tmp->desc);
283 printf("\t\t%s\n",tmp->usage);
289 static Eina_Bool run_func(void *data)
293 if(strcmp(cmd,"run_svc_res") == 0 )
296 ecore_main_loop_quit();
302 int main(int argc, char** argv)
305 print_usage(argv[0]);
314 apn_pid = atoi(argv[2]);
316 aul_launch_init(NULL,NULL);
318 //aul_listen_app_dead_signal(dead_tracker,NULL);
319 //aul_listen_app_dead_signal(NULL,NULL);
321 ecore_idler_add(run_func, NULL);
323 ecore_main_loop_begin();