Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_photo_tc2.c
1 /*
2  * Tested interface: AtkAction
3  *
4  * Tested AtkObject: EailPhoto
5  *
6  * Description: Test AtkAction interface
7  *
8  * Test input: accessible object representing EailPhoto
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 /* used for checking if photo was really clicked*/
21 static gboolean glob_test_photo_clicked = FALSE;
22
23 INIT_TEST("EailPhoto")
24
25 static void
26 _clicked_cb(void *data , Evas_Object *obj,
27             void *event_info)
28 {
29    glob_test_photo_clicked = TRUE;
30 }
31
32 static void
33 _do_test(AtkObject *obj)
34 {
35    g_assert(ATK_IS_ACTION(obj));
36
37    g_assert(ACTIONS_NUMBER == atk_action_get_n_actions(ATK_ACTION(obj)));
38
39    eailu_test_action_activate(ATK_ACTION(obj), "click");
40
41    g_assert((eailu_get_action_number(ATK_ACTION(obj), "typo")) == -1);
42
43    eailu_test_action_description_all(ATK_ACTION(obj));
44
45    g_assert(glob_test_photo_clicked);
46
47    eailu_test_code_called = 1;
48 }
49
50 static void
51 _init_photo(Evas_Object *win)
52 {
53    Evas_Object *bx, *photo;
54    const char * const filename = "data/th-whiterabbit01.jpg";
55
56    bx = elm_box_add(win);
57    elm_box_horizontal_set(bx, EINA_TRUE);
58    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
59    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
60    elm_box_homogeneous_set(bx, EINA_TRUE);
61    elm_win_resize_object_add(win, bx);
62
63    photo = elm_photo_add(win);
64    evas_object_smart_callback_add(photo, "clicked", _clicked_cb, NULL);
65    g_assert(elm_photo_file_set(photo, filename));
66    elm_photo_size_set(photo, 100);
67    elm_photo_aspect_fixed_set(photo, EINA_FALSE);
68    evas_object_size_hint_weight_set(photo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69    elm_photo_fill_inside_set(photo, EINA_TRUE);
70    evas_object_size_hint_align_set(photo, EVAS_HINT_FILL, EVAS_HINT_FILL);
71    elm_box_pack_end(bx, photo);
72    evas_object_show(photo);
73
74    evas_object_show(bx);
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    g_assert(win);
84    _init_photo(win);
85    evas_object_show(win);
86    elm_run();
87    elm_shutdown();
88
89    return 0;
90 }
91 ELM_MAIN()