Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_image_tc3.c
1 /*
2  * Tested interface: AtkImage
3  *
4  * Tested AtkObject: EailImage
5  *
6  * Description: Test AtkImage interface implementation
7  *
8  * Test input: accessible object representing EailImage
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 ACTIONS_NUMBER 1
19
20 INIT_TEST("EailImage")
21
22 static void
23 _on_image_clicked(void *data, Evas_Object *obj, void *ev)
24 {
25    _printf("photo clicked called\n");
26 }
27
28 static void
29 _do_test(AtkObject *obj)
30 {
31    const char *desc_test = "top secret";
32    const char *desc;
33    int height = 0, width  = 0;
34    int x = -1, y = -1;
35
36    g_assert(ATK_IS_IMAGE(obj));
37
38    atk_image_get_image_position(ATK_IMAGE(obj), &x, &y, ATK_XY_SCREEN);
39    _printf("atk_image_get_image_position on screen: x: %d y %d\n", x, y);
40
41    g_assert(NULL == atk_image_get_image_description(ATK_IMAGE(obj)));
42    g_assert(TRUE == atk_image_set_image_description(ATK_IMAGE(obj), desc_test));
43    desc = atk_image_get_image_description(ATK_IMAGE(obj));
44    _printf("atk_image_get_image_description: %s\n", desc ? desc : "NULL");
45    g_assert(NULL != desc);
46    g_assert_cmpstr(desc_test, ==, desc);
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
51    eailu_test_code_called = 1;
52 }
53
54 static void
55 _init_image(Evas_Object *win)
56 {
57    Evas_Object *bg, *image;
58    const char * const filename = "./data/whiterabbit01.jpg";
59
60    bg = elm_bg_add(win);
61    elm_bg_color_set(bg, 255, 255, 255);
62    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63    elm_win_resize_object_add(win, bg);
64    evas_object_show(bg);
65
66    image = elm_image_add(win);
67    g_assert(elm_image_file_set(image, filename, NULL));
68    elm_image_no_scale_set(image, EINA_TRUE);
69    elm_image_resizable_set(image, EINA_FALSE, EINA_TRUE);
70    elm_image_smooth_set(image, EINA_FALSE);
71    elm_image_orient_set(image, ELM_IMAGE_FLIP_HORIZONTAL);
72    elm_image_aspect_fixed_set(image, EINA_TRUE);
73    elm_image_fill_outside_set(image, EINA_TRUE);
74    elm_image_editable_set(image, EINA_TRUE);
75    evas_object_smart_callback_add(image, "clicked", _on_image_clicked, NULL);
76    evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
77    elm_win_resize_object_add(win, image);
78    evas_object_show(image);
79 }
80
81 EAPI_MAIN int
82 elm_main(int argc, char **argv)
83 {
84    Evas_Object *win;
85
86    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
87    g_assert(win);
88    _init_image(win);
89    evas_object_show(win);
90    elm_run();
91    elm_shutdown();
92
93    return 0;
94 }
95 ELM_MAIN()