Issues deteced by Static Code Analysis fixed
[platform/core/uifw/eail.git] / eail / tests / eail_button_tc3.c
1 /*
2  * Tested interface: AtkImage
3  *
4  * Tested AtkObject: EailButton
5  *
6  * Description: Test AtkImage interface
7  *
8  * Test input: accessible object representing EailButton
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 #define BUTTON_TEXT2   "button2"
19
20 #define ICON_SIZE 56
21
22 INIT_TEST("EailButton")
23
24 static void
25 _do_test(AtkObject *obj)
26 {
27    const char *type_name_child;
28    int height = 0, width = 0;
29    int x = -1, y = -1;
30    AtkObject *xobj;
31
32    g_assert(ATK_IS_IMAGE(obj));
33
34    _printf("Button test: %s\n", BUTTON_TEXT2);
35    // test children
36    g_assert(1 == atk_object_get_n_accessible_children(obj));
37
38    xobj = atk_object_ref_accessible_child(obj, 0);
39    g_assert(NULL != xobj);
40    type_name_child = g_type_name(G_TYPE_FROM_INSTANCE(xobj));
41    _printf("type_name_child: %s\n", type_name_child);
42    g_assert_cmpstr(type_name_child, ==, "EailIcon");
43
44    // test AtkImage
45    atk_image_get_image_position(ATK_IMAGE(obj), &x, &y, ATK_XY_SCREEN);
46    _printf("atk_image_get_image_position on screen: x: %d y %d\n", x, y);
47
48    atk_image_get_image_size(ATK_IMAGE(obj), &height, &width);
49    _printf("atk_image_get_image_size: height %d width %d\n", height, width);
50    g_assert(ICON_SIZE == height && ICON_SIZE == width);
51
52    eailu_test_code_called = 1;
53 }
54
55 static void
56 _init_button(Evas_Object *win)
57 {
58    Evas_Object *bg, *icon, *button2;
59
60    bg = elm_bg_add(win);
61    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62    elm_win_resize_object_add(win, bg);
63    evas_object_show(bg);
64
65    icon = elm_icon_add(win);
66    elm_icon_order_lookup_set(icon, ELM_ICON_LOOKUP_THEME_FDO);
67    elm_icon_standard_set(icon, "home");
68    evas_object_show(icon);
69
70    button2 = elm_button_add(win);
71    elm_object_text_set(button2, BUTTON_TEXT2);
72    elm_object_part_content_set(button2, "icon", icon);
73    evas_object_resize(button2, 140, 60);
74    evas_object_show(button2);
75 }
76
77 EAPI_MAIN int
78 elm_main(int argc, char **argv)
79 {
80    Evas_Object *win;
81
82    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
83    _init_button(win);
84    evas_object_show(win);
85    elm_run();
86    elm_shutdown();
87
88    return 0;
89 }
90 ELM_MAIN()