Tizen release 1.0
[pkgs/u/ui-gadget.git] / TC / unit / utc_ApplicationFW_ug_create_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.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 }