Initialize Tizen 2.3
[framework/uifw/elementary.git] / TC / elm_ts / label / utc_UIFW_elm_label_slide_duration_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         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 static void startup(void);
30 static void cleanup(void);
31
32 void (*tet_startup)(void) = startup;
33 void (*tet_cleanup)(void) = cleanup;
34
35 static void utc_UIFW_elm_label_slide_duration_get_func_01(void);
36 static void utc_UIFW_elm_label_slide_duration_get_func_02(void);
37
38 enum {
39         POSITIVE_TC_IDX = 0x01,
40         NEGATIVE_TC_IDX,
41 };
42
43 struct tet_testlist tet_testlist[] = {
44         { utc_UIFW_elm_label_slide_duration_get_func_01, POSITIVE_TC_IDX },
45         { utc_UIFW_elm_label_slide_duration_get_func_02, NEGATIVE_TC_IDX },
46         { NULL, 0}
47 };
48
49 // Declare the global variables
50 Evas_Object *main_win, *main_bg;
51 Evas_Object *test_win, *test_bg;
52 Evas_Object *test_eo = NULL;
53 // Declare internal functions
54 void _elm_precondition(void);
55 static void _win_del(void *data, Evas_Object *obj, void *event_info);
56
57
58 // Delete main window
59 static void _win_del(void *data, Evas_Object *obj, void *event_info)
60 {
61         elm_exit();
62 }
63
64 // Do precondition.
65 void _elm_precondition(void)
66 {
67         elm_init(0, NULL);
68
69         main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
70         elm_win_title_set(main_win, "Elementary Unit Test Suite");
71         evas_object_smart_callback_add(main_win, "delete,request", _win_del, NULL);
72         main_bg = elm_bg_add(main_win);
73         evas_object_size_hint_weight_set(main_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74         elm_win_resize_object_add(main_win, main_bg);
75         evas_object_show(main_bg);
76
77         // set an initial window size
78         evas_object_resize(main_win, 320, 480);
79         // show the window
80         evas_object_show(main_win);
81
82         //elm_run();
83 }
84
85
86 // Start up function for each test purpose
87 static void
88 startup()
89 {
90         tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");
91
92         // Elm precondition
93         _elm_precondition();
94
95         // Test precondition
96         test_win = elm_win_add(NULL, "Label", ELM_WIN_BASIC);
97         elm_win_title_set(test_win, "Label");
98         elm_win_autodel_set(test_win, 1);
99
100         test_bg = elm_bg_add(test_win);
101         elm_win_resize_object_add(test_win, test_bg);
102         evas_object_size_hint_weight_set(test_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
103         evas_object_show(test_bg);
104
105         evas_object_resize(test_win, 480, 800);
106         evas_object_show(test_win);
107
108         tet_infoline("[[ TET_MSG ]]:: Completing startup");
109 }
110
111 // Clean up function for each test purpose
112 static void
113 cleanup()
114 {
115         tet_infoline("[[ TET_MSG ]]:: ============ Cleanup ============ ");
116
117         // Clean up the used resources.
118         if ( NULL != main_win ) {
119                 evas_object_del(main_win);
120                 main_win = NULL;
121         }
122
123         if ( NULL != main_bg ) {
124                 evas_object_del(main_bg);
125                 main_bg = NULL;
126         }
127
128         if ( NULL != test_win ) {
129                 evas_object_del(test_win);
130                 test_win = NULL;
131         }
132
133         if ( NULL != test_bg ) {
134                 evas_object_del(test_bg);
135                 test_bg = NULL;
136         }
137
138         if ( NULL != test_eo ) {
139                 evas_object_del(test_eo);
140                 test_eo = NULL;
141         }
142
143         // clean up and shut down
144         elm_shutdown(); ;
145
146         tet_infoline("[[ TET_MSG ]]:: ========= TC COMPLETE  ========== ");
147 }
148
149 /**
150  * @brief Positive test case of elm_label_slide_duration_get()
151  */
152 static void utc_UIFW_elm_label_slide_duration_get_func_01(void)
153 {
154    test_eo = elm_label_add(test_win);
155    elm_object_text_set(test_eo, "test string");
156    elm_label_slide_duration_set(test_eo, 10);
157    int r = elm_label_slide_duration_get(test_eo);
158
159    if (!r) {
160         tet_infoline("elm_label_slide_duration_get() failed in positive test case");
161         tet_result(TET_FAIL);
162         return;
163    }
164    tet_result(TET_PASS);
165 }
166
167 /**
168  * @brief Negative test case of ug_init elm_label_slide_duration_get()
169  */
170 static void utc_UIFW_elm_label_slide_duration_get_func_02(void)
171 {
172    test_eo = elm_label_add(test_win);
173    elm_object_text_set(test_eo, NULL);
174    elm_label_slide_duration_set(test_eo, 10);
175    int r = elm_label_slide_duration_get(NULL);
176
177    if(r) {
178         tet_result(TET_FAIL);
179         tet_infoline("elm_label_slide_duration_get() failed in negative test case");
180         return;
181    }
182    tet_result(TET_PASS);
183 }