Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_separator_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailSeparator
5  *
6  * Description: Test whether accessible object is successfully registered
7  *    in GObject type system and is visible in AtkObject tree.
8  *
9  * Test input: accessible object representing EailSeparator
10  *
11  * Expected test result: test should return 0 (success)
12  */
13
14 #include <Elementary.h>
15 #include <atk/atk.h>
16
17 #include "eail_test_utils.h"
18
19 INIT_TEST("EailSeparator")
20
21 static void
22 _init_separator(Evas_Object *win)
23 {
24    Evas_Object *bg, *bxh, *bxv, *spv, *sph, *bt;
25
26    bg = elm_bg_add(win);
27    elm_win_resize_object_add(win, bg);
28    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29    evas_object_show(bg);
30
31    bxh = elm_box_add(win);
32    evas_object_size_hint_weight_set(bxh, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
33    elm_box_horizontal_set(bxh, EINA_TRUE);
34    elm_win_resize_object_add(win, bxh);
35    evas_object_show(bxh);
36
37    bxv = elm_box_add(win);
38    evas_object_size_hint_weight_set(bxv, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
39    elm_box_pack_end(bxh, bxv);
40    evas_object_show(bxv);
41
42    // horizontal separator
43    bt = elm_button_add(win);
44    elm_object_text_set(bt, "Top button");
45    elm_box_pack_end(bxv, bt);
46    evas_object_show(bt);
47
48    sph = elm_separator_add(win);
49    elm_separator_horizontal_set(sph, EINA_TRUE);
50    elm_box_pack_end(bxv, sph);
51    evas_object_show(sph);
52
53    bt = elm_button_add(win);
54    elm_object_text_set(bt, "Bottom button");
55    elm_box_pack_end(bxv, bt);
56    evas_object_show(bt);
57
58    // vertical separator
59    bt = elm_button_add(win);
60    elm_object_text_set(bt, "Left button");
61    elm_box_pack_end(bxh, bt);
62    evas_object_show(bt);
63
64    spv = elm_separator_add(win);
65    elm_box_pack_end(bxh, spv);
66    evas_object_show(spv);
67
68    bt = elm_button_add(win);
69    elm_object_text_set(bt, "Right button");
70    elm_box_pack_end(bxh, bt);
71    evas_object_show(bt);
72 }
73
74 static void
75 _do_test(AtkObject *obj)
76 {
77    AtkStateSet *state_set = atk_object_ref_state_set(obj);
78    static int test_count, test_vertical_count, test_horizontal_count;
79
80    test_count++;
81
82    g_assert(atk_object_get_role(obj) == ATK_ROLE_SEPARATOR);
83    g_assert(!atk_state_set_is_empty(state_set));
84    atk_object_set_description(obj, "test");
85    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
86
87    atk_object_set_name(obj, "test name");
88    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
89
90    if (atk_state_set_contains_state(state_set, ATK_STATE_VERTICAL))
91      {
92         test_vertical_count++;
93         _printf("atk_object_ref_state_set: vertical\n");
94      }
95
96    if (atk_state_set_contains_state(state_set, ATK_STATE_HORIZONTAL))
97      {
98         test_horizontal_count++;
99         _printf("atk_object_ref_state_set: horizontal\n");
100      }
101
102    g_assert((test_vertical_count + test_horizontal_count) == test_count);
103
104    if (2 == test_count)
105      g_assert(1 == test_vertical_count && 1 == test_horizontal_count);
106
107    eailu_test_code_called = 1;
108 }
109
110 EAPI_MAIN int
111 elm_main(int argc, char **argv)
112 {
113    Evas_Object *win;
114
115    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
116    _init_separator(win);
117
118    evas_object_show(win);
119    elm_run();
120    elm_shutdown();
121
122    return 0;
123 }
124 ELM_MAIN()