Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_action_slider_tc2.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailActionSlider
5  *
6  * Description: Test AtkAction interface
7  * Test input: accessible object representing EailActionSlider
8  *
9  * Expected test result: test should return 0 (success)
10  */
11
12 #include <Elementary.h>
13 #include <atk/atk.h>
14 #include "eail_test_utils.h"
15
16 INIT_TEST("EailActionSlider")
17
18 static void
19 _init_action_slider(Evas_Object *win)
20 {
21    Evas_Object *bg, *bx, *as;
22
23    bg = elm_bg_add(win);
24    elm_win_resize_object_add(win, bg);
25    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, 0);
26    evas_object_show(bg);
27
28    bx = elm_box_add(win);
29    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
30    elm_win_resize_object_add(win, bx);
31    evas_object_show(bx);
32
33    as = elm_actionslider_add(win);
34    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
35    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
36    elm_object_part_text_set(as, "left", "left1");
37    elm_object_part_text_set(as, "center", "center1");
38    elm_object_part_text_set(as, "right", "right1");
39    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
40    evas_object_show(as);
41    elm_box_pack_end(bx, as);
42
43    as = elm_actionslider_add(win);
44    evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
45    evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
46    elm_object_part_text_set(as, "center", "center2");
47    elm_object_part_text_set(as, "right", "right2");
48    elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_CENTER | ELM_ACTIONSLIDER_RIGHT);
49    elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
50    evas_object_show(as);
51    elm_box_pack_end(bx, as);
52 }
53
54 static void
55 _do_test(AtkObject *obj)
56 {
57    guint minimum, maximum, current, minimum_increment;
58    Elm_Actionslider_Pos pos_test_set = ELM_ACTIONSLIDER_CENTER;
59    static int test_count, test_1_count, test_2_count;
60
61    test_count++;
62
63    g_assert(ATK_IS_VALUE(obj));
64
65    GValue value = G_VALUE_INIT;
66    g_value_init(&value, G_TYPE_UINT);
67
68    atk_value_get_minimum_value(ATK_VALUE(obj), &value);
69    minimum = g_value_get_uint(&value);
70
71    atk_value_get_maximum_value(ATK_VALUE(obj), &value);
72    maximum = g_value_get_uint(&value);
73
74    atk_value_get_current_value(ATK_VALUE(obj), &value);
75    current = g_value_get_uint(&value);
76
77    atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
78    minimum_increment = g_value_get_uint(&value);
79
80    g_assert(ELM_ACTIONSLIDER_NONE == minimum);
81    g_assert(ELM_ACTIONSLIDER_NONE == minimum_increment);
82
83    if (ELM_ACTIONSLIDER_LEFT == current)
84      {
85         test_1_count++;
86
87         g_assert(ELM_ACTIONSLIDER_ALL == maximum);
88
89         g_value_set_uint(&value, ELM_ACTIONSLIDER_ALL);
90         g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
91      }
92    else if (ELM_ACTIONSLIDER_RIGHT == current)
93      {
94         test_2_count++;
95
96         g_assert((ELM_ACTIONSLIDER_RIGHT | ELM_ACTIONSLIDER_CENTER) == maximum);
97
98         g_value_set_uint(&value, ELM_ACTIONSLIDER_LEFT);
99         g_assert(!atk_value_set_current_value(ATK_VALUE(obj), &value));
100      }
101    else
102      {
103         _printf("initialized values ​​are different from returned by ATK");
104         g_assert(FALSE);
105      }
106
107    g_value_set_uint(&value, pos_test_set);
108    g_assert(atk_value_set_current_value(ATK_VALUE(obj), &value));
109
110    atk_value_get_current_value(ATK_VALUE(obj), &value);
111    current = g_value_get_uint(&value);
112    g_assert(pos_test_set == current);
113
114    g_assert((test_1_count + test_2_count) == test_count);
115
116    eailu_test_code_called = 1;
117 }
118
119 EAPI_MAIN int
120 elm_main(int argc, char **argv)
121 {
122    Evas_Object *win;
123
124    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
125    g_assert(win);
126    _init_action_slider(win);
127    evas_object_show(win);
128    elm_run();
129    elm_shutdown();
130
131    return 0;
132 }
133 ELM_MAIN()