Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_multibuttonentry_tc1.c
1 /*
2  * Tested interface: AtkAobject
3  *
4  * Tested AtkObject: EailMultibuttonEntry
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailMultibuttonEntry
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 EAIL_TYPE_FOR_MBE "EailMultibuttonentry"
19 #define EAIL_TEST_INPUT_TEXT "Input text"
20
21 INIT_TEST("EailMultibuttonentry")
22
23 static void
24 _do_test(AtkObject *obj)
25 {
26    int child_amount = 0, i =0;
27    AtkObject *nested_obj;
28    atk_object_set_description(obj, "test");
29    g_assert_cmpstr(atk_object_get_description(obj), ==, "test");
30
31    atk_object_set_name(obj, "test name");
32    g_assert_cmpstr(atk_object_get_name(obj), ==, "test name");
33    /* standard tests, types, child num etc.*/
34    child_amount = atk_object_get_n_accessible_children(obj);
35    g_assert(4 == child_amount);
36    for (i = 0; i < child_amount; ++i)
37      {
38         nested_obj = atk_object_ref_accessible_child(obj, i);
39         g_assert(nested_obj);
40         eailu_is_object_with_role(nested_obj, ATK_ROLE_LABEL);
41         eailu_is_object_with_type(nested_obj, "EailItem");
42
43         g_object_unref(nested_obj);
44      }
45
46    eailu_test_code_called = 1;
47 }
48
49 static void
50 _init_multibuttonentry(Evas_Object *win)
51 {
52    Evas_Object *scroller, *bg, *box, *mb_entry;
53
54    bg = elm_bg_add(win);
55    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
56    elm_win_resize_object_add(win, bg);
57    evas_object_show(bg);
58
59    box = elm_box_add(win);
60    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
61    elm_win_resize_object_add(win, box);
62    evas_object_show(box);
63
64    scroller = elm_scroller_add(win);
65    elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
66    elm_scroller_policy_set
67        (scroller, ELM_SCROLLER_POLICY_OFF,ELM_SCROLLER_POLICY_AUTO);
68    evas_object_show(scroller);
69
70    mb_entry = elm_multibuttonentry_add(win);
71    elm_object_part_text_set(mb_entry, "guide", "Tap to add recipient");
72    elm_object_text_set(mb_entry, EAIL_TEST_INPUT_TEXT);
73    evas_object_size_hint_weight_set(mb_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
74    evas_object_size_hint_align_set(mb_entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
75    elm_object_content_set(scroller, mb_entry);
76    evas_object_show(mb_entry);
77
78    elm_multibuttonentry_item_append(mb_entry, "first", NULL, NULL);
79    elm_multibuttonentry_item_append(mb_entry, "second", NULL, NULL);
80    elm_multibuttonentry_item_append(mb_entry, "third", NULL, NULL);
81    elm_multibuttonentry_item_append(mb_entry, "fourth", NULL, NULL);
82
83    elm_object_focus_set(mb_entry, EINA_TRUE);
84    elm_box_pack_end(box, mb_entry);
85
86    evas_object_resize(win, 130, 180);
87 }
88
89 EAPI_MAIN int
90 elm_main(int argc, char **argv)
91 {
92    Evas_Object *win;
93
94    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
95    _init_multibuttonentry(win);
96
97    evas_object_show(win);
98    elm_run();
99    elm_shutdown();
100
101    /* exit code */
102    return 0;
103 }
104 ELM_MAIN()