Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_bubble_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailBubble
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailBubble
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("EailBubble")
19
20 static void
21 _init_bubble(Evas_Object *win)
22 {
23    Evas_Object *bg, *label, *icon, *bubble;
24
25    bg = elm_bg_add(win);
26    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27    elm_win_resize_object_add(win, bg);
28    evas_object_show(bg);
29
30    label = elm_label_add(win);
31    elm_object_text_set(label, "This is the CONTENT of our bubble");
32    evas_object_show(label);
33
34    icon = elm_icon_add(win);
35    elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_THEME_FDO);
36    elm_icon_standard_set(icon, "home");
37    evas_object_show(icon);
38
39    bubble = elm_bubble_add(win);
40    elm_object_part_content_set(bubble, "icon", icon);
41    elm_object_part_text_set(bubble, "info", "INFO");
42    elm_object_text_set(bubble, "LABEL");
43    elm_object_content_set(bubble, label);
44    evas_object_resize(bubble, 300, 100);
45    evas_object_show(bubble);
46 }
47
48 static void
49 _do_test(AtkObject *obj)
50 {
51    const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj));
52    const char *type_name_child;
53    AtkObject *xobj;
54
55    g_assert(ATK_IS_OBJECT(obj));
56
57    atk_object_set_description(obj, "test");
58    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
59    atk_object_set_name(obj, "test name");
60    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
61
62    g_assert(atk_object_get_role(obj) == ATK_ROLE_FILLER);
63
64    g_assert_cmpstr(type_name, ==, "EailBubble");
65
66    // test children
67    g_assert(2 == atk_object_get_n_accessible_children(obj));
68
69    for (int count = 0; 2 > count; count++)
70      {
71         xobj = atk_object_ref_accessible_child(obj, count);
72         g_assert(xobj);
73         type_name_child = g_type_name(G_TYPE_FROM_INSTANCE(xobj));
74         _printf(" child num: %d, type_name: %s\n", count, type_name_child);
75         g_assert(!strcmp(type_name_child, "EailIcon") || !strcmp(type_name_child, "EailLabel"));
76      }
77
78    /* bubble object does not support focus */
79    eailu_test_atk_focus(obj, FALSE);
80
81    eailu_test_code_called = 1;
82 }
83
84 EAPI_MAIN int
85 elm_main(int argc, char **argv)
86 {
87    Evas_Object *win;
88
89    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
90    g_assert(win);
91    _init_bubble(win);
92    evas_object_show(win);
93    elm_run();
94    elm_shutdown();
95
96    return 0;
97 }
98 ELM_MAIN()