summaryrefslogtreecommitdiff
path: root/src/tests/edje/edje_test_text.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-12 16:25:15 +0900
committerHermet Park <hermetpark@gmail.com>2018-07-12 16:25:15 +0900
commitb05a5cb4c73d890ab4cd65d8872a470193439bcc (patch)
treebbeca6357e2ddc38e1b2fb6b70dcef98da1f4ab5 /src/tests/edje/edje_test_text.c
parenta62420ce36c38a85433c22185ed5dec9ce73e398 (diff)
tests/edje: split edje tests into separate files
Summary: this will speed up tests and make it slightly less intimidating to add new tests Reviewers: devilhorns Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6554
Diffstat (limited to 'src/tests/edje/edje_test_text.c')
-rw-r--r--src/tests/edje/edje_test_text.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
new file mode 100644
index 0000000000..d87ab48208
--- /dev/null
+++ b/src/tests/edje/edje_test_text.c
@@ -0,0 +1,120 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include "edje_suite.h"
12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14
15
16EFL_START_TEST(edje_test_text_cursor)
17{
18 Evas *evas;
19 Evas_Object *obj;
20 const char *buf = "ABC<br/>DEF";
21 const char *txt;
22 int i, old_pos, new_pos;
23
24 evas = _setup_evas();
25
26 obj = edje_object_add(evas);
27 fail_unless(edje_object_file_set(obj, test_layout_get("test_text_cursor.edj"), "test_text_cursor"));
28 edje_object_part_text_set(obj, "text", buf);
29 txt = edje_object_part_text_get(obj, "text");
30 fail_if(!txt || strcmp(txt, buf));
31
32 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 0);
33 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 0);
34 edje_object_part_text_cursor_pos_set(obj, "text", EDJE_CURSOR_MAIN, 1);
35 ck_assert_int_eq(edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN), 1);
36
37 /* Move cursor to the 0 pos from 1 pos */
38 old_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
39 ck_assert(edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
40 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
41 ck_assert_int_ne(old_pos, new_pos);
42
43 /* Move cursor to the -1 pos from 0 pos. It has to fail. */
44 old_pos = new_pos;
45 ck_assert(!edje_object_part_text_cursor_prev(obj, "text", EDJE_CURSOR_MAIN));
46 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
47 ck_assert_int_eq(old_pos, new_pos);
48
49 /* Jump to 2nd line from 1st line.
50 * It has to return EINA_TRUE which means success. */
51 old_pos = new_pos;
52 ck_assert(edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
53 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
54 ck_assert_int_ne(old_pos, new_pos);
55
56 /* Try to jump to 3rd line from 2nd line. But, 3rd line does not exist.
57 * So, it has to return EINA_FALSE which means failure. */
58 old_pos = new_pos;
59 ck_assert(!edje_object_part_text_cursor_down(obj, "text", EDJE_CURSOR_MAIN));
60 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
61 ck_assert_int_eq(old_pos, new_pos);
62
63 /* Move cursor to the end of 2nd line. */
64 for (i = 0; i < 3; i++)
65 {
66 old_pos = new_pos;
67 ck_assert(edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
68 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
69 ck_assert_int_ne(old_pos, new_pos);
70 }
71
72 /* Move cursor to the next of the end of 2nd line which does not exist. */
73 old_pos = new_pos;
74 ck_assert(!edje_object_part_text_cursor_next(obj, "text", EDJE_CURSOR_MAIN));
75 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
76 ck_assert_int_eq(old_pos, new_pos);
77
78 /* Jump to 1st line from 2nd line.
79 * It has to return EINA_TRUE which means success. */
80 old_pos = new_pos;
81 ck_assert(edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
82 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
83 ck_assert_int_ne(old_pos, new_pos);
84
85 /* Try to jump to the above of 1st line from 1st line. But, there is no such line.
86 * So, it has to return EINA_FALSE which means failure. */
87 old_pos = new_pos;
88 ck_assert(!edje_object_part_text_cursor_up(obj, "text", EDJE_CURSOR_MAIN));
89 new_pos = edje_object_part_text_cursor_pos_get(obj, "text", EDJE_CURSOR_MAIN);
90 ck_assert_int_eq(old_pos, new_pos);
91
92 evas_free(evas);
93}
94EFL_END_TEST
95
96
97EFL_START_TEST(edje_test_textblock)
98{
99 Evas *evas;
100 Evas_Object *obj;
101 const char *buf = "Hello";
102 const char *txt;
103
104 evas = _setup_evas();
105
106 obj = edje_object_add(evas);
107 fail_unless(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), "test_textblock"));
108 edje_object_part_text_set(obj, "text", buf);
109 txt = edje_object_part_text_get(obj, "text");
110 fail_if(!txt || strcmp(txt, buf));
111
112 evas_free(evas);
113}
114EFL_END_TEST
115
116void edje_test_text(TCase *tc)
117{
118 tcase_add_test(tc, edje_test_text_cursor);
119 tcase_add_test(tc, edje_test_textblock);
120}