upload tizen1.0 source
[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
28 void usage()
29 {
30         printf("[usage] sp_test launch/destroy popup_name..."
31                                 "(key1,val1,key2,val2,...)\n");
32 }
33
34 int main(int argc, char **argv)
35 {
36         bundle *b;
37         int i;
38
39         if (argc < 2) {
40                 usage();
41                 return -1;
42         }
43
44         if (strcmp(argv[1], "launch") == 0) {
45                 if ((argc < 3) || (argc % 2 == 0)) {
46                         usage();
47                         return -1;
48                 }
49
50                 b = bundle_create();
51                 for (i = 3; i < argc; i = i + 2)
52                         bundle_add(b, argv[i], argv[i + 1]);
53                 syspopup_launch(argv[2], b);
54                 bundle_free(b);
55         } else if (strcmp(argv[1], "destroy") == 0) {
56                 syspopup_destroy_all();
57         } else {
58                 usage();
59         }
60
61         return 0;
62 }
63