Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_button_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailButton
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 EailButton
10  *
11  * Expected test result: test should return 0 (success)
12  */
13
14 #include <Elementary.h>
15 #include <atk/atk.h>
16 #include "eail_test_utils.h"
17
18 #define BUTTON_TEXT1 "Button1"
19
20 INIT_TEST("EailButton")
21
22 void button_focus_cb(AtkObject *obj, gboolean b)
23 {
24    printf("aaa");
25    g_assert_cmpstr(atk_object_get_name(obj), ==, BUTTON_TEXT1"1");
26 }
27
28 static void
29 _do_test(AtkObject *obj)
30 {
31    int handler_id;
32
33    g_assert(ATK_IS_OBJECT(obj));
34    g_assert(atk_object_get_role(obj) == ATK_ROLE_PUSH_BUTTON);
35    g_assert_cmpstr(atk_object_get_name(obj), ==, BUTTON_TEXT1);
36    atk_object_set_name(obj, BUTTON_TEXT1"test");
37    g_assert_cmpstr(atk_object_get_name(obj), ==, BUTTON_TEXT1"test");
38
39    handler_id = atk_component_add_focus_handler(ATK_COMPONENT(obj),
40                                                 button_focus_cb);
41    g_assert(handler_id != 0);
42
43    handler_id = atk_component_add_focus_handler(ATK_COMPONENT(obj),
44                                                 button_focus_cb);
45    g_assert(handler_id == 0);
46
47    g_assert(atk_component_grab_focus(ATK_COMPONENT(obj)));
48    atk_component_remove_focus_handler(ATK_COMPONENT(obj), handler_id);
49
50    eailu_test_code_called = 1;
51 }
52
53 static void
54 _init_button(Evas_Object *win)
55 {
56    Evas_Object *bg, *button1;
57
58    bg = elm_bg_add(win);
59    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60    elm_win_resize_object_add(win, bg);
61    evas_object_show(bg);
62
63    button1 = elm_button_add(win);
64    elm_object_text_set(button1, BUTTON_TEXT1);
65
66    evas_object_resize(button1, 140, 60);
67    evas_object_move(button1, 50, 20);
68    evas_object_show(button1);
69 }
70
71 EAPI_MAIN int
72 elm_main(int argc, char **argv)
73 {
74    Evas_Object *win;
75
76    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
77    _init_button(win);
78    evas_object_show(win);
79
80    elm_run();
81    elm_shutdown();
82
83    return 0;
84 }
85 ELM_MAIN()