Give detail license information
[platform/core/api/notification.git] / TC / testcase / utc_notification_status.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_status_message_post_n(void);
37 static void utc_notification_status_message_post_p(void);
38 static void utc_notification_status_monitor_message_cb_set_n(void);
39 static void utc_notification_status_monitor_message_cb_set_p(void);
40 static void utc_notification_status_monitor_message_cb_unset_p(void);
41
42 void (*tet_startup)(void) = startup;
43 void (*tet_cleanup)(void) = cleanup;
44
45 struct tet_testlist tet_testlist[] = {
46         {utc_notification_status_message_post_n, NEGATIVE_TC_IDX},
47         {utc_notification_status_message_post_p, POSITIVE_TC_IDX},
48         {utc_notification_status_monitor_message_cb_set_n, NEGATIVE_TC_IDX},
49         {utc_notification_status_monitor_message_cb_set_p, POSITIVE_TC_IDX},
50         {utc_notification_status_monitor_message_cb_unset_p, POSITIVE_TC_IDX},
51         { NULL, 0 },
52 };
53
54 static void startup(void)
55 {
56         /* start of TC */
57         notification_clear(NOTIFICATION_TYPE_NONE);
58         tet_printf("\n TC start");
59 }
60
61
62 static void cleanup(void)
63 {
64         /* end of TC */
65         tet_printf("\n TC end");
66 }
67
68 static void _message_callback(const char *message, void *data)
69 {
70 }
71
72 /**
73  * @brief Negative test case of notification_status_message_post()
74  */
75 static void utc_notification_status_message_post_n(void)
76 {
77         int ret;
78
79         ret = notification_status_message_post(NULL);
80         dts_check_eq("notification_status_message_post", ret, NOTIFICATION_ERROR_INVALID_DATA,
81                 "Must return NOTIFICATION_ERROR_INVALID_DATA in case of invalid parameter");
82 }
83
84 /**
85  * @brief Positive test case of notification_status_message_post()
86  */
87 static void utc_notification_status_message_post_p(void)
88 {
89         int ret;
90
91         ret = notification_status_message_post("TETWARE-P");
92         /*Invalid parameter test*/
93         dts_check_eq("notification_status_message_post", ret, NOTIFICATION_ERROR_NONE,
94                 "Must return NOTIFICATION_ERROR_NONE in case of valid parameter");
95 }
96
97 /**
98  * @brief Negative test case of notification_status_monitor_message_cb_set()
99  */
100 static void utc_notification_status_monitor_message_cb_set_n(void)
101 {
102         int ret;
103
104         ret = notification_status_monitor_message_cb_set(NULL, NULL);
105         dts_check_eq("notification_status_message_post", ret, NOTIFICATION_ERROR_INVALID_DATA,
106                 "Must return NOTIFICATION_ERROR_INVALID_DATA in case of invalid parameter");
107 }
108
109 /**
110  * @brief Positive test case of notification_status_monitor_message_cb_set()
111  */
112 static void utc_notification_status_monitor_message_cb_set_p(void)
113 {
114         int ret;
115
116         ret = notification_status_monitor_message_cb_set(_message_callback, NULL);
117         dts_check_eq("notification_status_monitor_message_cb_set", ret, NOTIFICATION_ERROR_NONE,
118                 "Must return NOTIFICATION_ERROR_NONE in case of valid parameter");
119 }
120
121 /**
122  * @brief Positive test case of notification_status_monitor_message_cb_unset()
123  */
124 static void utc_notification_status_monitor_message_cb_unset_p(void)
125 {
126         int ret;
127
128         ret = notification_status_monitor_message_cb_unset();
129         dts_check_eq("notification_status_monitor_message_cb_unset", ret, NOTIFICATION_ERROR_NONE,
130                 "Must return NOTIFICATION_ERROR_NONE in case of valid parameter");
131 }