Evas textblock tests: Improved textblock word start/end tests.
authorTom Hacohen <tom@stosb.com>
Wed, 19 Feb 2014 14:31:33 +0000 (14:31 +0000)
committerTom Hacohen <tom@stosb.com>
Wed, 19 Feb 2014 14:38:06 +0000 (14:38 +0000)
Removed a wrong test and added some more tests.

src/tests/evas/evas_test_textblock.c

index 414c090..dfddefa 100644 (file)
@@ -598,14 +598,45 @@ START_TEST(evas_textblock_cursor)
         fail_if(12 != evas_textblock_cursor_pos_get(cur));
         evas_textblock_cursor_word_end(cur);
         fail_if(18 != evas_textblock_cursor_pos_get(cur));
-        evas_textblock_cursor_word_end(cur);
-        fail_if(21 != evas_textblock_cursor_pos_get(cur));
 
         /* Bug with 1 char word separators at paragraph start. */
         evas_object_textblock_text_markup_set(tb, "=test");
         evas_textblock_cursor_pos_set(cur, 4);
         evas_textblock_cursor_word_start(cur);
         fail_if(1 != evas_textblock_cursor_pos_get(cur));
+
+        /* 1 char words separated by spaces. */
+        evas_object_textblock_text_markup_set(tb, "a a a a");
+        evas_textblock_cursor_paragraph_first(cur);
+
+        evas_textblock_cursor_word_end(cur);
+        ck_assert_int_eq(0, evas_textblock_cursor_pos_get(cur));
+
+        evas_textblock_cursor_word_start(cur);
+        ck_assert_int_eq(0, evas_textblock_cursor_pos_get(cur));
+
+        evas_textblock_cursor_pos_set(cur, 2);
+        evas_textblock_cursor_word_start(cur);
+        ck_assert_int_eq(2, evas_textblock_cursor_pos_get(cur));
+        evas_textblock_cursor_word_end(cur);
+        ck_assert_int_eq(2, evas_textblock_cursor_pos_get(cur));
+
+        evas_textblock_cursor_pos_set(cur, 3);
+        evas_textblock_cursor_word_start(cur);
+        ck_assert_int_eq(2, evas_textblock_cursor_pos_get(cur));
+        evas_textblock_cursor_pos_set(cur, 3);
+        evas_textblock_cursor_word_end(cur);
+        ck_assert_int_eq(4, evas_textblock_cursor_pos_get(cur));
+
+        /* Going back when ending with whites. */
+        evas_object_textblock_text_markup_set(tb, "aa bla ");
+        evas_textblock_cursor_paragraph_last(cur);
+
+        evas_textblock_cursor_word_start(cur);
+        ck_assert_int_eq(3, evas_textblock_cursor_pos_get(cur));
+
+        evas_textblock_cursor_word_end(cur);
+        ck_assert_int_eq(5, evas_textblock_cursor_pos_get(cur));
      }
 
    /* Make sure coords are correct for ligatures */