tizen 2.4 release
[framework/base/syspopup.git] / test / test.c
1 /*
2  * syspopup
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include "syspopup_caller.h"
27 #include <bundle_internal.h>
28
29 void usage()
30 {
31         printf("[usage] sp_test launch/destroy popup_name..."
32                                 "(key1,val1,key2,val2,...)\n");
33 }
34
35 int main(int argc, char **argv)
36 {
37         bundle *b;
38         int i;
39         int ret = 0;
40
41         if (argc < 2) {
42                 usage();
43                 return -1;
44         }
45
46         if (strcmp(argv[1], "launch") == 0) {
47                 if ((argc < 3) || (argc % 2 == 0)) {
48                         usage();
49                         return -1;
50                 }
51
52                 b = bundle_create();
53                 for (i = 3; i < argc; i = i + 2)
54                         bundle_add(b, argv[i], argv[i + 1]);
55                 ret = syspopup_launch(argv[2], b);
56                 bundle_free(b);
57                 if(ret < 0) return -1;
58
59         } else if (strcmp(argv[1], "destroy") == 0) {
60                 ret = syspopup_destroy_all();
61                 if(ret < 0) return -1;
62         } else {
63                 usage();
64         }
65
66         return 0;
67 }
68