edccd06ed5e2e802d4d4c7d4b8bd9ba616680f05
[framework/uifw/elementary.git] / TC / elm_ts / navigationbar / utc_UIFW_elm_navigationbar_title_button_get_func.c
1 #include <tet_api.h>
2 #include <Elementary.h>
3 #define ICON_DIR "usr/share/beat_winset_test/icon"
4
5 // Definitions
6 // For checking the result of the positive test case.
7 #define TET_CHECK_PASS(x1, y...) \
8 { \
9         Evas_Object *err = y; \
10         if (err == (x1)) \
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         Evas_Object *err = y; \
22         if (err != (x1)) \
23                 { \
24                         tet_printf("[TET_CHECK_FAIL]:: %s[%d] : Test has failed..", __FILE__,__LINE__); \
25                         tet_result(TET_FAIL); \
26                         return; \
27                 } \
28 }
29
30
31 Evas_Object *main_win, *navibar;
32 char buf[4096];
33
34
35 static void startup(void);
36 static void cleanup(void);
37
38 void (*tet_startup)(void) = startup;
39 void (*tet_cleanup)(void) = cleanup;
40
41 static void utc_UIFW_elm_navigationbar_title_button_get_func_01(void);
42 static void utc_UIFW_elm_navigationbar_title_button_get_func_02(void);
43
44 enum {
45         POSITIVE_TC_IDX = 0x01,
46         NEGATIVE_TC_IDX,
47 };
48
49 struct tet_testlist tet_testlist[] = {
50         { utc_UIFW_elm_navigationbar_title_button_get_func_01, POSITIVE_TC_IDX },
51         { utc_UIFW_elm_navigationbar_title_button_get_func_02, NEGATIVE_TC_IDX },
52         { NULL, 0 }
53 };
54
55 static void startup(void)
56 {
57         tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");
58         elm_init(0, NULL);
59         main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
60         evas_object_show(main_win);
61         navibar = elm_navigationbar_add(main_win);
62         evas_object_show(navibar);
63 }
64
65 static void cleanup(void)
66 {
67         if ( NULL != navibar ) {
68                 evas_object_del(navibar);
69                 navibar = NULL;
70         }
71         if ( NULL != main_win ) {
72                 evas_object_del(main_win);
73                 main_win = NULL;
74         }
75         elm_shutdown();
76         tet_infoline("[[ TET_MSG ]]:: ============ Cleanup ============ ");
77 }
78
79 /**
80  * @brief Positive test case of elm_navigationbar_title_button_get()
81  */
82 static void utc_UIFW_elm_navigationbar_title_button_get_func_01(void)
83 {
84         Evas_Object *content = elm_icon_add(navibar);
85         snprintf(buf, sizeof(buf), "%s/00_volume_icon.png", ICON_DIR);
86         elm_icon_file_set(content, buf, NULL);
87         evas_object_size_hint_aspect_set(content, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
88         elm_icon_scale_set(content, 1, 1);
89
90         Evas_Object *button = elm_button_add(navibar);
91         elm_button_label_set(button, "next");
92
93         elm_navigationbar_push(navibar, "title", NULL, NULL, NULL, content);
94         elm_navigationbar_title_button_set(navibar, content, button, ELM_NAVIGATIONBAR_FUNCTION_BUTTON1);
95         Evas_Object *btn = elm_navigationbar_title_button_get(navibar, content, ELM_NAVIGATIONBAR_FUNCTION_BUTTON1);
96         if (!btn) {
97                 tet_infoline("elm_navigationbar_title_button_get() failed in positive test case");
98                 tet_result(TET_FAIL);
99                 return;
100         }
101         tet_result(TET_PASS);
102 }
103
104 /**
105  * @brief Negative test case of ug_init elm_navigationbar_title_button_get()
106  */
107 static void utc_UIFW_elm_navigationbar_title_button_get_func_02(void)
108 {
109         Evas_Object *content = elm_icon_add(navibar);
110         snprintf(buf, sizeof(buf), "%s/00_volume_icon.png", ICON_DIR);
111         elm_icon_file_set(content, buf, NULL);
112         evas_object_size_hint_aspect_set(content, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
113         elm_icon_scale_set(content, 1, 1);
114
115         Evas_Object *button = elm_button_add(navibar);
116         elm_button_label_set(button, "next");
117
118         elm_navigationbar_push(navibar, "title", NULL, NULL, NULL, content);
119         Evas_Object *btn = elm_navigationbar_title_button_get(NULL, content, ELM_NAVIGATIONBAR_FUNCTION_BUTTON1);
120         if (btn) {
121                 tet_infoline("elm_navigationbar_title_button_get() failed in negative test case");
122                 tet_result(TET_FAIL);
123                 return;
124         }
125         tet_result(TET_PASS);
126 }