Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_background_tc1.c
1 /*
2  * Tested interface: AtkObject
3  *
4  * Tested AtkObject: EailBackground
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailBackground
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13 #include <Elementary.h>
14 #include <Ecore_X.h>
15 #include <atk/atk.h>
16
17 #include "eail_test_utils.h"
18
19 #define TEST_STR "bg-test"
20 #define IMG_PATH "./data/08.jpg"
21 #define X 50
22 #define Y 60
23 #define WIDTH 320
24 #define HEIGHT 280
25
26 INIT_TEST("EailBackground")
27
28 static void
29 _do_test(AtkObject *obj)
30 {
31    AtkAttributeSet *attr_set, *node;
32    AtkAttribute *p;
33
34    g_assert(ATK_IS_OBJECT(obj));
35    atk_object_set_description(obj, "test");
36    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
37    g_assert(atk_object_get_role(obj) == ATK_ROLE_IMAGE);
38
39    atk_object_set_name(obj, "test name");
40    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
41
42    attr_set = atk_object_get_attributes(obj);
43    g_assert(g_slist_length(attr_set) == 3);
44
45    node = g_slist_nth(attr_set, 0);
46    p = (AtkAttribute *)node->data;
47    g_assert_cmpstr(p->name, ==, "type");
48    g_assert_cmpstr(p->value, ==, "elm_bg");
49
50    node = g_slist_next(node);
51    p = (AtkAttribute *)node->data;
52    g_assert_cmpstr(p->name, ==, "file");
53    g_assert_cmpstr(p->value, ==, IMG_PATH);
54
55    node = g_slist_next(node);
56    p = (AtkAttribute *)node->data;
57    g_assert_cmpstr(p->name, ==, "display mode");
58    g_assert_cmpstr(p->value, ==, "stretch");
59
60    g_slist_free(attr_set);
61
62    eailu_test_code_called = 1;
63 }
64
65 static void
66 _init_background(Evas_Object *win)
67 {
68    Evas_Object *bg;
69    char buf[PATH_MAX];
70
71    bg = elm_bg_add(win);
72    elm_bg_load_size_set(bg, 20, 20);
73    elm_bg_option_set(bg, ELM_BG_OPTION_STRETCH);
74    g_snprintf(buf, sizeof(buf), IMG_PATH);
75    elm_bg_file_set(bg, buf, NULL);
76    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77    elm_win_resize_object_add(win, bg);
78    evas_object_show(bg);
79    evas_object_resize(win, WIDTH, HEIGHT);
80 }
81
82 EAPI_MAIN int
83 elm_main(int argc, char **argv)
84 {
85    Evas_Object *win;
86
87    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
88    _init_background(win);
89    evas_object_show(win);
90    elm_run();
91    elm_shutdown();
92
93    return 0;
94 }
95 ELM_MAIN()