[Refactoring] Removed trailing whitespaces.
[framework/uifw/elementary.git] / TC / elm_ts / controlbar / utc_UIFW_elm_controlbar_item_select_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         Evas_Object *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 // For checking the result of the negative test case.
18 #define TET_CHECK_FAIL(x1, y...) \
19 { \
20         Evas_Object *err = y; \
21         if (err != (x1)) \
22                 { \
23                         tet_printf("[TET_CHECK_FAIL]:: %s[%d] : Test has failed..", __FILE__,__LINE__); \
24                         tet_result(TET_FAIL); \
25                         return; \
26                 } \
27 }
28
29
30 Evas_Object *main_win;
31 Evas_Object *controlbar;
32 Evas_Object *button;
33 Elm_Controlbar_Item *item1;
34 Elm_Controlbar_Item *item2;
35 Elm_Controlbar_Item *item3;
36
37 static void startup(void);
38 static void cleanup(void);
39
40 void (*tet_startup)(void) = startup;
41 void (*tet_cleanup)(void) = cleanup;
42
43 static void utc_UIFW_elm_controlbar_item_select_func_01(void);
44 static void utc_UIFW_elm_controlbar_item_select_func_02(void);
45
46 enum {
47         POSITIVE_TC_IDX = 0x01,
48         NEGATIVE_TC_IDX,
49 };
50
51 struct tet_testlist tet_testlist[] = {
52         { utc_UIFW_elm_controlbar_item_select_func_01, POSITIVE_TC_IDX },
53         { utc_UIFW_elm_controlbar_item_select_func_02, NEGATIVE_TC_IDX },
54         { NULL, 0 }
55 };
56
57 static void startup(void)
58 {
59         tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");
60         elm_init(0, NULL);
61         main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
62         evas_object_show(main_win);
63
64         controlbar = elm_controlbar_add(main_win);
65         item1 = elm_controlbar_tab_item_append(controlbar, NULL, "Controlbar", NULL);
66         item2 = elm_controlbar_tool_item_append(controlbar, NULL, "Controlbar", NULL, NULL);
67         button = elm_button_add(controlbar);
68         elm_button_label_set(button, "button");
69         item3 = elm_controlbar_object_item_append(controlbar, button, 3);
70 }
71
72 static void cleanup(void)
73 {
74         if ( NULL != main_win ) {
75                 evas_object_del(main_win);
76                 main_win = NULL;
77         }
78         elm_shutdown();
79         tet_infoline("[[ TET_MSG ]]:: ============ Cleanup ============ ");
80
81         evas_object_del(controlbar);
82         evas_object_del(button);
83 }
84
85 /**
86  * @brief Positive test case of elm_controlbar_item_select()
87  */
88 static void utc_UIFW_elm_controlbar_item_select_func_01(void)
89 {
90         Elm_Controlbar_Item *item;
91
92         elm_controlbar_item_select(item1);
93         item = elm_controlbar_selected_item_get(controlbar);
94
95         if (item != item1) {
96                 tet_infoline("elm_controlbar_item_select() failed in positive test case");
97                 tet_result(TET_FAIL);
98                 return;
99         }
100         tet_result(TET_PASS);
101 }
102
103 /**
104  * @brief Negative test case of ug_init elm_controlbar_item_select()
105  */
106 static void utc_UIFW_elm_controlbar_item_select_func_02(void)
107 {
108         Elm_Controlbar_Item *item;
109
110         elm_controlbar_item_select(item2);
111         item = elm_controlbar_selected_item_get(controlbar);
112
113         if (item == item2) {
114                 tet_infoline("elm_controlbar_item_select() failed in negative test case");
115                 tet_result(TET_FAIL);
116                 return;
117         }
118
119         elm_controlbar_item_select(item3);
120         item = elm_controlbar_selected_item_get(controlbar);
121
122         if (item == item3) {
123                 tet_infoline("elm_controlbar_item_select() failed in negative test case");
124                 tet_result(TET_FAIL);
125                 return;
126         }
127
128         tet_result(TET_PASS);
129 }