From: tasn Date: Wed, 13 Jul 2011 14:35:15 +0000 (+0000) Subject: Evas tests: Added more textblock cursor tests. X-Git-Tag: submit/trunk/20120815.174732~1152 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=366c3c662545a25712ecaa00895652f639f0430a;p=profile%2Fivi%2Fevas.git Evas tests: Added more textblock cursor tests. Also added tests to verify my previous fix. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@61342 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/tests/evas_test_textblock.c b/src/tests/evas_test_textblock.c index be98a6a..821f366 100644 --- a/src/tests/evas_test_textblock.c +++ b/src/tests/evas_test_textblock.c @@ -82,6 +82,7 @@ START_TEST(evas_textblock_cursor) { START_TB_TEST(); size_t i, len; + Evas_Coord nw, nh; const char *buf = "This is a
test.Lets see if this works.עוד פסקה."; /* Walk the textblock using cursor_char_next */ @@ -345,6 +346,49 @@ START_TEST(evas_textblock_cursor) evas_textblock_cursor_format_prev(main_cur); fail_if(evas_textblock_cursor_compare(main_cur, cur)); + + evas_object_textblock_text_markup_set(tb, buf); + + /* Check that pen geometry and getting char at coord are in sync. */ + do + { + Evas_Coord x, y, w, h; + int cur_pos; + + /* Check if it's the last char, if it is, break, otherwise, go back + * to the current char because our test advanced the cursor. */ + if (!evas_textblock_cursor_char_next(cur)) + break; + else + evas_textblock_cursor_char_prev(cur); + + cur_pos = evas_textblock_cursor_pos_get(cur); + evas_textblock_cursor_pen_geometry_get(cur, &x, &y, &w, &h); + evas_textblock_cursor_char_coord_set(cur, x + (w / 2), + y + (h / 2)); + fail_if(cur_pos != evas_textblock_cursor_pos_get(cur)); + } + while (evas_textblock_cursor_char_next(cur)); + + /* Try positions before the first paragraph, and after the last paragraph */ + evas_object_textblock_text_markup_set(tb, buf); + evas_object_textblock_size_native_get(tb, &nw, &nh); + evas_object_resize(tb, nw, nh); + evas_textblock_cursor_pos_set(cur, 5); + evas_textblock_cursor_char_coord_set(cur, nw / 2, + -50); + evas_textblock_cursor_paragraph_first(main_cur); + fail_if(evas_textblock_cursor_compare(cur, main_cur)); + + evas_textblock_cursor_pos_set(cur, 5); + evas_textblock_cursor_char_coord_set(cur, nw / 2, + nh + 50); + evas_textblock_cursor_paragraph_last(main_cur); + fail_if(evas_textblock_cursor_compare(cur, main_cur)); + + /* FIXME: Add tests that check positions left of/right of right/left + * aligned paragraphs + with rtl strings. */ + END_TB_TEST(); } END_TEST