Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / tests / eail_label_tc2.c
1 /*
2  * Tested interface: AtkText
3  *
4  * Tested AtkObject: EailLabel
5  *
6  * Description: Test AtkObject interface
7  *
8  * Test input: accessible object representing EailLabel
9  *
10  * Expected test result: test should return 0 (success)
11  */
12
13 #include <Elementary.h>
14
15 #include "eail_test_utils.h"
16
17 INIT_TEST("EailLabel")
18
19 static void
20 _init_label(Evas_Object *win)
21 {
22    Evas_Object *bg, *label;
23
24    bg = elm_bg_add(win);
25    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
26    elm_win_resize_object_add(win, bg);
27    evas_object_show(bg);
28
29    label = elm_label_add(win);
30    elm_object_text_set(label, "Lorem ipsum dolor sit amet, consectetur adipisicing elit,"
31                        "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
32                        "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris"
33                        "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in"
34                        "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla"
35                        "pariatur. Excepteur sint occaecat cupidatat non proident, sunt"
36                        "in culpa qui officia deserunt mollit anim id est laborum.");
37    elm_label_line_wrap_set(label, ELM_WRAP_WORD);
38    evas_object_resize(label, 200, 170);
39    evas_object_move(label, 0, 0);
40    evas_object_show(label);
41
42    evas_object_resize(win, 200, 320);
43 }
44
45 static void
46 _do_test(AtkObject *obj)
47 {
48    int start_offset, end_offset;
49    AtkAttributeSet *elem = NULL, *at_set = NULL;
50    AtkAttribute *attr = NULL;
51    gboolean wrap_exist = FALSE, editable_exist = FALSE;
52
53    g_assert(ATK_IS_TEXT(obj));
54
55    gchar *text = atk_text_get_text(ATK_TEXT(obj), 6, 11);
56    g_assert_cmpstr(text, ==, "ipsum");
57    g_free(text);
58
59    g_assert(atk_text_get_character_at_offset(ATK_TEXT(obj), 12) == 'd');
60
61    g_assert(atk_text_get_character_count(ATK_TEXT(obj)) == 440);
62
63    at_set = atk_text_get_run_attributes
64        (ATK_TEXT(obj), 0, &start_offset, &end_offset);
65    g_assert(at_set);
66
67    for (elem = at_set; elem; elem = elem->next)
68      {
69         attr = (AtkAttribute *)elem->data;
70         if (0 == g_strcmp0(attr->name, atk_text_attribute_get_name
71                            (ATK_TEXT_ATTR_WRAP_MODE)))
72           wrap_exist = TRUE;
73         else if (0 == g_strcmp0(attr->name, atk_text_attribute_get_name
74                                 (ATK_TEXT_ATTR_EDITABLE)))
75           editable_exist = TRUE;
76      }
77
78    g_assert(0 == start_offset);
79    g_assert(atk_text_get_character_count(ATK_TEXT(obj)) == end_offset);
80
81    g_assert(wrap_exist);
82    g_assert(editable_exist);
83
84    /* out of bounds offset in run attributes test*/
85    at_set = atk_text_get_run_attributes
86        (ATK_TEXT(obj), atk_text_get_character_count
87         (ATK_TEXT(obj)), &start_offset, &end_offset);
88    g_assert(NULL == at_set);
89    g_assert(-1 == start_offset);
90    g_assert(-1 == end_offset);
91
92    eailu_test_code_called = 1;
93 }
94
95 EAPI_MAIN int
96 elm_main(int argc, char **argv)
97 {
98    Evas_Object *win;
99
100    win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
101    g_assert(win);
102    _init_label(win);
103
104    evas_object_show(win);
105    elm_run();
106    elm_shutdown();
107
108    return 0;
109 }
110 ELM_MAIN()
111
112