Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_colorselector_tc2.c
1 /*
2  * Tested interface: AtkValue
3  *
4  * Tested AtkObject: EailColorselector
5  *
6  * Description: Test AtkValue interface
7  *
8  * Test input: accessible object representing EailColorselector
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13 #include <Elementary.h>
14 #include <atk/atk.h>
15
16 #include "eail_test_utils.h"
17
18 INIT_TEST("EailColorselector")
19
20 static void
21 _init_colorselector(Evas_Object *obj)
22 {
23    Evas_Object *bx = NULL;
24    Evas_Object *cs = NULL;
25    Evas_Object *fr = NULL;
26
27    bx = elm_box_add(obj);
28    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
30    elm_win_resize_object_add(obj, bx);
31    evas_object_show(bx);
32
33    fr = elm_frame_add(obj);
34    evas_object_size_hint_weight_set(fr, 1.0, 0.5);
35    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
36    elm_object_text_set(fr, "Color Selector");
37    elm_box_pack_end(bx, fr);
38    evas_object_show(fr);
39
40    cs = elm_colorselector_add(obj);
41    elm_colorselector_palette_name_set(cs, "painting");
42    evas_object_size_hint_weight_set(cs, EVAS_HINT_EXPAND, 0.0);
43    evas_object_size_hint_align_set(cs, EVAS_HINT_FILL, 0.0);
44    elm_colorselector_color_set(cs, 100, 100, 100, 133);
45    evas_object_show(cs);
46    elm_object_content_set(fr, cs);
47
48    evas_object_resize(obj, 320, 480);
49 }
50
51 static void
52 _get_rgba(const GValue *color, int *r, int *g, int *b, int *a)
53 {
54    int col = g_value_get_int(color);
55    *a = (0xFF000000 & (guint)col) >> 24;
56    *r = (0x00FF0000 & col) >> 16;
57    *g = (0x0000FF00 & col) >> 8;
58    *b = 0x000000FF & col;
59 }
60
61 static void
62 _set_rgba(GValue *color, int r, int g, int b, int a)
63 {
64    int col = (a << 24) | (r << 16) | (g << 8) | b;
65    g_value_set_int(color, col);
66 }
67
68 static void
69 _do_test(AtkObject *obj)
70 {
71    gint r = 0;
72    gint g = 0;
73    gint b = 0;
74    gint a = 0;
75    GValue value = G_VALUE_INIT;
76
77    g_assert(ATK_IS_VALUE(obj));
78
79    atk_value_get_current_value(ATK_VALUE(obj), &value);
80    _get_rgba(&value, &r, &g, &b, &a);
81    g_assert(r == 100 && g == 100 && b == 100 && a == 133);
82
83    atk_value_get_maximum_value(ATK_VALUE(obj), &value);
84    _get_rgba(&value, &r, &g, &b, &a);
85    g_assert(r == 255 && g == 255 && b == 255 && a == 255);
86
87    _set_rgba(&value, 77, 88, 10, 180);
88    g_assert(atk_value_set_current_value(ATK_VALUE(obj), &value));
89    atk_value_get_current_value(ATK_VALUE(obj), &value);
90    _get_rgba(&value, &r, &g, &b, &a);
91    g_assert(r == 77 && g == 88 && b == 10 && a == 180);
92
93    atk_value_get_minimum_value(ATK_VALUE(obj), &value);
94    _get_rgba(&value, &r, &g, &b, &a);
95    g_assert(r == 0 && g == 0 && b == 0 && a == 0);
96
97    atk_value_get_minimum_increment(ATK_VALUE(obj), &value);
98    _get_rgba(&value, &r, &g, &b, &a);
99    g_assert(r == 1 && g == 1 && b == 1 && a == 1);
100
101    eailu_test_atk_focus(obj, TRUE);
102
103    eailu_test_code_called = 1;
104 }
105
106 EAPI_MAIN int
107 elm_main(int argc, char **argv)
108 {
109    Evas_Object *win = NULL;
110
111    win = eailu_create_test_window_with_glib_init(NULL, _on_focus_in);
112    _init_colorselector(win);
113    evas_object_show(win);
114    elm_run();
115    elm_shutdown();
116
117    return 0;
118 }
119 ELM_MAIN()
120