From: Daniel Hirt Date: Tue, 17 Jun 2014 10:09:26 +0000 (+0100) Subject: Evas/Textblock: Introduce PS deletion bug test and fix X-Git-Tag: upstream/1.10.0+1149+ga3a15b1~575 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b40860f78a32a6139b64108d06a1d15fe53c818;p=platform%2Fupstream%2Fefl.git Evas/Textblock: Introduce PS deletion bug test and fix Summary: This test should make the test suite fail. It sets "ab" and "ab" markups, and deletes the PS format. Essentially, these two different markups should have the same result by this deletion. Instead, only the format gets deleted properly. A follow-up commit is added with this as a fix. Evas/Textblock: fix deletion of PS bug Fixes an issue with deletion of "". Format deletion was only performed for formats that are own-closers. This sets the paragraph separator to be an own-closer format. @fix Reviewers: tasn Reviewed By: tasn CC: JackDanielZ, id213sin Differential Revision: https://phab.enlightenment.org/D1046 --- diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index fc90a4f..df668e5 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -8491,11 +8491,27 @@ _evas_textblock_node_format_new(Evas_Textblock_Data *o, const char *_format) if ((format_len > 0) && format[format_len - 1] == '>') { format_len--; /* We don't care about '>' */ - /* Check if it closes itself. Skip the case. */ - if ((format_len > 1) && format[format_len - 1] == '/') + /* Check if it closes itself, i.e. one of the following: + * 1. Ends with a "/" e.g. "" + * 2. Is a paragraph separator */ + /* Skip the case. */ + if (format_len > 1) { - format_len--; /* We don't care about '/' */ - n->own_closer = EINA_TRUE; + if (format[format_len - 1] == '/') + { + format_len--; /* We don't care about '/' */ + n->own_closer = EINA_TRUE; + } + else if (format_len == 2) + { + char tmp[format_len + 1]; + strncpy(tmp, format, format_len); + tmp[format_len] = '\0'; + if (_IS_PARAGRAPH_SEPARATOR(o, tmp)) + { + n->own_closer = EINA_TRUE; + } + } } } diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index aebb8aa..a727b76 100644 --- a/src/tests/evas/evas_test_textblock.c +++ b/src/tests/evas/evas_test_textblock.c @@ -2909,6 +2909,42 @@ START_TEST(evas_textblock_size) } END_TEST +START_TEST(evas_textblock_delete) +{ + START_TB_TEST(); + const Evas_Object_Textblock_Node_Format *fmt; + + /* The first and the second set of commands should result in the same + * conditions for format and text nodes of the textblock object. + * Essentially, it creates the markup 'ab' */ + evas_object_textblock_text_markup_set(tb, "ab"); + fmt = evas_textblock_cursor_format_get(cur); + fail_if(fmt); + evas_textblock_cursor_pos_set(cur, 1); + evas_object_textblock_text_markup_prepend(cur, ""); + evas_textblock_cursor_pos_set(cur, 1); + fmt = evas_textblock_cursor_format_get(cur); + fail_if (!fmt); + evas_textblock_cursor_char_delete(cur); + fmt = evas_textblock_cursor_format_get(cur); + fail_if(fmt); + + evas_object_textblock_text_markup_set(tb, "ab"); + fmt = evas_textblock_cursor_format_get(cur); + fail_if(fmt); + evas_textblock_cursor_pos_set(cur, 1); + evas_object_textblock_text_markup_prepend(cur, ""); + evas_textblock_cursor_pos_set(cur, 1); + fmt = evas_textblock_cursor_format_get(cur); + fail_if (!fmt); + evas_textblock_cursor_char_delete(cur); + fmt = evas_textblock_cursor_format_get(cur); + fail_if(fmt); + + END_TB_TEST(); +} +END_TEST; + void evas_test_textblock(TCase *tc) { tcase_add_test(tc, evas_textblock_simple); @@ -2929,5 +2965,6 @@ void evas_test_textblock(TCase *tc) tcase_add_test(tc, evas_textblock_various); tcase_add_test(tc, evas_textblock_wrapping); tcase_add_test(tc, evas_textblock_items); + tcase_add_test(tc, evas_textblock_delete); }