summaryrefslogtreecommitdiff
path: root/src/tests/edje
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2018-05-02 10:33:35 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-05-02 19:48:46 +0300
commitcd0bd865eb93d47d87e6e921d3743152784fc1fd (patch)
tree9395a0211926438cdb05dfbdc5efc8f76e96a71b /src/tests/edje
parentf1d411db2f2b907084c25806e38feed81f26ca0e (diff)
edje: fix backward compatibility issue caused by legacy cursor funcs
Summary: edje_object_part_text_cursor_prev/next/up/down has return value. It has to return EINA_TRUE when only it successed. But, when these funcs moved to legacy, it changed to return EINA_TRUE whenever it fails or success. It must return EINA_FALSE when it fails. @fix Test Plan: - Run test suite make check Reviewers: herdsman, raster, cedric, woohyun Subscribers: zmike Differential Revision: https://phab.enlightenment.org/D5972
Diffstat (limited to 'src/tests/edje')
-rw-r--r--src/tests/edje/data/test_text_cursor.edc22
-rw-r--r--src/tests/edje/edje_test_edje.c81
2 files changed, 103 insertions, 0 deletions
diff --git a/src/tests/edje/data/test_text_cursor.edc b/src/tests/edje/data/test_text_cursor.edc
new file mode 100644
index 0000000000..7392e545bc
--- /dev/null
+++ b/src/tests/edje/data/test_text_cursor.edc
@@ -0,0 +1,22 @@
1collections {
2 styles {
3 style { name: "tb_style";
4 base: "font=Sans font_size=20 color=#fff";
5 }
6 }
7 group { name: "test_text_cursor";
8 parts {
9 part { name: "text";
10 type: TEXTBLOCK;
11 entry_mode: EDITABLE;
12 cursor_mode: BEFORE;
13 description { state: "default" 0.0;
14 min: 300 300;
15 text {
16 style: "tb_style";
17 }
18 }
19 }
20 }
21 }
22}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 11f1df6eb2..6ce93a4809 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -943,6 +943,86 @@ EFL_START_TEST(edje_test_signal_callback_del_full)
943} 943}
944EFL_END_TEST 944EFL_END_TEST
945 945
946EFL_START_TEST(edje_test_text_cursor)
947{
948 Evas *evas;
949 Evas_Object *obj;
950 const char *buf = "ABC<br/>DEF";
951 const char *txt;
952 int i, old_pos, new_pos;
953
954 evas = EDJE_TEST_INIT_EVAS();
955
956 obj = edje_object_add(evas);
957 fail_unless(edje_object_file_set(obj, test_layout_get("test_text_cursor.edj"), "test_text_cursor"));
958 edje_object_part_text_set(obj, "text", buf);
959 txt = edje_object_part_text_get(obj, "text");
960 fail_if(!txt || strcmp(txt, buf));
961
962 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 0);
963 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 0);
964 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 1);
965 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 1);
966
967 /* Move cursor to the 0 pos from 1 pos */
968 old_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
969 ck_assert(edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
970 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
971 ck_assert_int_ne(old_pos, new_pos);
972
973 /* Move cursor to the -1 pos from 0 pos. It has to fail. */
974 old_pos = new_pos;
975 ck_assert(!edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
976 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
977 ck_assert_int_eq(old_pos, new_pos);
978
979 /* Jump to 2nd line from 1st line.
980 * It has to return EINA_TRUE which means success. */
981 old_pos = new_pos;
982 ck_assert(edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
983 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
984 ck_assert_int_ne(old_pos, new_pos);
985
986 /* Try to jump to 3rd line from 2nd line. But, 3rd line does not exist.
987 * So, it has to return EINA_FALSE which means failure. */
988 old_pos = new_pos;
989 ck_assert(!edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
990 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
991 ck_assert_int_eq(old_pos, new_pos);
992
993 /* Move cursor to the end of 2nd line. */
994 for (i = 0; i < 3; i++)
995 {
996 old_pos = new_pos;
997 ck_assert(edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
998 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
999 ck_assert_int_ne(old_pos, new_pos);
1000 }
1001
1002 /* Move cursor to the next of the end of 2nd line which does not exist. */
1003 old_pos = new_pos;
1004 ck_assert(!edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
1005 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1006 ck_assert_int_eq(old_pos, new_pos);
1007
1008 /* Jump to 1st line from 2nd line.
1009 * It has to return EINA_TRUE which means success. */
1010 old_pos = new_pos;
1011 ck_assert(edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1012 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1013 ck_assert_int_ne(old_pos, new_pos);
1014
1015 /* Try to jump to the above of 1st line from 1st line. But, there is no such line.
1016 * So, it has to return EINA_FALSE which means failure. */
1017 old_pos = new_pos;
1018 ck_assert(!edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
1019 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
1020 ck_assert_int_eq(old_pos, new_pos);
1021
1022 EDJE_TEST_FREE_EVAS();
1023}
1024EFL_END_TEST
1025
946void edje_test_edje(TCase *tc) 1026void edje_test_edje(TCase *tc)
947{ 1027{
948 tcase_add_test(tc, edje_test_edje_init); 1028 tcase_add_test(tc, edje_test_edje_init);
@@ -968,4 +1048,5 @@ void edje_test_edje(TCase *tc)
968 tcase_add_test(tc, edje_test_message_send_eo); 1048 tcase_add_test(tc, edje_test_message_send_eo);
969 tcase_add_test(tc, edje_test_signals); 1049 tcase_add_test(tc, edje_test_signals);
970 tcase_add_test(tc, edje_test_signal_callback_del_full); 1050 tcase_add_test(tc, edje_test_signal_callback_del_full);
1051 tcase_add_test(tc, edje_test_text_cursor);
971} 1052}