Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_image_tc2.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailImage
5  *
6  * Description: Test AtkAction interface
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 static int action_test_passed;
21
22 INIT_TEST("EailImage")
23
24 static void
25 _on_image_clicked(void *data, Evas_Object *obj, void *ev)
26 {
27    _printf("photo clicked called\n");
28    ++action_test_passed;
29 }
30
31 static void
32 _do_test(AtkObject *obj)
33 {
34    g_assert(ATK_IS_ACTION(obj));
35
36    g_assert(ACTIONS_NUMBER == atk_action_get_n_actions(ATK_ACTION(obj)));
37
38    eailu_test_action_activate(ATK_ACTION(obj), "click");
39
40    g_assert((eailu_get_action_number(ATK_ACTION(obj), "typo")) == -1);
41
42    eailu_test_action_description_all(ATK_ACTION(obj));
43
44    g_assert(action_test_passed);
45
46    eailu_test_code_called = 1;
47 }
48
49 static void
50 _init_image(Evas_Object *win)
51 {
52    Evas_Object *bg, *image;
53    const char * const filename = "./data/whiterabbit01.jpg";
54
55    bg = elm_bg_add(win);
56    elm_bg_color_set(bg, 255, 255, 255);
57    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
58    elm_win_resize_object_add(win, bg);
59    evas_object_show(bg);
60
61    image = elm_image_add(win);
62    g_assert(elm_image_file_set(image, filename, NULL));
63    elm_image_no_scale_set(image, EINA_TRUE);
64    elm_image_resizable_set(image, EINA_FALSE, EINA_TRUE);
65    elm_image_smooth_set(image, EINA_FALSE);
66    elm_image_orient_set(image, ELM_IMAGE_FLIP_HORIZONTAL);
67    elm_image_aspect_fixed_set(image, EINA_TRUE);
68    elm_image_fill_outside_set(image, EINA_TRUE);
69    elm_image_editable_set(image, EINA_TRUE);
70    evas_object_smart_callback_add(image, "clicked", _on_image_clicked, NULL);
71    evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
72    elm_win_resize_object_add(win, image);
73    evas_object_show(image);
74 }
75
76 EAPI_MAIN int
77 elm_main(int argc, char **argv)
78 {
79    Evas_Object *win;
80
81    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
82    g_assert(win);
83    _init_image(win);
84    evas_object_show(win);
85    elm_run();
86    elm_shutdown();
87
88    return 0;
89 }
90 ELM_MAIN()