Add default Smack manifest for ui-gadget.spec
[pkgs/u/ui-gadget.git] / TC / unit / utc_ApplicationFW_ug_send_result_func.c
1 /*
2  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * This file is part of the UI Gadget
5  * Written by Jayoun Lee <airjany@samsung.com>, Jinwoo Nam <jwoo.nam@samsung.com>
6  *
7  * PROPRIETARY/CONFIDENTIAL
8  *
9  * This software is the confidential and proprietary information of
10  * SAMSUNG ELECTRONICS (Confidential Information).
11  * You shall not disclose such Confidential Information and shall
12  * use it only in accordance with the terms of the license agreement
13  * you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no
14  * representations or warranties about the suitability
15  * of the software, either express or implied, including but not
16  * limited to the implied warranties of merchantability, fitness for a particular purpose, or non-
17  * infringement. SAMSUNG shall not be liable for any damages suffered by licensee as
18  * a result of using, modifying or distributing this software or its derivatives.
19  *
20  */
21 #include <tet_api.h>
22 #include <ui-gadget-module.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_result_func_01(void);
33 static void utc_ApplicationFW_ug_send_result_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_result_func_01, POSITIVE_TC_IDX },
42         { utc_ApplicationFW_ug_send_result_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 *result;
78         struct ui_gadget *ug = data;
79
80         result = bundle_create();
81         if (!result) {
82                 tet_infoline("bundle_create() failed");
83                 tet_result(TET_UNINITIATED);
84                 goto exit;
85         }
86         bundle_add(result, "test", "case");
87
88         r = ug_send_result(ug, result);
89         if (r) {
90                 tet_infoline("ug_send_result() 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 static void result_cb(struct ui_gadget *ug, bundle *b, void *priv)
102 {
103         // dummy result callback
104 }
105
106 /**
107  * @brief Positive test case of ug_send_result()
108  */
109 static void utc_ApplicationFW_ug_send_result_func_01(void)
110 {
111         struct ui_gadget *ug;
112         struct ug_cbs cbs = {0, };
113
114         if (init()) {
115                 tet_result(TET_UNINITIATED);
116                 return;
117         }
118
119         cbs.result_cb = result_cb;
120
121         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, &cbs);
122         if (!ug) {
123                 tet_infoline("ug_create() failed");
124                 tet_result(TET_UNINITIATED);
125         }
126
127         ecore_idler_add(tst01, ug);
128         elm_run();
129 }
130
131 static Eina_Bool tst02(void *data)
132 {
133         int r = 0;
134         bundle *result;
135         struct ui_gadget *ug = data;
136
137         result = bundle_create();
138         if (!result) {
139                 tet_infoline("bundle_create() failed");
140                 tet_result(TET_UNINITIATED);
141                 goto exit;
142         }
143         bundle_add(result, "test", "case");
144
145         r = ug_send_result(NULL, NULL);
146         if (!r) {
147                 tet_infoline("ug_send_result() failed in negative test case");
148                 tet_result(TET_FAIL);
149                 goto exit;
150         }
151
152         r = ug_send_result(ug, NULL);
153         if (!r) {
154                 tet_infoline("ug_send_result() failed in negative test case");
155                 tet_result(TET_FAIL);
156                 goto exit;
157         }
158
159         r = ug_send_result(NULL, result);
160         if (!r) {
161                 tet_infoline("ug_send_result() failed in negative test case");
162                 tet_result(TET_FAIL);
163                 goto exit;
164         }
165
166         tet_result(TET_PASS);
167 exit:
168         elm_exit();
169         return 0;
170 }
171
172
173 /**
174  * @brief Negative test case of ug_init ug_send_result()
175  */
176 static void utc_ApplicationFW_ug_send_result_func_02(void)
177 {
178         struct ui_gadget *ug;
179
180         if (init()) {
181                 tet_result(TET_UNINITIATED);
182                 return;
183         }
184
185         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, NULL);
186         if (!ug) {
187                 tet_infoline("ug_create() failed");
188                 tet_result(TET_UNINITIATED);
189         }
190
191         ecore_idler_add(tst02, ug);
192         elm_run();
193 }