Skip to content

Commit 31a8101

Browse files
kjaroshtorokati44
authored andcommitted
tests: Add text_caret_placement_scroll test
This test verifies how the caret placement works with non-zero vertical and horizontal scroll.
1 parent ffb5be6 commit 31a8101

File tree

6 files changed

+248
-0
lines changed

6 files changed

+248
-0
lines changed
Binary file not shown.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package {
2+
import flash.display.Sprite;
3+
import flash.text.TextField;
4+
import flash.text.TextFormat;
5+
import flash.events.MouseEvent;
6+
7+
[SWF(width="600", height="200")]
8+
public class Test extends Sprite {
9+
[Embed(source="NotoSans.ttf", fontName="Noto Sans", embedAsCFF="false", unicodeRange="U+0020-U+007A")]
10+
private var font:Class;
11+
12+
public function Test() {
13+
stage.scaleMode = "noScale";
14+
addChild(newTextField());
15+
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);
16+
}
17+
18+
private function mouseUp(event:MouseEvent):void {
19+
var focus = TextField(stage.focus);
20+
var begin = focus.selectionBeginIndex;
21+
var end = focus.selectionEndIndex;
22+
if (begin == end) {
23+
trace(" { \"type\": \"MouseMove\", \"pos\": [" + event.stageX + ", " + event.stageY + "] },");
24+
trace(" { \"type\": \"MouseDown\", \"pos\": [" + event.stageX + ", " + event.stageY + "], \"btn\": \"Left\" },");
25+
trace(" { \"type\": \"MouseUp\", \"pos\": [" + event.stageX + ", " + event.stageY + "], \"btn\": \"Left\" },");
26+
trace("Caret placed at: " + begin);
27+
}
28+
}
29+
30+
private function newTextField(): TextField {
31+
var text:TextField = new TextField();
32+
text.border = true;
33+
text.type = "input";
34+
text.width = 600 - 3;
35+
text.height = 200 - 3;
36+
text.x = 1;
37+
text.embedFonts = true;
38+
var tf:TextFormat = new TextFormat();
39+
tf.font = "Noto Sans";
40+
tf.size = 20;
41+
tf.leading = 5;
42+
text.defaultTextFormat = tf;
43+
44+
text.y = 1;
45+
text.height = 100;
46+
text.multiline = true;
47+
text.text = "This is an example text\nand this is its second line, which should be really long so that it's longer than the width\nand this is its third line\nand fourth!";
48+
49+
text.scrollV = 2;
50+
text.scrollH = 50;
51+
52+
return text;
53+
}
54+
55+
}
56+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
[
2+
{ "type": "MouseMove", "pos": [44, 24] },
3+
{ "type": "MouseDown", "pos": [44, 24], "btn": "Left" },
4+
{ "type": "MouseUp", "pos": [44, 24], "btn": "Left" },
5+
{ "type": "MouseMove", "pos": [73, 50] },
6+
{ "type": "MouseDown", "pos": [73, 50], "btn": "Left" },
7+
{ "type": "MouseUp", "pos": [73, 50], "btn": "Left" },
8+
{ "type": "MouseMove", "pos": [118, 27] },
9+
{ "type": "MouseDown", "pos": [118, 27], "btn": "Left" },
10+
{ "type": "MouseUp", "pos": [118, 27], "btn": "Left" },
11+
{ "type": "MouseMove", "pos": [312, 24] },
12+
{ "type": "MouseDown", "pos": [312, 24], "btn": "Left" },
13+
{ "type": "MouseUp", "pos": [312, 24], "btn": "Left" },
14+
{ "type": "MouseMove", "pos": [519, 47] },
15+
{ "type": "MouseDown", "pos": [519, 47], "btn": "Left" },
16+
{ "type": "MouseUp", "pos": [519, 47], "btn": "Left" },
17+
{ "type": "MouseMove", "pos": [558, 23] },
18+
{ "type": "MouseDown", "pos": [558, 23], "btn": "Left" },
19+
{ "type": "MouseUp", "pos": [558, 23], "btn": "Left" },
20+
{ "type": "MouseMove", "pos": [429, 26] },
21+
{ "type": "MouseDown", "pos": [429, 26], "btn": "Left" },
22+
{ "type": "MouseUp", "pos": [429, 26], "btn": "Left" },
23+
{ "type": "MouseMove", "pos": [420, 47] },
24+
{ "type": "MouseDown", "pos": [420, 47], "btn": "Left" },
25+
{ "type": "MouseUp", "pos": [420, 47], "btn": "Left" },
26+
{ "type": "MouseMove", "pos": [169, 36] },
27+
{ "type": "MouseDown", "pos": [169, 36], "btn": "Left" },
28+
{ "type": "MouseUp", "pos": [169, 36], "btn": "Left" },
29+
{ "type": "MouseMove", "pos": [167, 39] },
30+
{ "type": "MouseDown", "pos": [167, 39], "btn": "Left" },
31+
{ "type": "MouseUp", "pos": [167, 39], "btn": "Left" },
32+
{ "type": "MouseMove", "pos": [143, 39] },
33+
{ "type": "MouseDown", "pos": [143, 39], "btn": "Left" },
34+
{ "type": "MouseUp", "pos": [143, 39], "btn": "Left" },
35+
{ "type": "MouseMove", "pos": [139, 38] },
36+
{ "type": "MouseDown", "pos": [139, 38], "btn": "Left" },
37+
{ "type": "MouseUp", "pos": [139, 38], "btn": "Left" },
38+
{ "type": "MouseMove", "pos": [120, 38] },
39+
{ "type": "MouseDown", "pos": [120, 38], "btn": "Left" },
40+
{ "type": "MouseUp", "pos": [120, 38], "btn": "Left" },
41+
{ "type": "MouseMove", "pos": [113, 38] },
42+
{ "type": "MouseDown", "pos": [113, 38], "btn": "Left" },
43+
{ "type": "MouseUp", "pos": [113, 38], "btn": "Left" },
44+
{ "type": "MouseMove", "pos": [112, 39] },
45+
{ "type": "MouseDown", "pos": [112, 39], "btn": "Left" },
46+
{ "type": "MouseUp", "pos": [112, 39], "btn": "Left" },
47+
{ "type": "MouseMove", "pos": [88, 39] },
48+
{ "type": "MouseDown", "pos": [88, 39], "btn": "Left" },
49+
{ "type": "MouseUp", "pos": [88, 39], "btn": "Left" },
50+
{ "type": "MouseMove", "pos": [40, 41] },
51+
{ "type": "MouseDown", "pos": [40, 41], "btn": "Left" },
52+
{ "type": "MouseUp", "pos": [40, 41], "btn": "Left" },
53+
{ "type": "MouseMove", "pos": [12, 34] },
54+
{ "type": "MouseDown", "pos": [12, 34], "btn": "Left" },
55+
{ "type": "MouseUp", "pos": [12, 34], "btn": "Left" },
56+
{ "type": "MouseMove", "pos": [206, 67] },
57+
{ "type": "MouseDown", "pos": [206, 67], "btn": "Left" },
58+
{ "type": "MouseUp", "pos": [206, 67], "btn": "Left" },
59+
{ "type": "MouseMove", "pos": [165, 76] },
60+
{ "type": "MouseDown", "pos": [165, 76], "btn": "Left" },
61+
{ "type": "MouseUp", "pos": [165, 76], "btn": "Left" },
62+
{ "type": "MouseMove", "pos": [127, 73] },
63+
{ "type": "MouseDown", "pos": [127, 73], "btn": "Left" },
64+
{ "type": "MouseUp", "pos": [127, 73], "btn": "Left" },
65+
{ "type": "MouseMove", "pos": [106, 75] },
66+
{ "type": "MouseDown", "pos": [106, 75], "btn": "Left" },
67+
{ "type": "MouseUp", "pos": [106, 75], "btn": "Left" },
68+
{ "type": "MouseMove", "pos": [77, 77] },
69+
{ "type": "MouseDown", "pos": [77, 77], "btn": "Left" },
70+
{ "type": "MouseUp", "pos": [77, 77], "btn": "Left" },
71+
{ "type": "MouseMove", "pos": [43, 71] },
72+
{ "type": "MouseDown", "pos": [43, 71], "btn": "Left" },
73+
{ "type": "MouseUp", "pos": [43, 71], "btn": "Left" },
74+
{ "type": "MouseMove", "pos": [20, 81] },
75+
{ "type": "MouseDown", "pos": [20, 81], "btn": "Left" },
76+
{ "type": "MouseUp", "pos": [20, 81], "btn": "Left" },
77+
{ "type": "MouseMove", "pos": [6, 68] },
78+
{ "type": "MouseDown", "pos": [6, 68], "btn": "Left" },
79+
{ "type": "MouseUp", "pos": [6, 68], "btn": "Left" },
80+
{ "type": "MouseMove", "pos": [5, 76] },
81+
{ "type": "MouseDown", "pos": [5, 76], "btn": "Left" },
82+
{ "type": "MouseUp", "pos": [5, 76], "btn": "Left" }
83+
]
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{ "type": "MouseMove", "pos": [44, 24] },
2+
{ "type": "MouseDown", "pos": [44, 24], "btn": "Left" },
3+
{ "type": "MouseUp", "pos": [44, 24], "btn": "Left" },
4+
Caret placed at: 35
5+
{ "type": "MouseMove", "pos": [73, 50] },
6+
{ "type": "MouseDown", "pos": [73, 50], "btn": "Left" },
7+
{ "type": "MouseUp", "pos": [73, 50], "btn": "Left" },
8+
Caret placed at: 131
9+
{ "type": "MouseMove", "pos": [118, 27] },
10+
{ "type": "MouseDown", "pos": [118, 27], "btn": "Left" },
11+
{ "type": "MouseUp", "pos": [118, 27], "btn": "Left" },
12+
Caret placed at: 44
13+
{ "type": "MouseMove", "pos": [312, 24] },
14+
{ "type": "MouseDown", "pos": [312, 24], "btn": "Left" },
15+
{ "type": "MouseUp", "pos": [312, 24], "btn": "Left" },
16+
Caret placed at: 64
17+
{ "type": "MouseMove", "pos": [519, 47] },
18+
{ "type": "MouseDown", "pos": [519, 47], "btn": "Left" },
19+
{ "type": "MouseUp", "pos": [519, 47], "btn": "Left" },
20+
Caret placed at: 142
21+
{ "type": "MouseMove", "pos": [558, 23] },
22+
{ "type": "MouseDown", "pos": [558, 23], "btn": "Left" },
23+
{ "type": "MouseUp", "pos": [558, 23], "btn": "Left" },
24+
Caret placed at: 94
25+
{ "type": "MouseMove", "pos": [429, 26] },
26+
{ "type": "MouseDown", "pos": [429, 26], "btn": "Left" },
27+
{ "type": "MouseUp", "pos": [429, 26], "btn": "Left" },
28+
Caret placed at: 78
29+
{ "type": "MouseMove", "pos": [420, 47] },
30+
{ "type": "MouseDown", "pos": [420, 47], "btn": "Left" },
31+
{ "type": "MouseUp", "pos": [420, 47], "btn": "Left" },
32+
Caret placed at: 142
33+
{ "type": "MouseMove", "pos": [169, 36] },
34+
{ "type": "MouseDown", "pos": [169, 36], "btn": "Left" },
35+
{ "type": "MouseUp", "pos": [169, 36], "btn": "Left" },
36+
Caret placed at: 50
37+
{ "type": "MouseMove", "pos": [167, 39] },
38+
{ "type": "MouseDown", "pos": [167, 39], "btn": "Left" },
39+
{ "type": "MouseUp", "pos": [167, 39], "btn": "Left" },
40+
Caret placed at: 142
41+
{ "type": "MouseMove", "pos": [143, 39] },
42+
{ "type": "MouseDown", "pos": [143, 39], "btn": "Left" },
43+
{ "type": "MouseUp", "pos": [143, 39], "btn": "Left" },
44+
Caret placed at: 140
45+
{ "type": "MouseMove", "pos": [139, 38] },
46+
{ "type": "MouseDown", "pos": [139, 38], "btn": "Left" },
47+
{ "type": "MouseUp", "pos": [139, 38], "btn": "Left" },
48+
Caret placed at: 45
49+
{ "type": "MouseMove", "pos": [120, 38] },
50+
{ "type": "MouseDown", "pos": [120, 38], "btn": "Left" },
51+
{ "type": "MouseUp", "pos": [120, 38], "btn": "Left" },
52+
Caret placed at: 44
53+
{ "type": "MouseMove", "pos": [113, 38] },
54+
{ "type": "MouseDown", "pos": [113, 38], "btn": "Left" },
55+
{ "type": "MouseUp", "pos": [113, 38], "btn": "Left" },
56+
Caret placed at: 43
57+
{ "type": "MouseMove", "pos": [112, 39] },
58+
{ "type": "MouseDown", "pos": [112, 39], "btn": "Left" },
59+
{ "type": "MouseUp", "pos": [112, 39], "btn": "Left" },
60+
Caret placed at: 136
61+
{ "type": "MouseMove", "pos": [88, 39] },
62+
{ "type": "MouseDown", "pos": [88, 39], "btn": "Left" },
63+
{ "type": "MouseUp", "pos": [88, 39], "btn": "Left" },
64+
Caret placed at: 133
65+
{ "type": "MouseMove", "pos": [40, 41] },
66+
{ "type": "MouseDown", "pos": [40, 41], "btn": "Left" },
67+
{ "type": "MouseUp", "pos": [40, 41], "btn": "Left" },
68+
Caret placed at: 126
69+
{ "type": "MouseMove", "pos": [12, 34] },
70+
{ "type": "MouseDown", "pos": [12, 34], "btn": "Left" },
71+
{ "type": "MouseUp", "pos": [12, 34], "btn": "Left" },
72+
Caret placed at: 30
73+
{ "type": "MouseMove", "pos": [206, 67] },
74+
{ "type": "MouseDown", "pos": [206, 67], "btn": "Left" },
75+
{ "type": "MouseUp", "pos": [206, 67], "btn": "Left" },
76+
Caret placed at: 142
77+
{ "type": "MouseMove", "pos": [165, 76] },
78+
{ "type": "MouseDown", "pos": [165, 76], "btn": "Left" },
79+
{ "type": "MouseUp", "pos": [165, 76], "btn": "Left" },
80+
Caret placed at: 154
81+
{ "type": "MouseMove", "pos": [127, 73] },
82+
{ "type": "MouseDown", "pos": [127, 73], "btn": "Left" },
83+
{ "type": "MouseUp", "pos": [127, 73], "btn": "Left" },
84+
Caret placed at: 137
85+
{ "type": "MouseMove", "pos": [106, 75] },
86+
{ "type": "MouseDown", "pos": [106, 75], "btn": "Left" },
87+
{ "type": "MouseUp", "pos": [106, 75], "btn": "Left" },
88+
Caret placed at: 154
89+
{ "type": "MouseMove", "pos": [77, 77] },
90+
{ "type": "MouseDown", "pos": [77, 77], "btn": "Left" },
91+
{ "type": "MouseUp", "pos": [77, 77], "btn": "Left" },
92+
Caret placed at: 154
93+
{ "type": "MouseMove", "pos": [43, 71] },
94+
{ "type": "MouseDown", "pos": [43, 71], "btn": "Left" },
95+
{ "type": "MouseUp", "pos": [43, 71], "btn": "Left" },
96+
Caret placed at: 126
97+
{ "type": "MouseMove", "pos": [20, 81] },
98+
{ "type": "MouseDown", "pos": [20, 81], "btn": "Left" },
99+
{ "type": "MouseUp", "pos": [20, 81], "btn": "Left" },
100+
Caret placed at: 150
101+
{ "type": "MouseMove", "pos": [6, 68] },
102+
{ "type": "MouseDown", "pos": [6, 68], "btn": "Left" },
103+
{ "type": "MouseUp", "pos": [6, 68], "btn": "Left" },
104+
Caret placed at: 121
105+
{ "type": "MouseMove", "pos": [5, 76] },
106+
{ "type": "MouseDown", "pos": [5, 76], "btn": "Left" },
107+
{ "type": "MouseUp", "pos": [5, 76], "btn": "Left" },
108+
Caret placed at: 148
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)