From 3832ec550039a99a98868c09d8fb0e302d4d5653 Mon Sep 17 00:00:00 2001 From: Yakov Goldberg Date: Thu, 11 Apr 2013 14:00:15 +0300 Subject: [PATCH] Evas textblock: fixing tests Re-enabling tests, disabled in commit: 84fa062d6e958d4a8fd547c96ef571eab6106e4a Signed-off-by: Yakov Goldberg --- src/tests/evas/evas_test_textblock.c | 109 +++++++++++++-------------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index 2101791a8c..b4fd93d04c 100644 --- a/src/tests/evas/evas_test_textblock.c +++ b/src/tests/evas/evas_test_textblock.c @@ -26,7 +26,7 @@ _evas_textblock_format_offset_get(const Evas_Object_Textblock_Node_Format *n); #define TEST_FONT "font=TEST_FONT fount_source" TESTS_SRC_DIR "./DejaVuSans.eet" static const char *style_buf = - "DEFAULT='" TEST_FONT " font_size=10 color=#000 text_class=entry'" + "DEFAULT='" TEST_FONT " font_size=40 color=#000 text_class=entry'" "newline='br'" "b='+ font=Sans:style=bold'"; @@ -612,37 +612,37 @@ START_TEST(evas_textblock_cursor) for (i = 0 ; i < 2 ; i++) { evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 3); + ck_assert_int_eq(w, 13); evas_textblock_cursor_char_next(cur); } evas_textblock_cursor_char_next(cur); - for (i = 0 ; i < 3 ; i++) + for (i = 0 ; i < 2 ; i++) { evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 3); + ck_assert_int_eq(w, 13); evas_textblock_cursor_char_next(cur); } -#else -#if 0 evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 4); + ck_assert_int_eq(w, 12); +#else + evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); + ck_assert_int_eq(w, 15); evas_textblock_cursor_char_next(cur); evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 3); + ck_assert_int_eq(w, 12); evas_textblock_cursor_pos_set(cur, 3); evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 4); + ck_assert_int_eq(w, 15); for (i = 0 ; i < 2 ; i++) { evas_textblock_cursor_char_next(cur); evas_textblock_cursor_pen_geometry_get(cur, NULL, NULL, &w, NULL); - ck_assert_int_eq(w, 3); + ck_assert_int_eq(w, 12); } -#endif #endif } @@ -650,9 +650,9 @@ START_TEST(evas_textblock_cursor) } END_TEST +#ifdef HAVE_FRIBIDI START_TEST(evas_textblock_split_cursor) { -#ifdef HAVE_FRIBIDI START_TB_TEST(); Evas_Coord x, w, x2, w2; Evas_Coord nw, nh; @@ -669,12 +669,12 @@ START_TEST(evas_textblock_split_cursor) fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 4); - evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - evas_textblock_cursor_pos_set(cur, 5); - evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); - fail_if(cx != (x + w)); - fail_if(cx2 != (x2 + w2)); + evas_textblock_cursor_pos_set(cur, 19); + evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, NULL, NULL); + evas_textblock_cursor_pos_set(cur, 20); + evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, NULL, NULL); + fail_if(cx != x); + fail_if(cx2 != x2); /* Logical cursor before " bang" */ evas_textblock_cursor_pos_set(cur, 20); @@ -700,14 +700,15 @@ START_TEST(evas_textblock_split_cursor) /* Logical cursor after "c" */ evas_textblock_cursor_pos_set(cur, 15); - evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 13); - evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - fail_if(cx != (x + w)); - fail_if(cx2 != (x2 + w2)); + evas_textblock_cursor_pos_set(cur, 9); + evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, NULL, NULL); + evas_textblock_cursor_pos_set(cur, 11); + evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, NULL, NULL); + fail_if(cx != x); + fail_if(cx2 != x2); /* Logical cursor in the beginning */ evas_textblock_cursor_line_char_first(cur); @@ -722,9 +723,8 @@ START_TEST(evas_textblock_split_cursor) fail_if(evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 24); - evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - fail_if(cx != (x + w)); + evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, NULL, NULL); + fail_if(cx != x); /* Logical cursor on the first pos */ evas_textblock_cursor_pos_set(cur, 1); @@ -745,7 +745,6 @@ START_TEST(evas_textblock_split_cursor) evas_textblock_cursor_pos_set(cur, 4); evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); evas_textblock_cursor_pos_set(cur, 5); - fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); @@ -756,20 +755,19 @@ START_TEST(evas_textblock_split_cursor) /* Logical cursor after " efl" */ evas_textblock_cursor_pos_set(cur, 21); - evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 20); - evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); - fail_if(cx != (x + w)); - fail_if(cx2 != (x2 + w2)); + evas_textblock_cursor_pos_set(cur, 4); + evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, NULL, NULL); + evas_textblock_cursor_pos_set(cur, 5); + evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, NULL, NULL); + fail_if(cx != x); + fail_if(cx2 != x2); /* Logical cursor before " efl" */ evas_textblock_cursor_pos_set(cur, 17); evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); @@ -780,15 +778,15 @@ START_TEST(evas_textblock_split_cursor) /* Logical cursor after "test " */ evas_textblock_cursor_pos_set(cur, 11); - evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); - fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 9); + evas_textblock_cursor_pos_set(cur, 17); + evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); + evas_textblock_cursor_pos_set(cur, 15); evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); - fail_if(cx != (x + w)); - fail_if(cx2 != (x2 + w2)); + fail_if(cx != x); + fail_if(cx2 != x2); /* Logical cursor in the beginning */ evas_textblock_cursor_line_char_first(cur); @@ -809,7 +807,7 @@ START_TEST(evas_textblock_split_cursor) /* Corner cases for split cursor. */ - /* End of line in LTR paragraph */ + /* End of line in LTR paragraph with embedding*/ /* 1 01234567890123 4 567 */ evas_object_textblock_text_markup_set(tb, "test נסיוןشسيب\u202babc"); @@ -822,12 +820,12 @@ START_TEST(evas_textblock_split_cursor) fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, NULL, NULL, NULL, &cx2, NULL, NULL, NULL, EVAS_TEXTBLOCK_CURSOR_BEFORE)); - evas_textblock_cursor_pos_set(cur, 4); - evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); + evas_textblock_cursor_pos_set(cur, 15); + evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, NULL, NULL); evas_textblock_cursor_pos_set(cur, 5); evas_textblock_cursor_pen_geometry_get(cur, &x, NULL, &w, NULL); fail_if(cx != (x + w)); - fail_if(cx2 != (x2 + w2)); + fail_if(cx2 != x2); /* End of line in RTL paragraph */ /* 1 2 @@ -899,7 +897,6 @@ START_TEST(evas_textblock_split_cursor) for (i = 0; i < nw; i++) { evas_object_resize(tb, i, nh); - evas_textblock_cursor_pos_set(cur, 16); fail_if(!evas_textblock_cursor_geometry_bidi_get(cur, &cx, &cy, NULL, NULL, &cx2, &cy2, NULL, NULL, @@ -965,16 +962,16 @@ START_TEST(evas_textblock_split_cursor) evas_textblock_cursor_line_geometry_get(cur, NULL, &ly, NULL, NULL); fail_if(cy != ly); - evas_textblock_cursor_pos_set(cur, 23); + evas_textblock_cursor_line_char_last(cur); evas_textblock_cursor_pen_geometry_get(cur, &x2, NULL, &w2, NULL); - fail_if(cx2 != (x2 + w2)); + fail_if(cx2 != x2); evas_textblock_cursor_line_geometry_get(cur, NULL, &ly, NULL, NULL); fail_if(cy2 != ly); END_TB_TEST(); -#endif } END_TEST +#endif START_TEST(evas_textblock_format_removal) { @@ -1435,21 +1432,21 @@ START_TEST(evas_textblock_items) /* Relsize */ /* relsize means it should adjust itself to the size of the line */ - buf = "This is an ."; + buf = "This is an ."; evas_object_textblock_text_markup_set(tb, buf); evas_object_textblock_size_formatted_get(tb, &w, &h); - fail_if((w >= 93) || (h >= 152)); + fail_if((w >= 330) || (h >= 152)); evas_textblock_cursor_pos_set(cur, 11); evas_textblock_cursor_format_item_geometry_get(cur, NULL, NULL, &w, &ih); - fail_if((w > 90) || (h != ih)); + fail_if((w > 108) || (h != ih)); - buf = "This is an ."; + buf = "This is an ."; evas_object_textblock_text_markup_set(tb, buf); evas_object_textblock_size_formatted_get(tb, &w, &h); - fail_if((w >= 93) || (h >= 152)); + fail_if((w >= 330) || (h >= 152)); evas_textblock_cursor_pos_set(cur, 11); evas_textblock_cursor_format_item_geometry_get(cur, NULL, NULL, &w, &ih); - fail_if((w > 90) || (h <= ih)); + fail_if((w > 108) || (h <= ih)); /* Relsize and abs size in the same line, all should be the same size */ buf = ""; @@ -2309,7 +2306,7 @@ START_TEST(evas_textblock_formats) evas_object_textblock_text_markup_set(tb, "Test"); evas_object_textblock_size_formatted_get(tb, &w, &h); evas_textblock_cursor_paragraph_first(cur); - evas_textblock_cursor_format_prepend(cur, "+ font_size=40"); + evas_textblock_cursor_format_prepend(cur, "+ font_size=50"); evas_object_textblock_size_formatted_get(tb, &nw, &nh); fail_if((w >= nw) || (h >= nh)); } @@ -2424,7 +2421,7 @@ START_TEST(evas_textblock_style) newst = evas_textblock_style_new(); fail_if(!newst); evas_textblock_style_set(newst, - "DEFAULT='" TEST_FONT " font_size=20 color=#000 text_class=entry'" + "DEFAULT='" TEST_FONT " font_size=50 color=#000 text_class=entry'" "br='\n'" "ps='ps'" "tab='\t'"); @@ -2646,7 +2643,7 @@ void evas_test_textblock(TCase *tc) { tcase_add_test(tc, evas_textblock_simple); tcase_add_test(tc, evas_textblock_cursor); -#if 0 +#ifdef HAVE_FRIBIDI tcase_add_test(tc, evas_textblock_split_cursor); #endif tcase_add_test(tc, evas_textblock_size);