Initialize Tizen 2.3
[framework/uifw/elementary.git] / wearable / TC / elm_ts / multibuttonentry / utc_UIFW_elm_multibuttonentry_label_get_func.c
1 #include <tet_api.h>
2 #include <Elementary.h>
3
4 // Definitions
5 // For checking the result of the positive test case.
6 #define TET_CHECK_PASS(x1, y...) \
7 { \
8         const char *err = y; \
9         if (err == (x1)) \
10                 { \
11                         tet_printf("[TET_CHECK_PASS]:: %s[%d] : Test has failed..", __FILE__,__LINE__); \
12                         tet_result(TET_FAIL); \
13                         return; \
14                 } \
15 }
16
17 #define TET_CHECK_STRING_PASS(x, y)\
18 {\
19         if (x == NULL || y == NULL)\
20         {\
21                 tet_printf("[TET_CHECK_STRING_PASS]:: %s[%d] : Test has failed..", __FILE__,__LINE__);\
22                 tet_printf("[TET_CHECK_STRING_PASS]:: Test string is NULL");\
23                 tet_result(TET_FAIL);\
24                 return;\
25         }\
26         if (strcmp(x, y))\
27         {\
28                 tet_printf("[TET_CHECK_STRING_PASS]:: %s[%d] : Test has failed..", __FILE__,__LINE__);\
29                 tet_result(TET_FAIL);\
30                 return;\
31         }\
32 }
33
34
35 // For checking the result of the negative test case.
36 #define TET_CHECK_FAIL(x1, y...) \
37 { \
38         const char *err = y; \
39         if (err != (x1)) \
40                 { \
41                         tet_printf("[TET_CHECK_FAIL]:: %s[%d] : Test has failed..", __FILE__,__LINE__); \
42                         tet_result(TET_FAIL); \
43                         return; \
44                 } \
45 }
46
47 #define TET_CHECK_STRING_FAIL(x, y)\
48 {\
49         if (x == NULL || y == NULL)\
50                 return;\
51         if (strcmp(x, y) == 0)\
52         {\
53                 tet_printf("[TET_CHECK_STRING_FAIL]:: %s[%d] : Test has failed..", __FILE__,__LINE__); \
54                 tet_result(TET_FAIL);\
55                 return;\
56         }\
57 }
58
59 Evas_Object *main_win;
60
61 static void startup(void);
62 static void cleanup(void);
63
64 void (*tet_startup)(void) = startup;
65 void (*tet_cleanup)(void) = cleanup;
66
67 static void utc_UIFW_elm_multibuttonentry_label_get_func_01(void);
68 static void utc_UIFW_elm_multibuttonentry_label_get_func_02(void);
69
70 enum {
71         POSITIVE_TC_IDX = 0x01,
72         NEGATIVE_TC_IDX,
73 };
74
75 struct tet_testlist tet_testlist[] = {
76         { utc_UIFW_elm_multibuttonentry_label_get_func_01, POSITIVE_TC_IDX },
77         { utc_UIFW_elm_multibuttonentry_label_get_func_02, NEGATIVE_TC_IDX },
78         { NULL, 0 }
79 };
80
81 // Declare the global variables
82 Evas_Object *main_win, *main_bg;
83 Evas_Object *test_win, *test_bg;
84 Evas_Object *test_eo = NULL;
85 // Declare internal functions
86 void _elm_precondition(void);
87 static void _win_del(void *data, Evas_Object *obj, void *event_info);
88
89
90 // Delete main window
91 static void _win_del(void *data, Evas_Object *obj, void *event_info)
92 {
93         elm_exit();
94 }
95
96 // Do precondition.
97 void _elm_precondition(void)
98 {
99         elm_init(0, NULL);
100
101         main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
102         elm_win_title_set(main_win, "Elementary Unit Test Suite");
103         evas_object_smart_callback_add(main_win, "delete,request", _win_del, NULL);
104         main_bg = elm_bg_add(main_win);
105         evas_object_size_hint_weight_set(main_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
106         elm_win_resize_object_add(main_win, main_bg);
107         evas_object_show(main_bg);
108
109         // set an initial window size
110         evas_object_resize(main_win, 320, 480);
111         // show the window
112         evas_object_show(main_win);
113
114         //elm_run();
115 }
116
117 // Start up function for each test purpose
118 static void
119 startup()
120 {
121         tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");
122
123         // Elm precondition
124         _elm_precondition();
125
126         // Test precondition
127         test_win = elm_win_add(NULL, "Multi Button Entry", ELM_WIN_BASIC);
128         elm_win_title_set(test_win, "Multi Button Entry");
129         elm_win_autodel_set(test_win, 1);
130
131         test_bg = elm_bg_add(test_win);
132         elm_win_resize_object_add(test_win, test_bg);
133         evas_object_size_hint_weight_set(test_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134         evas_object_show(test_bg);
135
136         evas_object_resize(test_win, 480, 800);
137         evas_object_show(test_win);
138
139         tet_infoline("[[ TET_MSG ]]:: Completing startup");
140 }
141
142 // Clean up function for each test purpose
143 static void
144 cleanup()
145 {
146         tet_infoline("[[ TET_MSG ]]:: ============ Cleanup ============ ");
147
148         // Clean up the used resources.
149         if ( NULL != main_win ) {
150                 evas_object_del(main_win);
151                 main_win = NULL;
152         }
153
154         if ( NULL != main_bg ) {
155                 evas_object_del(main_bg);
156                 main_bg = NULL;
157         }
158
159         if ( NULL != test_win ) {
160                 evas_object_del(test_win);
161                 test_win = NULL;
162         }
163
164         if ( NULL != test_bg ) {
165                 evas_object_del(test_bg);
166                 test_bg = NULL;
167         }
168
169         if ( NULL != test_eo ) {
170                 evas_object_del(test_eo);
171                 test_eo = NULL;
172         }
173
174         // clean up and shut down
175         elm_shutdown(); ;
176
177         tet_infoline("[[ TET_MSG ]]:: ========= TC COMPLETE  ========== ");
178 }
179
180 /**
181  * @brief Positive test case of elm_multibuttonentry_label_get()
182  */
183 static void utc_UIFW_elm_multibuttonentry_label_get_func_01(void)
184 {
185         const char *ret_str = NULL;
186
187         test_eo = elm_multibuttonentry_add(test_win);
188         elm_multibuttonentry_label_set(test_eo, "test");
189         ret_str = elm_multibuttonentry_label_get(test_eo);
190         TET_CHECK_STRING_PASS("test", ret_str);
191
192         tet_result(TET_PASS);
193         tet_infoline("[[ TET_MSG ]]::[ID]:TC_01, [TYPE]: Positive, [RESULT]:PASS, elm_multibuttonentry_label_get().");
194 }
195
196
197
198 /**
199  * @brief Negative test case of ug_init elm_multibuttonentry_label_get()
200  */
201 static void utc_UIFW_elm_multibuttonentry_label_get_func_02(void)
202 {
203         const char *ret_str = NULL;
204
205         test_eo = elm_multibuttonentry_add(test_win);
206         elm_multibuttonentry_label_set(test_eo, "test");
207         elm_multibuttonentry_label_set(test_eo, NULL);
208         ret_str = elm_multibuttonentry_label_get(test_eo);
209         TET_CHECK_STRING_FAIL("test", ret_str);
210
211         tet_result(TET_PASS);
212         tet_infoline("[[ TET_MSG ]]::[ID]:TC_02, [TYPE]: Negative, [RESULT]:PASS, elm_multibuttonentry_label_get().");
213 }
214
215