apply FSL license
[pkgs/u/ui-gadget.git] / TC / unit / utc_ApplicationFW_ug_send_message_func.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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
18
19
20
21 #include <tet_api.h>
22 #include <ui-gadget.h>
23 #include <Elementary.h>
24 #include <Ecore_X.h>
25
26 static void startup(void);
27 static void cleanup(void);
28
29 void (*tet_startup)(void) = startup;
30 void (*tet_cleanup)(void) = cleanup;
31
32 static void utc_ApplicationFW_ug_send_message_func_01(void);
33 static void utc_ApplicationFW_ug_send_message_func_02(void);
34
35 enum {
36         POSITIVE_TC_IDX = 0x01,
37         NEGATIVE_TC_IDX,
38 };
39
40 struct tet_testlist tet_testlist[] = {
41         { utc_ApplicationFW_ug_send_message_func_01, POSITIVE_TC_IDX },
42         { utc_ApplicationFW_ug_send_message_func_02, NEGATIVE_TC_IDX },
43         { NULL, 0},
44 };
45
46 #define TESTUG "helloUG-efl"
47
48 static void startup(void)
49 {
50         elm_init(0, NULL);
51 }
52
53 static void cleanup(void)
54 {
55         elm_shutdown();
56 }
57
58 static int init(void)
59 {
60         Evas_Object *win;
61         win = elm_win_add(NULL, "UI gadget test", ELM_WIN_BASIC);
62         if (!win) {
63                 tet_infoline("Cannot create window");
64                 return -1;
65         }
66
67         if (UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE)) {
68                 tet_infoline("ug_init() failed");
69                 return -1;
70         }
71         return 0;
72 }
73
74 static Eina_Bool tst01(void *data)
75 {
76         int r = 0;
77         bundle *msg;
78         struct ui_gadget *ug = data;
79
80         msg = bundle_create();
81         if (!msg) {
82                 tet_infoline("bundle_create() failed");
83                 tet_result(TET_UNINITIATED);
84                 goto exit;
85         }
86         bundle_add(msg, "test", "case");
87
88         r = ug_send_message(ug, msg);
89         if (r) {
90                 tet_infoline("ug_send_message() failed in positive test case");
91                 tet_result(TET_FAIL);
92                 goto exit;
93         }
94         tet_result(TET_PASS);
95
96 exit:
97         elm_exit();
98         return 0;
99 }
100
101 /**
102  * @brief Positive test case of ug_send_message()
103  */
104 static void utc_ApplicationFW_ug_send_message_func_01(void)
105 {
106         struct ui_gadget *ug;
107
108         if (init()) {
109                 tet_result(TET_UNINITIATED);
110                 return;
111         }
112
113         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, NULL);
114         if (!ug) {
115                 tet_infoline("ug_create() failed");
116                 tet_result(TET_UNINITIATED);
117         }
118
119         ecore_idler_add(tst01, ug);
120         elm_run();
121 }
122
123 static Eina_Bool tst02(void *data)
124 {
125         int r = 0;
126         bundle *msg;
127         struct ui_gadget *ug = data;
128
129         msg = bundle_create();
130         if (!msg) {
131                 tet_infoline("bundle_create() failed");
132                 tet_result(TET_UNINITIATED);
133                 goto exit;
134         }
135         bundle_add(msg, "test", "case");
136
137         r = ug_send_message(NULL, NULL);
138         if (!r) {
139                 tet_infoline("ug_send_message() failed in negative test case");
140                 tet_result(TET_FAIL);
141                 goto exit;
142         }
143
144         r = ug_send_message(ug, NULL);
145         if (!r) {
146                 tet_infoline("ug_send_message() failed in negative test case");
147                 tet_result(TET_FAIL);
148                 goto exit;
149         }
150
151         r = ug_send_message(NULL, msg);
152         if (!r) {
153                 tet_infoline("ug_send_message() failed in negative test case");
154                 tet_result(TET_FAIL);
155                 goto exit;
156         }
157
158         tet_result(TET_PASS);
159
160 exit:
161         elm_exit();
162         return 0;
163 }
164
165 /**
166  * @brief Negative test case of ug_init ug_send_message()
167  */
168 static void utc_ApplicationFW_ug_send_message_func_02(void)
169 {
170         struct ui_gadget *ug;
171
172         if (init()) {
173                 tet_result(TET_UNINITIATED);
174                 return;
175         }
176
177         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, NULL);
178         if (!ug) {
179                 tet_infoline("ug_create() failed");
180                 tet_result(TET_UNINITIATED);
181         }
182
183         ecore_idler_add(tst02, ug);
184         elm_run();
185 }