upload tizen1.0 source
[framework/appfw/app-checker.git] / TC / unit / utc_ApplicationFW_ac_check_launch_privilege_func.c
1 /*
2  *  app-checker
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>, Shobhit Srivastava <shobhit.s@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 #include <tet_api.h>
23 #include <app-checker.h>
24 #include <unistd.h>
25 #include <sys/types.h>
26
27 static void startup(void);
28 static void cleanup(void);
29
30 void (*tet_startup) (void) = startup;
31 void (*tet_cleanup) (void) = cleanup;
32
33 static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void);
34 static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void);
35 static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void);
36 static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void);
37
38 enum {
39         POSITIVE_TC_IDX = 0x01,
40         NEGATIVE_TC_IDX,
41 };
42
43 struct tet_testlist tet_testlist[] = {
44         {utc_ApplicationFW_ac_check_launch_privilege_func_01, POSITIVE_TC_IDX},
45         {utc_ApplicationFW_ac_check_launch_privilege_func_02, NEGATIVE_TC_IDX},
46         {utc_ApplicationFW_ac_check_launch_privilege_func_03, NEGATIVE_TC_IDX},
47         {utc_ApplicationFW_ac_check_launch_privilege_func_04, NEGATIVE_TC_IDX},
48         {NULL, 0},
49 };
50
51 static void startup(void)
52 {
53 }
54
55 static void cleanup(void)
56 {
57 }
58
59 /** API Prototype
60 *int ac_check_launch_privilege(const char *pkg_name,
61 *                       const char *pkg_type, int pid);
62 */
63
64
65 /**
66  * @brief Positive test case of ac_check_launch_privilege()
67  */
68 static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void)
69 {
70         int r = AC_R_ERROR;
71         r = ac_check_launch_privilege("org.tizen.calculator", "deb",
72                                       getpid());
73         if (r < 0) {
74                 tet_infoline
75                     ("ac_check_launch_privilege()"
76                      " failed in positive test case");
77                 tet_result(TET_FAIL);
78                 return;
79         }
80         tet_result(TET_PASS);
81 }
82
83 /**
84  * @brief Negative test case 01 of ac_check_launch_privilege()
85  */
86 static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void)
87 {
88         int r = AC_R_ERROR;
89         r = ac_check_launch_privilege(NULL, "deb", getpid());
90         if (r != AC_R_EINVAL) {
91                 tet_infoline
92                     ("ac_check_launch_privilege()"
93                      " failed in negative test case");
94                 tet_result(TET_FAIL);
95                 return;
96         }
97         tet_result(TET_PASS);
98 }
99
100 /**
101  * @brief Negative test case 02 of ac_check_launch_privilege()
102  */
103 static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void)
104 {
105         int r = AC_R_ERROR;
106         r = ac_check_launch_privilege("org.tizen.calculator", NULL, getpid());
107         if (r != AC_R_EINVAL) {
108                 tet_infoline
109                     ("ac_check_launch_privilege()"
110                      " failed in negative test case");
111                 tet_result(TET_FAIL);
112                 return;
113         }
114         tet_result(TET_PASS);
115 }
116
117 /**
118  * @brief Negative test case 03 of ac_check_launch_privilege()
119  */
120 static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void)
121 {
122         int r = AC_R_ERROR;
123         r = ac_check_launch_privilege(NULL, NULL, getpid());
124         if (r != AC_R_EINVAL) {
125                 tet_infoline
126                     ("ac_check_launch_privilege()"
127                      " failed in negative test case");
128                 tet_result(TET_FAIL);
129                 return;
130         }
131         tet_result(TET_PASS);
132 }