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