2 * Tested interface: AtkText
4 * Tested AtkObject: EailEntry
6 * Description: Test AtkText interface
8 * Test input: accessible object representing EailEntry
10 * Expected test result: test should return 0 (success)
13 #include <Elementary.h>
16 #include "eail_test_utils.h"
20 INIT_TEST("EailEntry")
23 _do_test(AtkObject *obj)
26 int start_offset, end_offset;
27 AtkAttributeSet *elem = NULL, *at_set = NULL;
28 AtkAttribute *attr = NULL;
29 gboolean wrap_exist = FALSE, editable_exist = FALSE;
31 g_assert(ATK_IS_TEXT(obj));
33 text = atk_text_get_text(ATK_TEXT(obj), 6, 11);
34 g_assert_cmpstr(text, ==, "ipsum");
37 g_assert(atk_text_get_character_at_offset(ATK_TEXT(obj), 12) == 'd');
38 g_assert(atk_text_get_character_count(ATK_TEXT(obj)) == TEXT_LEN);
39 g_assert(atk_text_set_caret_offset(ATK_TEXT(obj), 13));
40 g_assert(atk_text_get_caret_offset(ATK_TEXT(obj)) == 13);
44 g_assert(atk_text_get_n_selections(ATK_TEXT(obj)) == 0);
45 g_assert(atk_text_set_selection(ATK_TEXT(obj), 0, start_offset, end_offset));
46 text = atk_text_get_selection(ATK_TEXT(obj), 0, &start_offset, &end_offset);
47 g_assert_cmpstr(text, ==, "Lorem");
48 g_assert(start_offset == 0);
49 g_assert(end_offset == 5);
51 g_assert(atk_text_get_n_selections(ATK_TEXT(obj)) == 1);
52 g_assert(atk_text_remove_selection(ATK_TEXT(obj), 0) == TRUE);
53 g_assert(atk_text_get_n_selections(ATK_TEXT(obj)) == 0);
54 g_assert(atk_text_add_selection(ATK_TEXT(obj), start_offset, end_offset));
55 g_assert(atk_text_get_n_selections(ATK_TEXT(obj)) == 1);
58 at_set = atk_text_get_run_attributes
59 (ATK_TEXT(obj), 0, &start_offset, &end_offset);
62 for (elem = at_set; elem; elem = elem->next)
64 attr = (AtkAttribute *)elem->data;
65 if (0 == g_strcmp0(attr->name, atk_text_attribute_get_name
66 (ATK_TEXT_ATTR_WRAP_MODE)))
68 else if (0 == g_strcmp0(attr->name, atk_text_attribute_get_name
69 (ATK_TEXT_ATTR_EDITABLE)))
70 editable_exist = TRUE;
73 g_assert(0 == start_offset);
74 g_assert(atk_text_get_character_count(ATK_TEXT(obj)) == end_offset);
77 g_assert(editable_exist);
79 /* out of bounds offset in run attributes test*/
80 at_set = atk_text_get_run_attributes
81 (ATK_TEXT(obj), atk_text_get_character_count
82 (ATK_TEXT(obj)), &start_offset, &end_offset);
83 g_assert(NULL == at_set);
84 g_assert(-1 == start_offset);
85 g_assert(-1 == end_offset);
87 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 6,
88 ATK_TEXT_BOUNDARY_CHAR,
91 g_assert_cmpstr(text, ==, "i");
93 g_assert(start_offset == 6);
94 g_assert(end_offset == 7);
96 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 2,
97 ATK_TEXT_BOUNDARY_WORD_START,
100 g_assert_cmpstr(text, ==, "Lorem ");
103 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 11,
104 ATK_TEXT_BOUNDARY_WORD_START,
107 g_assert_cmpstr(text, ==, "ipsum ");
110 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 11,
111 ATK_TEXT_BOUNDARY_WORD_END,
114 g_assert_cmpstr(text, ==, " dolor");
117 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 10,
118 ATK_TEXT_BOUNDARY_WORD_END,
121 g_assert_cmpstr(text, ==, " ipsum");
124 text = atk_text_get_text_after_offset(ATK_TEXT(obj), 6,
125 ATK_TEXT_BOUNDARY_CHAR,
128 g_assert_cmpstr(text, ==, "p");
130 g_assert(start_offset == 7);
131 g_assert(end_offset == 8);
133 text = atk_text_get_text_after_offset(ATK_TEXT(obj), 12,
134 ATK_TEXT_BOUNDARY_WORD_START,
137 g_assert_cmpstr(text, ==, "sit ");
140 text = atk_text_get_text_after_offset(ATK_TEXT(obj), 10,
141 ATK_TEXT_BOUNDARY_WORD_END,
144 g_assert_cmpstr(text, ==, " dolor");
147 text = atk_text_get_text_before_offset(ATK_TEXT(obj), 5,
148 ATK_TEXT_BOUNDARY_CHAR,
151 g_assert_cmpstr(text, ==, "m");
153 g_assert(start_offset == 4);
154 g_assert(end_offset == 5);
156 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 12,
157 ATK_TEXT_BOUNDARY_LINE_START,
160 g_assert_cmpstr(text, ==,
161 "Lorem ipsum dolor sit amet, consectetur adipisicing elit,\n");
164 text = atk_text_get_text_at_offset(ATK_TEXT(obj), 129,
165 ATK_TEXT_BOUNDARY_LINE_END,
169 text, ==, "Ut enim ad minim veniam, quis nostrud exercitation ullamc");
172 text = atk_text_get_text_after_offset(ATK_TEXT(obj), 2,
173 ATK_TEXT_BOUNDARY_LINE_START,
178 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n");
181 text = atk_text_get_text_after_offset(ATK_TEXT(obj), 70,
182 ATK_TEXT_BOUNDARY_LINE_END,
187 "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n");
190 eailu_test_code_called = 1;
194 _init_entry(Evas_Object *win)
196 Evas_Object *box, *tb, *bg, *en;
197 const char *text1 = "Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br>"
198 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>"
199 "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris<br>"
200 "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in<br>"
201 "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla<br>"
202 "pariatur. Excepteur sint occaecat cupidatat non proident, sunt<br>"
203 "in culpa qui officia deserunt mollit anim id est laborum.<br>";
205 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
206 elm_win_autodel_set(win, EINA_TRUE);
208 bg = elm_bg_add(win);
209 elm_win_resize_object_add(win, bg);
210 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
211 evas_object_show(bg);
213 box = elm_box_add(win);
214 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
215 elm_win_resize_object_add(win, box);
216 evas_object_show(box);
218 tb = elm_box_add(win);
219 elm_box_horizontal_set(tb, EINA_TRUE);
220 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
221 evas_object_size_hint_weight_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 elm_box_pack_end(box, tb);
223 evas_object_show(tb);
225 en = elm_entry_add(win);
226 elm_entry_autosave_set(en, EINA_FALSE);
227 elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
228 elm_entry_entry_set(en, text1);
229 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
230 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
231 elm_box_pack_end(box, en);
232 evas_object_show(en);
234 evas_object_resize(win, 200, 200);
238 elm_main(int argc, char *argv[])
242 win = eailu_create_test_window_with_glib_init(_on_done, _on_focus_in);
244 evas_object_show(win);