Skip to content

Commit e0d59aa

Browse files
committed
tests: Add visual/edittext/edittext_device_transform_negative test
1 parent 0a80884 commit e0d59aa

File tree

6 files changed

+265
-0
lines changed

6 files changed

+265
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package {
2+
import flash.display.*;
3+
import flash.text.*;
4+
import flash.geom.*;
5+
6+
public class Test extends Sprite {
7+
[Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0064")]
8+
private var TestFont:Class;
9+
10+
private var nextX = 0;
11+
private var nextY = 0;
12+
13+
public function Test() {
14+
stage.scaleMode = "noScale";
15+
16+
test(false);
17+
test(false, 2);
18+
test(false, 1, 2);
19+
test(false, 2, 2);
20+
21+
nextX += 50;
22+
test(false, 1, 1, 90);
23+
test(false, 1, 2, 90);
24+
nextX -= 50;
25+
26+
nextX = 100;
27+
nextY = 0;
28+
29+
test(true);
30+
test(true, 2);
31+
test(true, 1, 2);
32+
test(true, 2, 2);
33+
34+
nextX += 50;
35+
test(true, 1, 1, 90);
36+
test(true, 1, 2, 90);
37+
nextX -= 50;
38+
39+
nextX = 200;
40+
nextY = 0;
41+
42+
test(false);
43+
test(false, -2);
44+
test(false, -1, -2);
45+
test(false, -2, -2);
46+
47+
nextY += 50;
48+
test(false, -1, -1, 90);
49+
test(false, -1, -2, 90);
50+
nextY -= 50;
51+
52+
nextX = 300;
53+
nextY = 0;
54+
55+
test(true);
56+
test(true, -2);
57+
test(true, -1, -2);
58+
test(true, -2, -2);
59+
60+
nextY += 50;
61+
test(true, -1, -1, 90);
62+
test(true, -1, -2, 90);
63+
nextY -= 50;
64+
65+
nextX = 400;
66+
nextY = 0;
67+
}
68+
69+
private function test(device: Boolean, scaleX: Number = 1, scaleY: Number = 1, rotation: Number = 0):TextField {
70+
var text = new TextField();
71+
text.x = nextX;
72+
text.y = nextY;
73+
if (rotation == 0 && scaleX < 0) {
74+
text.x += 100;
75+
}
76+
if (rotation == 0 && scaleY < 0) {
77+
text.y += 50;
78+
}
79+
text.border = true;
80+
text.width = 40;
81+
text.height = 20;
82+
text.embedFonts = !device;
83+
var tf = new TextFormat();
84+
tf.font = "TestFont";
85+
tf.size = 10;
86+
text.defaultTextFormat = tf;
87+
88+
text.multiline = true;
89+
text.text = "ab\n\n\n\n\n\n\n\n\n\n\nab";
90+
text.scaleX = scaleX;
91+
text.scaleY = scaleY;
92+
text.rotation = rotation;
93+
addChild(text);
94+
95+
nextY += 50;
96+
97+
trace("" + device + " = " + text.getCharBoundaries(0) + "," + text.getCharBoundaries(1));
98+
trace("" + device + " = " +
99+
text.getCharIndexAtPoint(1, 5) + "," +
100+
text.getCharIndexAtPoint(2, 5) + "," +
101+
text.getCharIndexAtPoint(5, 5) + "," +
102+
text.getCharIndexAtPoint(8, 5) + "," +
103+
text.getCharIndexAtPoint(10, 5) + "," +
104+
text.getCharIndexAtPoint(12, 5) + "," +
105+
text.getCharIndexAtPoint(15, 5) + "," +
106+
text.getCharIndexAtPoint(8, 1) + "," +
107+
text.getCharIndexAtPoint(12, 1) + "," +
108+
text.getCharIndexAtPoint(8, 12) + "," +
109+
text.getCharIndexAtPoint(12, 12) + "," +
110+
"");
111+
trace("" + device + " = " + metricsToString(text.getLineMetrics(0)));
112+
trace("" + device + " = " + text.textHeight);
113+
trace("" + device + " = " + text.textWidth);
114+
115+
return text;
116+
}
117+
118+
private function metricsToString(m:TextLineMetrics): String {
119+
return "height=" + Math.round(m.height) +
120+
",width=" + Math.round(m.width) +
121+
",x=" + Math.round(m.x) +
122+
",ascent=" + Math.round(m.ascent) +
123+
",descent=" + Math.round(m.descent);
124+
}
125+
}
126+
}
Binary file not shown.
1.92 KB
Loading
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
2+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
3+
false = height=10,width=16,x=2,ascent=8,descent=2
4+
false = 120
5+
false = 16
6+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
7+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
8+
false = height=10,width=16,x=2,ascent=8,descent=2
9+
false = 120
10+
false = 16
11+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
12+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
13+
false = height=10,width=16,x=2,ascent=8,descent=2
14+
false = 120
15+
false = 16
16+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
17+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
18+
false = height=10,width=16,x=2,ascent=8,descent=2
19+
false = 120
20+
false = 16
21+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
22+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
23+
false = height=10,width=16,x=2,ascent=8,descent=2
24+
false = 120
25+
false = 16
26+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
27+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
28+
false = height=10,width=16,x=2,ascent=8,descent=2
29+
false = 120
30+
false = 16
31+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
32+
true = 0,0,0,0,1,1,1,-1,-1,-1,-1,
33+
true = height=10,width=16,x=102,ascent=8,descent=2
34+
true = 120
35+
true = 16
36+
true = (x=2, y=2, w=4, h=10),(x=6, y=2, w=4, h=10)
37+
true = 0,0,0,1,-1,-1,-1,-1,-1,-1,-1,
38+
true = height=5,width=8,x=52,ascent=4,descent=1
39+
true = 60
40+
true = 8
41+
true = (x=2, y=2, w=16, h=10),(x=18, y=2, w=16, h=10)
42+
true = 0,0,0,0,0,0,0,-1,-1,-1,-1,
43+
true = height=20,width=32,x=102,ascent=16,descent=4
44+
true = 240
45+
true = 32
46+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
47+
true = 0,0,0,0,1,1,1,-1,-1,-1,-1,
48+
true = height=10,width=16,x=52,ascent=8,descent=2
49+
true = 120
50+
true = 16
51+
true = (x=2, y=18, w=2, h=-2),(x=2, y=16, w=2, h=-2)
52+
true = 0,0,0,0,0,0,0,0,0,0,0,
53+
true = height=2,width=4,x=132,ascent=2,descent=0
54+
true = 24
55+
true = 4
56+
true = (x=2, y=18, w=2, h=-1),(x=2, y=17, w=2, h=-1)
57+
true = 0,0,0,0,0,0,0,0,0,0,0,
58+
true = height=1,width=2,x=57,ascent=1,descent=0
59+
true = 12
60+
true = 2
61+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
62+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
63+
false = height=10,width=16,x=2,ascent=8,descent=2
64+
false = 120
65+
false = 16
66+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
67+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
68+
false = height=10,width=16,x=2,ascent=8,descent=2
69+
false = 120
70+
false = 16
71+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
72+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
73+
false = height=10,width=16,x=2,ascent=8,descent=2
74+
false = 120
75+
false = 16
76+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
77+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
78+
false = height=10,width=16,x=2,ascent=8,descent=2
79+
false = 120
80+
false = 16
81+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
82+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
83+
false = height=10,width=16,x=2,ascent=8,descent=2
84+
false = 120
85+
false = 16
86+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
87+
false = 0,0,0,0,1,1,1,-1,-1,-1,-1,
88+
false = height=10,width=16,x=2,ascent=8,descent=2
89+
false = 120
90+
false = 16
91+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
92+
true = 0,0,0,0,1,1,1,-1,-1,-1,-1,
93+
true = height=10,width=16,x=302,ascent=8,descent=2
94+
true = 120
95+
true = 16
96+
true = (x=38, y=2, w=-4, h=10),(x=34, y=2, w=-4, h=10)
97+
true = 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
98+
true = height=5,width=8,x=162,ascent=4,descent=1
99+
true = 60
100+
true = 8
101+
true = (x=38, y=18, w=-16, h=-10),(x=22, y=18, w=-16, h=-10)
102+
true = -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
103+
true = height=20,width=32,x=362,ascent=16,descent=4
104+
true = 240
105+
true = 32
106+
true = (x=38, y=18, w=-8, h=-10),(x=30, y=18, w=-8, h=-10)
107+
true = -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
108+
true = height=10,width=16,x=162,ascent=8,descent=2
109+
true = 120
110+
true = 16
111+
true = (x=38, y=2, w=-2, h=2),(x=38, y=4, w=-2, h=2)
112+
true = 0,0,0,0,0,0,0,0,0,0,0,
113+
true = height=2,width=4,x=302,ascent=2,descent=0
114+
true = 24
115+
true = 4
116+
true = (x=38, y=2, w=-2, h=1),(x=38, y=3, w=-2, h=1)
117+
true = 0,0,0,0,0,0,0,0,0,0,0,
118+
true = height=1,width=2,x=152,ascent=1,descent=0
119+
true = 12
120+
true = 2
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
num_ticks = 1
2+
known_failure = true
3+
4+
[[image_comparisons.output.checks]]
5+
tolerance = 0
6+
max_outliers = 160
7+
8+
[[image_comparisons.output.checks]]
9+
tolerance = 128
10+
max_outliers = 30
11+
12+
[player_options]
13+
with_renderer = { optional = true, sample_count = 4 }
14+
15+
[fonts.test_font]
16+
family = "TestFont"
17+
path = "TestFont.ttf"
18+
bold = false
19+
italic = false

0 commit comments

Comments
 (0)