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