08127152565331c453dca38fc9b75f3244ff06f7
[pkgs/u/ui-gadget.git] / TC / unit / utc_ApplicationFW_ug_create_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_create_func_01(void);
33 static void utc_ApplicationFW_ug_create_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_create_func_01, POSITIVE_TC_IDX },
42         { utc_ApplicationFW_ug_create_func_02, NEGATIVE_TC_IDX },
43         { NULL, 0},
44 };
45
46 #define TESTUG "helloUG-efl"
47 #define TESTUG_ERR "helloUG-efl0-abacbadsf"
48
49 static void startup(void)
50 {
51         char *err;
52         Evas_Object *win;
53
54         elm_init(0, NULL);
55         win = elm_win_add(NULL, "UI gadget test", ELM_WIN_BASIC);
56         if (!win) {
57                 err = "Cannot create window";
58                 goto startup_err;
59         }
60
61         if (UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE)) {
62                 err = "ug_init() failed";
63                 goto startup_err;
64         }
65         return;
66
67 startup_err:
68         tet_infoline(err);
69         tet_delete(POSITIVE_TC_IDX, err);
70         tet_delete(NEGATIVE_TC_IDX, err);
71 }
72
73 static void cleanup(void)
74 {
75         elm_shutdown();
76 }
77
78 /**
79  * @brief Positive test case of ug_create()
80  */
81 static void utc_ApplicationFW_ug_create_func_01(void)
82 {
83         struct ui_gadget *ug;
84         bundle *data = NULL;
85         struct ug_cbs cbs = {0, };
86         data = bundle_create();
87         bundle_add(data, "test", "case");
88
89         ug = ug_create(NULL, TESTUG, UG_MODE_FULLVIEW, data, &cbs);
90         if (!ug) {
91                 tet_infoline("ug_create() failed in positive test case");
92                 tet_result(TET_FAIL);
93                 return;
94         }
95
96         ug = ug_create(NULL, TESTUG, UG_MODE_FRAMEVIEW, data, &cbs);
97         if (!ug) {
98                 tet_infoline("ug_create() failed in positive test case");
99                 tet_result(TET_FAIL);
100                 return;
101         }
102
103         tet_result(TET_PASS);
104 }
105
106 /**
107  * @brief Negative test case of ug_init ug_create()
108  */
109 static void utc_ApplicationFW_ug_create_func_02(void)
110 {
111         struct ui_gadget *ug;
112         bundle *data = NULL;
113         struct ug_cbs cbs = {0, };
114         data = bundle_create();
115         bundle_add(data, "test", "case");
116
117         ug = ug_create(NULL, TESTUG_ERR, -1, data, &cbs);
118         if (ug) {
119                 tet_infoline("ug_create() failed in negative test case");
120                 tet_result(TET_FAIL);
121                 return;
122         }
123
124         ug = ug_create(NULL, TESTUG_ERR, UG_MODE_INVALID, data, &cbs);
125         if (ug) {
126                 tet_infoline("ug_create() failed in negative test case");
127                 tet_result(TET_FAIL);
128                 return;
129         }
130
131         ug = ug_create(NULL, TESTUG_ERR, UG_MODE_MAX, data, &cbs);
132         if (ug) {
133                 tet_infoline("ug_create() failed in negative test case");
134                 tet_result(TET_FAIL);
135                 return;
136         }
137
138         tet_result(TET_PASS);
139 }