Initialize Tizen 2.3
[platform/core/api/notification.git] / TC / testcase / utc_notification_list.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_list_get_head_n(void);
37 static void utc_notification_list_get_head_p(void);
38 static void utc_notification_list_get_tail_n(void);
39 static void utc_notification_list_get_tail_p(void);
40 static void utc_notification_list_get_prev_n(void);
41 static void utc_notification_list_get_prev_p(void);
42 static void utc_notification_list_get_next_n(void);
43 static void utc_notification_list_get_next_p(void);
44 static void utc_notification_list_get_data_n(void);
45 static void utc_notification_list_get_data_p(void);
46 static void utc_notification_list_append_n(void);
47 static void utc_notification_list_append_p(void);
48 static void utc_notification_list_remove_n(void);
49 static void utc_notification_list_remove_p(void);
50
51 void (*tet_startup)(void) = startup;
52 void (*tet_cleanup)(void) = cleanup;
53
54 struct tet_testlist tet_testlist[] = {
55         {utc_notification_list_get_head_n, NEGATIVE_TC_IDX},
56         {utc_notification_list_get_head_p, POSITIVE_TC_IDX},
57         {utc_notification_list_get_tail_n, NEGATIVE_TC_IDX},
58         {utc_notification_list_get_tail_p, POSITIVE_TC_IDX},
59         {utc_notification_list_get_prev_n, NEGATIVE_TC_IDX},
60         {utc_notification_list_get_prev_p, POSITIVE_TC_IDX},
61         {utc_notification_list_get_next_n, NEGATIVE_TC_IDX},
62         {utc_notification_list_get_next_p, POSITIVE_TC_IDX},
63         {utc_notification_list_get_data_n, NEGATIVE_TC_IDX},
64         {utc_notification_list_get_data_p, POSITIVE_TC_IDX},
65         {utc_notification_list_append_n, NEGATIVE_TC_IDX},
66         {utc_notification_list_append_p, POSITIVE_TC_IDX},
67         {utc_notification_list_remove_n, NEGATIVE_TC_IDX},
68         {utc_notification_list_remove_p, POSITIVE_TC_IDX},
69         { NULL, 0 },
70 };
71
72 static void startup(void)
73 {
74         /* start of TC */
75         notifiation_clear(NOTIFICATION_TYPE_NONE);
76         tet_printf("\n TC start");
77 }
78
79
80 static void cleanup(void)
81 {
82         /* end of TC */
83         tet_printf("\n TC end");
84 }
85
86 /**
87  * @brief Negative test case of notification_list_get_head()
88  */
89 static void utc_notification_list_get_head_n(void)
90 {
91         notification_list_h list = NULL;
92         notification_list_h list_value = NULL;
93         notification_h notification_1 = NULL;
94         notification_h notification_2 = NULL;
95         notification_h notification_3 = NULL;
96         notification_h notification_4 = NULL;
97
98         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
99         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
100         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
101         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
102         list = notification_list_append(list, notification_1);
103         list = notification_list_append(list, notification_2);
104         list = notification_list_append(list, notification_3);
105         list = notification_list_append(list, notification_4);
106
107         list_value = notification_list_get_head(NULL);
108         dts_check_eq("notification_list_get_head", list_value, NULL,
109                 "Must return NULL in case of invalid parameter");
110 }
111
112 /**
113  * @brief Positive test case of notification_list_get_head()
114  */
115 static void utc_notification_list_get_head_p(void)
116 {
117         notification_list_h list = NULL;
118         notification_list_h list_value = NULL;
119         notification_h notification_1 = NULL;
120         notification_h notification_2 = NULL;
121         notification_h notification_3 = NULL;
122         notification_h notification_4 = NULL;
123
124         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
125         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
126         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
127         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
128         list = notification_list_append(list, notification_1);
129         list = notification_list_append(list, notification_2);
130         list = notification_list_append(list, notification_3);
131         list = notification_list_append(list, notification_4);
132
133         /*Invalid parameter test*/
134         list_value = notification_list_get_head(list);
135         dts_check_ne("notification_list_get_head", list_value, NULL,
136                 "Must return valid pointer in case of invalid parameter");
137 }
138
139 /**
140  * @brief Negative test case of notification_list_get_tail()
141  */
142 static void utc_notification_list_get_tail_n(void)
143 {
144         notification_list_h list = NULL;
145         notification_list_h list_value = NULL;
146         notification_h notification_1 = NULL;
147         notification_h notification_2 = NULL;
148         notification_h notification_3 = NULL;
149         notification_h notification_4 = NULL;
150
151         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
152         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
153         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
154         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
155         list = notification_list_append(list, notification_1);
156         list = notification_list_append(list, notification_2);
157         list = notification_list_append(list, notification_3);
158         list = notification_list_append(list, notification_4);
159
160         list_value = notification_list_get_tail(NULL);
161         dts_check_eq("notification_list_get_tail", list_value, NULL,
162                 "Must return NULL in case of invalid parameter");
163 }
164
165 /**
166  * @brief Positive test case of notification_list_get_tail()
167  */
168 static void utc_notification_list_get_tail_p(void)
169 {
170         notification_list_h list = NULL;
171         notification_list_h list_value = NULL;
172         notification_h notification_1 = NULL;
173         notification_h notification_2 = NULL;
174         notification_h notification_3 = NULL;
175         notification_h notification_4 = NULL;
176
177         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
178         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
179         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
180         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
181         list = notification_list_append(list, notification_1);
182         list = notification_list_append(list, notification_2);
183         list = notification_list_append(list, notification_3);
184         list = notification_list_append(list, notification_4);
185
186         /*Invalid parameter test*/
187         list_value = notification_list_get_tail(list);
188         dts_check_ne("notification_list_get_tail", list_value, NULL,
189                 "Must return valid pointer in case of invalid parameter");
190 }
191
192 /**
193  * @brief Negative test case of notification_list_get_prev()
194  */
195 static void utc_notification_list_get_prev_n(void)
196 {
197         notification_list_h list = NULL;
198         notification_list_h list_value = NULL;
199         notification_h notification_1 = NULL;
200         notification_h notification_2 = NULL;
201         notification_h notification_3 = NULL;
202         notification_h notification_4 = NULL;
203
204         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
205         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
206         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
207         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
208         list = notification_list_append(list, notification_1);
209         list = notification_list_append(list, notification_2);
210         list = notification_list_append(list, notification_3);
211         list = notification_list_append(list, notification_4);
212
213         list_value = notification_list_get_prev(NULL);
214         dts_check_eq("notification_list_get_prev", list_value, NULL,
215                 "Must return NULL in case of invalid parameter");
216 }
217
218 /**
219  * @brief Positive test case of notification_list_get_prev()
220  */
221 static void utc_notification_list_get_prev_p(void)
222 {
223         notification_list_h list = NULL;
224         notification_list_h list_value = NULL;
225         notification_h notification_1 = NULL;
226         notification_h notification_2 = NULL;
227         notification_h notification_3 = NULL;
228         notification_h notification_4 = NULL;
229
230         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
231         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
232         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
233         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
234         list = notification_list_append(list, notification_1);
235         list = notification_list_append(list, notification_2);
236         list = notification_list_append(list, notification_3);
237         list = notification_list_append(list, notification_4);
238
239         /*Invalid parameter test*/
240         list =  notification_list_get_tail(list);
241         list_value = notification_list_get_prev(list);
242         dts_check_ne("notification_list_get_prev", list_value, NULL,
243                 "Must return valid pointer in case of invalid parameter");
244 }
245
246 /**
247  * @brief Negative test case of notification_list_get_next()
248  */
249 static void utc_notification_list_get_next_n(void)
250 {
251         notification_list_h list = NULL;
252         notification_list_h list_value = NULL;
253         notification_h notification_1 = NULL;
254         notification_h notification_2 = NULL;
255         notification_h notification_3 = NULL;
256         notification_h notification_4 = NULL;
257
258         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
259         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
260         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
261         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
262         list = notification_list_append(list, notification_1);
263         list = notification_list_append(list, notification_2);
264         list = notification_list_append(list, notification_3);
265         list = notification_list_append(list, notification_4);
266
267         list_value = notification_list_get_next(NULL);
268         dts_check_eq("notification_list_get_next", list_value, NULL,
269                 "Must return NULL in case of invalid parameter");
270 }
271
272 /**
273  * @brief Positive test case of notification_list_get_next()
274  */
275 static void utc_notification_list_get_next_p(void)
276 {
277         notification_list_h list = NULL;
278         notification_list_h list_value = NULL;
279         notification_h notification_1 = NULL;
280         notification_h notification_2 = NULL;
281         notification_h notification_3 = NULL;
282         notification_h notification_4 = NULL;
283
284         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
285         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
286         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
287         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
288         list = notification_list_append(list, notification_1);
289         list = notification_list_append(list, notification_2);
290         list = notification_list_append(list, notification_3);
291         list = notification_list_append(list, notification_4);
292
293         /*Invalid parameter test*/
294         list =  notification_list_get_head(list);
295         list_value = notification_list_get_next(list);
296         dts_check_ne("notification_list_get_next", list_value, NULL,
297                 "Must return valid pointer in case of invalid parameter");
298 }
299
300 /**
301  * @brief Negative test case of notification_list_get_data()
302  */
303 static void utc_notification_list_get_data_n(void)
304 {
305         notification_list_h list = NULL;
306         notification_h value = NULL;
307         notification_h notification_1 = NULL;
308         notification_h notification_2 = NULL;
309         notification_h notification_3 = NULL;
310         notification_h notification_4 = NULL;
311
312         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
313         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
314         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
315         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
316         list = notification_list_append(list, notification_1);
317         list = notification_list_append(list, notification_2);
318         list = notification_list_append(list, notification_3);
319         list = notification_list_append(list, notification_4);
320
321         value = notification_list_get_data(NULL);
322         dts_check_eq("notification_list_get_data", value, NULL,
323                 "Must return NULL in case of invalid parameter");
324 }
325
326 /**
327  * @brief Positive test case of notification_list_get_data()
328  */
329 static void utc_notification_list_get_data_p(void)
330 {
331         notification_list_h list = NULL;
332         notification_h value = NULL;
333         notification_h notification_1 = NULL;
334         notification_h notification_2 = NULL;
335         notification_h notification_3 = NULL;
336         notification_h notification_4 = NULL;
337
338         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
339         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
340         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
341         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
342         list = notification_list_append(list, notification_1);
343         list = notification_list_append(list, notification_2);
344         list = notification_list_append(list, notification_3);
345         list = notification_list_append(list, notification_4);
346
347         /*Invalid parameter test*/
348         value = notification_list_get_data(list);
349         dts_check_ne("notification_list_get_data", value, NULL,
350                 "Must return valid pointer in case of invalid parameter");
351 }
352
353 /**
354  * @brief Negative test case of notification_list_append()
355  */
356 static void utc_notification_list_append_n(void)
357 {
358         notification_list_h list = NULL;
359         notification_h notification_1 = NULL;
360         notification_h notification_2 = NULL;
361         notification_h notification_3 = NULL;
362         notification_h notification_4 = NULL;
363
364         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
365         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
366         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
367         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
368         list = notification_list_append(list, NULL);
369         dts_check_eq("notification_list_append", list, NULL,
370                 "Must return NULL in case of invalid parameter");
371 }
372
373 /**
374  * @brief Positive test case of notification_list_append()
375  */
376 static void utc_notification_list_append_p(void)
377 {
378         notification_list_h list = NULL;
379         notification_h notification_1 = NULL;
380         notification_h notification_2 = NULL;
381         notification_h notification_3 = NULL;
382         notification_h notification_4 = NULL;
383
384         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
385         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
386         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
387         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
388         list = notification_list_append(list, notification_1);
389         dts_check_ne("notification_list_append", list, NULL,
390                 "Must return valid pointer in case of invalid parameter");
391 }
392
393 /**
394  * @brief Negative test case of notification_list_remove()
395  */
396 static void utc_notification_list_remove_n(void)
397 {
398         notification_list_h list = NULL;
399         notification_h notification_1 = NULL;
400         notification_h notification_2 = NULL;
401         notification_h notification_3 = NULL;
402         notification_h notification_4 = NULL;
403
404         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
405         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
406         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
407         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
408         list = notification_list_append(list, notification_1);
409         list = notification_list_append(list, notification_2);
410         list = notification_list_append(list, notification_3);
411         list = notification_list_append(list, notification_4);
412
413         list = notification_list_remove(NULL, NULL);
414         dts_check_eq("notification_list_remove", list, NULL,
415                 "Must return NULL in case of invalid parameter");
416 }
417
418 /**
419  * @brief Positive test case of notification_list_remove()
420  */
421 static void utc_notification_list_remove_p(void)
422 {
423         notification_list_h list = NULL;
424         notification_h notification_1 = NULL;
425         notification_h notification_2 = NULL;
426         notification_h notification_3 = NULL;
427         notification_h notification_4 = NULL;
428
429         notification_1 = notification_create(NOTIFICATION_TYPE_NOTI);
430         notification_2 = notification_create(NOTIFICATION_TYPE_NOTI);
431         notification_3 = notification_create(NOTIFICATION_TYPE_NOTI);
432         notification_4 = notification_create(NOTIFICATION_TYPE_NOTI);
433         list = notification_list_append(list, notification_1);
434         list = notification_list_append(list, notification_2);
435         list = notification_list_append(list, notification_3);
436         list = notification_list_append(list, notification_4);
437
438         list = notification_list_remove(list, notification_1);
439         dts_check_ne("notification_list_remove", list, NULL,
440                 "Must return valid pointer in case of invalid parameter");
441 }