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. "<my_tag/>"
+ * 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;
+ }
+ }
}
}
}
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 'a<ps>b' */
+ 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, "<ps/>");
+ 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, "<ps>");
+ 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);
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);
}