Skip to content

Commit ffb5be6

Browse files
kjaroshtorokati44
authored andcommitted
tests: Add text_caret_placement_translated_bounds test
This test verifies how the caret placement works when bounds do not start with 0,0.
1 parent 544c8d9 commit ffb5be6

File tree

5 files changed

+260
-0
lines changed

5 files changed

+260
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
[
2+
{ "type": "TextControl", "code": "MoveLeft" },
3+
{ "type": "MouseMove", "pos": [142, 56] },
4+
{ "type": "MouseDown", "pos": [142, 56], "btn": "Left" },
5+
{ "type": "MouseUp", "pos": [142, 56], "btn": "Left" },
6+
{ "type": "MouseMove", "pos": [136, 20] },
7+
{ "type": "MouseDown", "pos": [136, 20], "btn": "Left" },
8+
{ "type": "MouseUp", "pos": [136, 20], "btn": "Left" },
9+
{ "type": "MouseMove", "pos": [84, 51] },
10+
{ "type": "MouseDown", "pos": [84, 51], "btn": "Left" },
11+
{ "type": "MouseUp", "pos": [84, 51], "btn": "Left" },
12+
{ "type": "MouseMove", "pos": [72, 50] },
13+
{ "type": "MouseDown", "pos": [72, 50], "btn": "Left" },
14+
{ "type": "MouseUp", "pos": [72, 50], "btn": "Left" },
15+
{ "type": "MouseMove", "pos": [62, 22] },
16+
{ "type": "MouseDown", "pos": [62, 22], "btn": "Left" },
17+
{ "type": "MouseUp", "pos": [62, 22], "btn": "Left" },
18+
{ "type": "MouseMove", "pos": [206, 44] },
19+
{ "type": "MouseDown", "pos": [206, 44], "btn": "Left" },
20+
{ "type": "MouseUp", "pos": [206, 44], "btn": "Left" },
21+
{ "type": "MouseMove", "pos": [207, 26] },
22+
{ "type": "MouseDown", "pos": [207, 26], "btn": "Left" },
23+
{ "type": "MouseUp", "pos": [207, 26], "btn": "Left" },
24+
{ "type": "MouseMove", "pos": [302, 44] },
25+
{ "type": "MouseDown", "pos": [302, 44], "btn": "Left" },
26+
{ "type": "MouseUp", "pos": [302, 44], "btn": "Left" },
27+
{ "type": "MouseMove", "pos": [305, 32] },
28+
{ "type": "MouseDown", "pos": [305, 32], "btn": "Left" },
29+
{ "type": "MouseUp", "pos": [305, 32], "btn": "Left" },
30+
{ "type": "MouseMove", "pos": [322, 110] },
31+
{ "type": "MouseDown", "pos": [322, 110], "btn": "Left" },
32+
{ "type": "MouseUp", "pos": [322, 110], "btn": "Left" },
33+
{ "type": "MouseMove", "pos": [209, 115] },
34+
{ "type": "MouseDown", "pos": [209, 115], "btn": "Left" },
35+
{ "type": "MouseUp", "pos": [209, 115], "btn": "Left" },
36+
{ "type": "MouseMove", "pos": [165, 109] },
37+
{ "type": "MouseDown", "pos": [165, 109], "btn": "Left" },
38+
{ "type": "MouseUp", "pos": [165, 109], "btn": "Left" },
39+
{ "type": "MouseMove", "pos": [86, 102] },
40+
{ "type": "MouseDown", "pos": [86, 102], "btn": "Left" },
41+
{ "type": "MouseUp", "pos": [86, 102], "btn": "Left" },
42+
{ "type": "MouseMove", "pos": [56, 101] },
43+
{ "type": "MouseDown", "pos": [56, 101], "btn": "Left" },
44+
{ "type": "MouseUp", "pos": [56, 101], "btn": "Left" },
45+
{ "type": "MouseMove", "pos": [26, 95] },
46+
{ "type": "MouseDown", "pos": [26, 95], "btn": "Left" },
47+
{ "type": "MouseUp", "pos": [26, 95], "btn": "Left" },
48+
{ "type": "MouseMove", "pos": [13, 86] },
49+
{ "type": "MouseDown", "pos": [13, 86], "btn": "Left" },
50+
{ "type": "MouseUp", "pos": [13, 86], "btn": "Left" },
51+
{ "type": "MouseMove", "pos": [14, 24] },
52+
{ "type": "MouseDown", "pos": [14, 24], "btn": "Left" },
53+
{ "type": "MouseUp", "pos": [14, 24], "btn": "Left" },
54+
{ "type": "MouseMove", "pos": [14, 31] },
55+
{ "type": "MouseDown", "pos": [14, 31], "btn": "Left" },
56+
{ "type": "MouseUp", "pos": [14, 31], "btn": "Left" },
57+
{ "type": "MouseMove", "pos": [14, 34] },
58+
{ "type": "MouseDown", "pos": [14, 34], "btn": "Left" },
59+
{ "type": "MouseUp", "pos": [14, 34], "btn": "Left" },
60+
{ "type": "MouseMove", "pos": [15, 32] },
61+
{ "type": "MouseDown", "pos": [15, 32], "btn": "Left" },
62+
{ "type": "MouseUp", "pos": [15, 32], "btn": "Left" },
63+
{ "type": "MouseMove", "pos": [17, 32] },
64+
{ "type": "MouseDown", "pos": [17, 32], "btn": "Left" },
65+
{ "type": "MouseUp", "pos": [17, 32], "btn": "Left" },
66+
{ "type": "MouseMove", "pos": [18, 33] },
67+
{ "type": "MouseDown", "pos": [18, 33], "btn": "Left" },
68+
{ "type": "MouseUp", "pos": [18, 33], "btn": "Left" },
69+
{ "type": "MouseMove", "pos": [19, 34] },
70+
{ "type": "MouseDown", "pos": [19, 34], "btn": "Left" },
71+
{ "type": "MouseUp", "pos": [19, 34], "btn": "Left" },
72+
{ "type": "MouseMove", "pos": [23, 34] },
73+
{ "type": "MouseDown", "pos": [23, 34], "btn": "Left" },
74+
{ "type": "MouseUp", "pos": [23, 34], "btn": "Left" },
75+
{ "type": "MouseMove", "pos": [24, 32] },
76+
{ "type": "MouseDown", "pos": [24, 32], "btn": "Left" },
77+
{ "type": "MouseUp", "pos": [24, 32], "btn": "Left" },
78+
{ "type": "MouseMove", "pos": [27, 32] },
79+
{ "type": "MouseDown", "pos": [27, 32], "btn": "Left" },
80+
{ "type": "MouseUp", "pos": [27, 32], "btn": "Left" },
81+
{ "type": "MouseMove", "pos": [28, 33] },
82+
{ "type": "MouseDown", "pos": [28, 33], "btn": "Left" },
83+
{ "type": "MouseUp", "pos": [28, 33], "btn": "Left" },
84+
{ "type": "MouseMove", "pos": [28, 34] },
85+
{ "type": "MouseDown", "pos": [28, 34], "btn": "Left" },
86+
{ "type": "MouseUp", "pos": [28, 34], "btn": "Left" },
87+
{ "type": "MouseMove", "pos": [56, 35] },
88+
{ "type": "MouseDown", "pos": [56, 35], "btn": "Left" },
89+
{ "type": "MouseUp", "pos": [56, 35], "btn": "Left" },
90+
{ "type": "MouseMove", "pos": [56, 33] },
91+
{ "type": "MouseDown", "pos": [56, 33], "btn": "Left" },
92+
{ "type": "MouseUp", "pos": [56, 33], "btn": "Left" },
93+
{ "type": "MouseMove", "pos": [79, 33] },
94+
{ "type": "MouseDown", "pos": [79, 33], "btn": "Left" },
95+
{ "type": "MouseUp", "pos": [79, 33], "btn": "Left" },
96+
{ "type": "MouseMove", "pos": [79, 34] },
97+
{ "type": "MouseDown", "pos": [79, 34], "btn": "Left" },
98+
{ "type": "MouseUp", "pos": [79, 34], "btn": "Left" },
99+
{ "type": "MouseMove", "pos": [142, 32] },
100+
{ "type": "MouseDown", "pos": [142, 32], "btn": "Left" },
101+
{ "type": "MouseUp", "pos": [142, 32], "btn": "Left" },
102+
{ "type": "MouseMove", "pos": [142, 33] },
103+
{ "type": "MouseDown", "pos": [142, 33], "btn": "Left" },
104+
{ "type": "MouseUp", "pos": [142, 33], "btn": "Left" },
105+
{ "type": "MouseMove", "pos": [142, 34] },
106+
{ "type": "MouseDown", "pos": [142, 34], "btn": "Left" },
107+
{ "type": "MouseUp", "pos": [142, 34], "btn": "Left" }
108+
]
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{ "type": "MouseMove", "pos": [142, 56] },
2+
{ "type": "MouseDown", "pos": [142, 56], "btn": "Left" },
3+
{ "type": "MouseUp", "pos": [142, 56], "btn": "Left" },
4+
Text with caret: This is an example text\nand this is its s|econd line
5+
{ "type": "MouseMove", "pos": [136, 20] },
6+
{ "type": "MouseDown", "pos": [136, 20], "btn": "Left" },
7+
{ "type": "MouseUp", "pos": [136, 20], "btn": "Left" },
8+
Text with caret: This is an exa|mple text\nand this is its second line
9+
{ "type": "MouseMove", "pos": [84, 51] },
10+
{ "type": "MouseDown", "pos": [84, 51], "btn": "Left" },
11+
{ "type": "MouseUp", "pos": [84, 51], "btn": "Left" },
12+
Text with caret: This is an example text\nand this |is its second line
13+
{ "type": "MouseMove", "pos": [72, 50] },
14+
{ "type": "MouseDown", "pos": [72, 50], "btn": "Left" },
15+
{ "type": "MouseUp", "pos": [72, 50], "btn": "Left" },
16+
Text with caret: This is an example text\nand thi|s is its second line
17+
{ "type": "MouseMove", "pos": [62, 22] },
18+
{ "type": "MouseDown", "pos": [62, 22], "btn": "Left" },
19+
{ "type": "MouseUp", "pos": [62, 22], "btn": "Left" },
20+
Text with caret: This is| an example text\nand this is its second line
21+
{ "type": "MouseMove", "pos": [206, 44] },
22+
{ "type": "MouseDown", "pos": [206, 44], "btn": "Left" },
23+
{ "type": "MouseUp", "pos": [206, 44], "btn": "Left" },
24+
Text with caret: This is an example text\nand this is its second l|ine
25+
{ "type": "MouseMove", "pos": [207, 26] },
26+
{ "type": "MouseDown", "pos": [207, 26], "btn": "Left" },
27+
{ "type": "MouseUp", "pos": [207, 26], "btn": "Left" },
28+
Text with caret: This is an example tex|t\nand this is its second line
29+
{ "type": "MouseMove", "pos": [302, 44] },
30+
{ "type": "MouseDown", "pos": [302, 44], "btn": "Left" },
31+
{ "type": "MouseUp", "pos": [302, 44], "btn": "Left" },
32+
Text with caret: This is an example text\nand this is its second line|
33+
{ "type": "MouseMove", "pos": [305, 32] },
34+
{ "type": "MouseDown", "pos": [305, 32], "btn": "Left" },
35+
{ "type": "MouseUp", "pos": [305, 32], "btn": "Left" },
36+
Text with caret: This is an example text|\nand this is its second line
37+
{ "type": "MouseMove", "pos": [322, 110] },
38+
{ "type": "MouseDown", "pos": [322, 110], "btn": "Left" },
39+
{ "type": "MouseUp", "pos": [322, 110], "btn": "Left" },
40+
Text with caret: This is an example text\nand this is its second line|
41+
{ "type": "MouseMove", "pos": [209, 115] },
42+
{ "type": "MouseDown", "pos": [209, 115], "btn": "Left" },
43+
{ "type": "MouseUp", "pos": [209, 115], "btn": "Left" },
44+
Text with caret: This is an example text\nand this is its second l|ine
45+
{ "type": "MouseMove", "pos": [165, 109] },
46+
{ "type": "MouseDown", "pos": [165, 109], "btn": "Left" },
47+
{ "type": "MouseUp", "pos": [165, 109], "btn": "Left" },
48+
Text with caret: This is an example text\nand this is its sec|ond line
49+
{ "type": "MouseMove", "pos": [86, 102] },
50+
{ "type": "MouseDown", "pos": [86, 102], "btn": "Left" },
51+
{ "type": "MouseUp", "pos": [86, 102], "btn": "Left" },
52+
Text with caret: This is an example text\nand this i|s its second line
53+
{ "type": "MouseMove", "pos": [56, 101] },
54+
{ "type": "MouseDown", "pos": [56, 101], "btn": "Left" },
55+
{ "type": "MouseUp", "pos": [56, 101], "btn": "Left" },
56+
Text with caret: This is an example text\nand t|his is its second line
57+
{ "type": "MouseMove", "pos": [26, 95] },
58+
{ "type": "MouseDown", "pos": [26, 95], "btn": "Left" },
59+
{ "type": "MouseUp", "pos": [26, 95], "btn": "Left" },
60+
Text with caret: This is an example text\nan|d this is its second line
61+
{ "type": "MouseMove", "pos": [13, 86] },
62+
{ "type": "MouseDown", "pos": [13, 86], "btn": "Left" },
63+
{ "type": "MouseUp", "pos": [13, 86], "btn": "Left" },
64+
Text with caret: This is an example text\na|nd this is its second line
65+
{ "type": "MouseMove", "pos": [14, 24] },
66+
{ "type": "MouseDown", "pos": [14, 24], "btn": "Left" },
67+
{ "type": "MouseUp", "pos": [14, 24], "btn": "Left" },
68+
Text with caret: T|his is an example text\nand this is its second line
69+
{ "type": "MouseMove", "pos": [14, 31] },
70+
{ "type": "MouseDown", "pos": [14, 31], "btn": "Left" },
71+
{ "type": "MouseUp", "pos": [14, 31], "btn": "Left" },
72+
Text with caret: T|his is an example text\nand this is its second line
73+
{ "type": "MouseMove", "pos": [14, 34] },
74+
{ "type": "MouseDown", "pos": [14, 34], "btn": "Left" },
75+
{ "type": "MouseUp", "pos": [14, 34], "btn": "Left" },
76+
Text with caret: This is an example text\na|nd this is its second line
77+
{ "type": "MouseMove", "pos": [15, 32] },
78+
{ "type": "MouseDown", "pos": [15, 32], "btn": "Left" },
79+
{ "type": "MouseUp", "pos": [15, 32], "btn": "Left" },
80+
Text with caret: T|his is an example text\nand this is its second line
81+
{ "type": "MouseMove", "pos": [17, 32] },
82+
{ "type": "MouseDown", "pos": [17, 32], "btn": "Left" },
83+
{ "type": "MouseUp", "pos": [17, 32], "btn": "Left" },
84+
Text with caret: T|his is an example text\nand this is its second line
85+
{ "type": "MouseMove", "pos": [18, 33] },
86+
{ "type": "MouseDown", "pos": [18, 33], "btn": "Left" },
87+
{ "type": "MouseUp", "pos": [18, 33], "btn": "Left" },
88+
Text with caret: T|his is an example text\nand this is its second line
89+
{ "type": "MouseMove", "pos": [19, 34] },
90+
{ "type": "MouseDown", "pos": [19, 34], "btn": "Left" },
91+
{ "type": "MouseUp", "pos": [19, 34], "btn": "Left" },
92+
Text with caret: This is an example text\na|nd this is its second line
93+
{ "type": "MouseMove", "pos": [23, 34] },
94+
{ "type": "MouseDown", "pos": [23, 34], "btn": "Left" },
95+
{ "type": "MouseUp", "pos": [23, 34], "btn": "Left" },
96+
Text with caret: This is an example text\nan|d this is its second line
97+
{ "type": "MouseMove", "pos": [24, 32] },
98+
{ "type": "MouseDown", "pos": [24, 32], "btn": "Left" },
99+
{ "type": "MouseUp", "pos": [24, 32], "btn": "Left" },
100+
Text with caret: Th|is is an example text\nand this is its second line
101+
{ "type": "MouseMove", "pos": [27, 32] },
102+
{ "type": "MouseDown", "pos": [27, 32], "btn": "Left" },
103+
{ "type": "MouseUp", "pos": [27, 32], "btn": "Left" },
104+
Text with caret: Th|is is an example text\nand this is its second line
105+
{ "type": "MouseMove", "pos": [28, 33] },
106+
{ "type": "MouseDown", "pos": [28, 33], "btn": "Left" },
107+
{ "type": "MouseUp", "pos": [28, 33], "btn": "Left" },
108+
Text with caret: Th|is is an example text\nand this is its second line
109+
{ "type": "MouseMove", "pos": [28, 34] },
110+
{ "type": "MouseDown", "pos": [28, 34], "btn": "Left" },
111+
{ "type": "MouseUp", "pos": [28, 34], "btn": "Left" },
112+
Text with caret: This is an example text\nan|d this is its second line
113+
{ "type": "MouseMove", "pos": [56, 35] },
114+
{ "type": "MouseDown", "pos": [56, 35], "btn": "Left" },
115+
{ "type": "MouseUp", "pos": [56, 35], "btn": "Left" },
116+
Text with caret: This is an example text\nand t|his is its second line
117+
{ "type": "MouseMove", "pos": [56, 33] },
118+
{ "type": "MouseDown", "pos": [56, 33], "btn": "Left" },
119+
{ "type": "MouseUp", "pos": [56, 33], "btn": "Left" },
120+
Text with caret: This i|s an example text\nand this is its second line
121+
{ "type": "MouseMove", "pos": [79, 33] },
122+
{ "type": "MouseDown", "pos": [79, 33], "btn": "Left" },
123+
{ "type": "MouseUp", "pos": [79, 33], "btn": "Left" },
124+
Text with caret: This is a|n example text\nand this is its second line
125+
{ "type": "MouseMove", "pos": [79, 34] },
126+
{ "type": "MouseDown", "pos": [79, 34], "btn": "Left" },
127+
{ "type": "MouseUp", "pos": [79, 34], "btn": "Left" },
128+
Text with caret: This is an example text\nand this| is its second line
129+
{ "type": "MouseMove", "pos": [142, 32] },
130+
{ "type": "MouseDown", "pos": [142, 32], "btn": "Left" },
131+
{ "type": "MouseUp", "pos": [142, 32], "btn": "Left" },
132+
Text with caret: This is an exam|ple text\nand this is its second line
133+
{ "type": "MouseMove", "pos": [142, 33] },
134+
{ "type": "MouseDown", "pos": [142, 33], "btn": "Left" },
135+
{ "type": "MouseUp", "pos": [142, 33], "btn": "Left" },
136+
Text with caret: This is an exam|ple text\nand this is its second line
137+
{ "type": "MouseMove", "pos": [142, 34] },
138+
{ "type": "MouseDown", "pos": [142, 34], "btn": "Left" },
139+
{ "type": "MouseUp", "pos": [142, 34], "btn": "Left" },
140+
Text with caret: This is an example text\nand this is its s|econd line
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var listener = new Object();
2+
listener.onMouseUp = function(event) {
3+
field.replaceSel("|");
4+
trace(" { \"type\": \"MouseMove\", \"pos\": [" + _xmouse + ", " + _ymouse + "] },");
5+
trace(" { \"type\": \"MouseDown\", \"pos\": [" + _xmouse + ", " + _ymouse + "], \"btn\": \"Left\" },");
6+
trace(" { \"type\": \"MouseUp\", \"pos\": [" + _xmouse + ", " + _ymouse + "], \"btn\": \"Left\" },");
7+
trace("Text with caret: " + field.text.split("\r").join("\\n").split("\n").join("\\n"));
8+
field.text = "This is an example text\nand this is its second line";
9+
};
10+
Mouse.addListener(listener);
11+
Selection.setFocus(field);
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
num_ticks = 1

0 commit comments

Comments
 (0)