Add default Smack manifest for ui-gadget.spec
[pkgs/u/ui-gadget.git] / TC / unit / utc_ApplicationFW_ug_destroy_me_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_destroy_me_func_01(void);
33 static void utc_ApplicationFW_ug_destroy_me_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_destroy_me_func_01, POSITIVE_TC_IDX },
42         { utc_ApplicationFW_ug_destroy_me_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         struct ui_gadget *ug = data;
78
79         r = ug_destroy_me(ug);
80         if (r) {
81                 tet_infoline("ug_destroy_me() failed in positive test case");
82                 tet_result(TET_FAIL);
83                 goto exit;
84         }
85         tet_result(TET_PASS);
86
87 exit:
88         elm_exit();
89         return 0;
90 }
91
92 static void destroy_cb(struct ui_gadget *ug, void *priv)
93 {
94         // dummy destroy callback
95 }
96
97 /**
98  * @brief Positive test case of ug_destroy_me()
99  */
100 static void utc_ApplicationFW_ug_destroy_me_func_01(void)
101 {
102         struct ui_gadget *ug;
103         struct ug_cbs cbs = {0, };
104
105         if (init()) {
106                 tet_result(TET_UNINITIATED);
107                 return;
108         }
109
110         cbs.destroy_cb = destroy_cb;
111
112         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, &cbs);
113         if (!ug) {
114                 tet_infoline("ug_create() failed");
115                 tet_result(TET_UNINITIATED);
116         }
117
118         ecore_idler_add(tst01, ug);
119         elm_run();
120 }
121
122 static Eina_Bool tst02(void *data)
123 {
124         int r = 0;
125
126         r = ug_destroy_me(NULL);
127         if (!r) {
128                 tet_infoline("ug_destroy_me() failed in negative test case");
129                 tet_result(TET_FAIL);
130                 goto exit;
131         }
132         tet_result(TET_PASS);
133
134 exit:
135         elm_exit();
136         return 0;
137 }
138
139 /**
140  * @brief Negative test case of ug_init ug_destroy_me()
141  */
142 static void utc_ApplicationFW_ug_destroy_me_func_02(void)
143 {
144         struct ui_gadget *ug;
145
146         if (init()) {
147                 tet_result(TET_UNINITIATED);
148                 return;
149         }
150
151         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, NULL, NULL);
152         if (!ug) {
153                 tet_infoline("ug_create() failed");
154                 tet_result(TET_UNINITIATED);
155         }
156
157         ecore_idler_add(tst02, ug);
158         elm_run();
159 }