8dc13db5d841043b713454276cab09adca77f0fa
[platform/core/api/notification.git] / TC / testcase / utc_notification_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 <notification.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_notification_setting_property_set_n(void);
37 static void utc_notification_setting_property_set_p(void);
38 static void utc_notification_setting_property_get_n(void);
39 static void utc_notification_setting_property_get_p(void);
40
41 void (*tet_startup)(void) = startup;
42 void (*tet_cleanup)(void) = cleanup;
43
44 struct tet_testlist tet_testlist[] = {
45         {utc_notification_setting_property_set_n, NEGATIVE_TC_IDX},
46         {utc_notification_setting_property_set_p, POSITIVE_TC_IDX},
47         {utc_notification_setting_property_get_n, NEGATIVE_TC_IDX},
48         {utc_notification_setting_property_get_p, POSITIVE_TC_IDX},
49         { NULL, 0 },
50 };
51
52 static void startup(void)
53 {
54         /* start of TC */
55         notification_clear(NOTIFICATION_TYPE_NONE);
56         tet_printf("\n TC start");
57 }
58
59
60 static void cleanup(void)
61 {
62         /* end of TC */
63         tet_printf("\n TC end");
64 }
65
66 /**
67  * @brief Negative test case of notification_setting_property_set()
68  */
69 static void utc_notification_setting_property_set_n(void)
70 {
71         int ret;
72
73         ret = notification_setting_property_set(NULL, NULL, NULL);
74         dts_check_eq("notification_setting_property_set", ret, NOTIFICATION_ERROR_INVALID_DATA,
75                 "Must return NOTIFICATION_ERROR_INVALID_DATA in case of invalid parameter");
76 }
77
78 /**
79  * @brief Positive test case of notification_setting_property_set()
80  */
81 static void utc_notification_setting_property_set_p(void)
82 {
83         int ret;
84
85         ret = notification_setting_property_set(TEST_PKG, "OPT_NOTIFICATION", "ON");
86         /*Invalid parameter test*/
87         dts_check_ne("notification_setting_property_set", ret, NOTIFICATION_ERROR_INVALID_DATA,
88                 "Must return NOTIFICATION_ERROR_NONE in case of valid parameter");
89 }
90
91 /**
92  * @brief Negative test case of notification_setting_property_get()
93  */
94 static void utc_notification_setting_property_get_n(void)
95 {
96         int ret;
97
98         ret = notification_setting_property_get(NULL, NULL, NULL);
99         dts_check_eq("notification_setting_property_get", ret, NOTIFICATION_ERROR_INVALID_DATA,
100                 "Must return NOTIFICATION_ERROR_INVALID_DATA in case of invalid parameter");
101 }
102
103 /**
104  * @brief Positive test case of notification_setting_property_get()
105  */
106 static void utc_notification_setting_property_get_p(void)
107 {
108         int ret;
109         char *value = NULL;
110
111         ret = notification_setting_property_get(TEST_PKG, "OPT_NOTIFICATION", &value);
112         dts_check_ne("notification_setting_property_get", ret, NOTIFICATION_ERROR_INVALID_DATA,
113                 "Must return NOTIFICATION_ERROR_NONE in case of valid parameter");
114 }