[elm_genlist] add TC
[framework/uifw/elementary.git] / TC / elm_ts / genlist / utc_UIFW_elm_genlist_last_item_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
30 Evas_Object *main_win, *genlist;
31 Elm_Genlist_Item_Class itc;
32
33 static void startup(void);
34 static void cleanup(void);
35
36 void (*tet_startup)(void) = startup;
37 void (*tet_cleanup)(void) = cleanup;
38
39 static void utc_UIFW_elm_genlist_last_item_get_func_01(void);
40 static void utc_UIFW_elm_genlist_last_item_get_func_02(void);
41
42 enum {
43         POSITIVE_TC_IDX = 0x01,
44         NEGATIVE_TC_IDX,
45 };
46
47 struct tet_testlist tet_testlist[] = {
48         { utc_UIFW_elm_genlist_last_item_get_func_01, POSITIVE_TC_IDX },
49         { utc_UIFW_elm_genlist_last_item_get_func_02, NEGATIVE_TC_IDX },
50 };
51
52 static void startup(void)
53 {
54         tet_infoline("[[ TET_MSG ]]:: ============ Startup ============ ");
55         elm_init(0, NULL);
56         main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
57         evas_object_show(main_win);     
58         genlist = elm_genlist_add(main_win);
59         evas_object_show(genlist);
60         elm_win_resize_object_add(main_win, genlist);
61         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
62         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63         itc.item_style = "1line_textonly";
64         itc.func.label_get = NULL;
65         itc.func.icon_get = NULL;
66         itc.func.state_get = NULL;
67         itc.func.del = NULL;
68 }
69
70 static void cleanup(void)
71 {
72         if ( NULL != main_win ) {
73                 evas_object_del(main_win);
74                 main_win = NULL;
75         }
76         elm_shutdown();
77         tet_infoline("[[ TET_MSG ]]:: ============ Cleanup ============ ");
78 }
79
80 /**
81  * @brief Positive test case of elm_genlist_last_item_get()
82  */
83 static void utc_UIFW_elm_genlist_last_item_get_func_01(void)
84 {
85    Elm_Genlist_Item *item = NULL, *result_item = NULL;
86
87    item = elm_genlist_item_append(genlist, &itc, (void *) 0, NULL,
88                         ELM_GENLIST_ITEM_NONE, NULL, NULL);   
89    
90         result_item = elm_genlist_last_item_get(genlist);
91
92         if (!result_item) {
93                 tet_infoline("elm_genlist_last_item_get() failed in positive test case");
94                 tet_result(TET_FAIL);
95                 return;
96         }
97         tet_result(TET_PASS);
98 }
99
100 /**
101  * @brief Negative test case of ug_init elm_genlist_last_item_get()
102  */
103 static void utc_UIFW_elm_genlist_last_item_get_func_02(void)
104 {
105    Elm_Genlist_Item *item = NULL, *result_item = NULL;
106
107    item = elm_genlist_item_append(genlist, &itc, (void *) 0, NULL,
108                         ELM_GENLIST_ITEM_NONE, NULL, NULL);   
109    
110         result_item = elm_genlist_last_item_get(NULL);
111
112         if (result_item) {
113                 tet_infoline("elm_genlist_last_item_get() failed in negative test case");
114                 tet_result(TET_FAIL);
115                 return;
116         }
117         tet_result(TET_PASS);
118 }