Initialize Tizen 2.3
[platform/core/appfw/badge.git] / TC / testcase / utc_badge_setting.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <libintl.h>
23 #include <tet_api.h>
24 #include <badge.h>
25
26 #define TEST_PKG "org.tizen.tetware"
27
28 enum {
29         POSITIVE_TC_IDX = 0x01,
30         NEGATIVE_TC_IDX,
31 };
32
33 static void startup(void);
34 static void cleanup(void);
35
36 static void utc_badge_setting_property_set_n(void);
37 static void utc_badge_setting_property_set_p(void);
38 static void utc_badge_setting_property_get_n(void);
39 static void utc_badge_setting_property_get_p(void);
40
41 #define TEST_PKG "org.tizen.tetware"
42
43 void (*tet_startup)(void) = startup;
44 void (*tet_cleanup)(void) = cleanup;
45
46 struct tet_testlist tet_testlist[] = {
47         {utc_badge_setting_property_set_n, NEGATIVE_TC_IDX},
48         {utc_badge_setting_property_set_p, POSITIVE_TC_IDX},
49         {utc_badge_setting_property_get_n, NEGATIVE_TC_IDX},
50         {utc_badge_setting_property_get_p, POSITIVE_TC_IDX},
51         { NULL, 0 },
52 };
53
54 static void startup(void)
55 {
56         /* start of TC */
57         tet_printf("\n TC start");
58 }
59
60
61 static void cleanup(void)
62 {
63         /* end of TC */
64         tet_printf("\n TC end");
65 }
66
67 /**
68  * @brief Negative test case of badge_setting_property_set()
69  */
70 static void utc_badge_setting_property_set_n(void)
71 {
72         int ret;
73
74         ret = badge_setting_property_set(NULL, NULL, NULL);
75         dts_check_eq("badge_setting_property_set", ret, BADGE_ERROR_INVALID_DATA,
76                 "Must return BADGE_ERROR_INVALID_DATA in case of invalid parameter");
77 }
78
79 /**
80  * @brief Positive test case of badge_setting_property_set()
81  */
82 static void utc_badge_setting_property_set_p(void)
83 {
84         int ret;
85
86         ret = badge_setting_property_set(TEST_PKG, "OPT_BADGE", "ON");
87         /*Invalid parameter test*/
88         dts_check_ne("badge_setting_property_set", ret, BADGE_ERROR_INVALID_DATA,
89                 "Must return BADGE_ERROR_NONE in case of valid parameter");
90 }
91
92 /**
93  * @brief Negative test case of badge_setting_property_get()
94  */
95 static void utc_badge_setting_property_get_n(void)
96 {
97         int ret;
98
99         ret = badge_setting_property_get(NULL, NULL, NULL);
100         dts_check_eq("badge_setting_property_get", ret, BADGE_ERROR_INVALID_DATA,
101                 "Must return BADGE_ERROR_INVALID_DATA in case of invalid parameter");
102 }
103
104 /**
105  * @brief Positive test case of badge_setting_property_get()
106  */
107 static void utc_badge_setting_property_get_p(void)
108 {
109         int ret;
110         char *value = NULL;
111
112         ret = badge_setting_property_get(TEST_PKG, "OPT_BADGE", &value);
113         dts_check_ne("badge_setting_property_get", ret, BADGE_ERROR_INVALID_DATA,
114                 "Must return BADGE_ERROR_NONE in case of valid parameter");
115 }