Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_custom_widgets_tc1.c
1 /*
2  * Tested interface:
3  *
4  * Tested AtkObject:
5  *
6  * Description:
7  *
8  * Test input:
9  *
10  * Expected test result:
11  */
12
13 #include <Elementary.h>
14 #include <atk/atk.h>
15
16 #include "eail_custom_widget.h"
17 #include "eail_factory.h"
18 #include "eail_widget.h"
19 #include "eail_test_utils.h"
20
21 INIT_TEST("EailCustomWidget")
22
23 static void
24 _init_custom_widget(Evas_Object *win)
25 {
26    Evas_Object *bg, *rectangle;
27    AtkObject *ao, *wgt;
28
29    bg = elm_bg_add(win);
30    if(!bg) return;
31    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
32    elm_win_resize_object_add(win, bg);
33    evas_object_show(bg);
34
35    Evas_Object *label = elm_label_add(win);
36    if(!label) return;
37    elm_object_text_set(label, "This is the CONTENT");
38    evas_object_show(label);
39
40    rectangle = evas_object_rectangle_add(evas_object_evas_get(win));
41    evas_object_resize(rectangle, 10, 10);
42    evas_object_show(rectangle);
43
44    ao = eail_custom_widget_create(rectangle);
45
46    g_assert(ao);
47
48    wgt = eail_factory_get_accessible(label);
49    eail_widget_add_custom_widget_child(wgt, ao);
50
51    g_assert(1 == atk_object_get_n_accessible_children(wgt));
52    g_assert(wgt == atk_object_get_parent(ao));
53
54    g_assert(0 == atk_object_get_index_in_parent(ao));
55
56    evas_object_del(rectangle);
57
58    g_assert(0 == atk_object_get_n_accessible_children(wgt));
59
60 }
61
62 static void
63 _do_test(AtkObject *obj)
64 {
65    eailu_test_code_called = 1;
66 }
67
68 EAPI_MAIN int
69 elm_main(int argc, char **argv)
70 {
71    Evas_Object *win;
72
73    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
74    g_assert(win);
75    _init_custom_widget(win);
76    evas_object_show(win);
77    elm_run();
78    elm_shutdown();
79
80    return 0;
81 }
82 ELM_MAIN()
83