Skip to content

Commit 741fb91

Browse files
committed
tests: Add visual/edittext/edittext_device_transform_basic test
Tests basic translations applied to device text.
1 parent c49e9ac commit 741fb91

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package {
2+
import flash.display.*;
3+
import flash.text.*;
4+
import flash.geom.*;
5+
6+
[SWF(width="200", height="200")]
7+
public class Test extends Sprite {
8+
[Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0064")]
9+
private var TestFont:Class;
10+
11+
private var nextX:int = 0;
12+
private var nextY:int = 0;
13+
14+
public function Test() {
15+
stage.scaleMode = "noScale";
16+
17+
test(false);
18+
test(false, 2);
19+
test(false, 1, 2);
20+
test(false, 2, 2);
21+
22+
nextX = 100;
23+
nextY = 0;
24+
25+
test(true);
26+
test(true, 2);
27+
test(true, 1, 2);
28+
test(true, 2, 2);
29+
}
30+
31+
private function test(device: Boolean, scaleX: Number = 1, scaleY: Number = 1):TextField {
32+
var text:TextField = new TextField();
33+
text.x = nextX;
34+
text.y = nextY;
35+
text.border = true;
36+
text.width = 40;
37+
text.height = 20;
38+
text.embedFonts = !device;
39+
var tf:TextFormat = new TextFormat();
40+
tf.font = "TestFont";
41+
tf.size = 10;
42+
text.defaultTextFormat = tf;
43+
44+
text.multiline = true;
45+
text.text = "ab\n\n\n\n\n\n\n\n\n\n\nab";
46+
text.scaleX = scaleX;
47+
text.scaleY = scaleY;
48+
addChild(text);
49+
50+
nextY += 50;
51+
52+
trace("" + device + " = " + text.getCharBoundaries(0) + "," + text.getCharBoundaries(1));
53+
trace("" + device + " = " + metricsToString(text.getLineMetrics(0)));
54+
trace("" + device + " = " + text.textWidth);
55+
56+
return text;
57+
}
58+
59+
private function metricsToString(m:TextLineMetrics): String {
60+
return "width=" + Math.round(m.width);
61+
}
62+
}
63+
}
Binary file not shown.
820 Bytes
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
2+
false = width=16
3+
false = 16
4+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
5+
false = width=16
6+
false = 16
7+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
8+
false = width=16
9+
false = 16
10+
false = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
11+
false = width=16
12+
false = 16
13+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
14+
true = width=16
15+
true = 16
16+
true = (x=2, y=2, w=4, h=10),(x=6, y=2, w=4, h=10)
17+
true = width=8
18+
true = 8
19+
true = (x=2, y=2, w=16, h=10),(x=18, y=2, w=16, h=10)
20+
true = width=32
21+
true = 32
22+
true = (x=2, y=2, w=8, h=10),(x=10, y=2, w=8, h=10)
23+
true = width=16
24+
true = 16
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
num_ticks = 1
2+
3+
[[image_comparisons.output.checks]]
4+
tolerance = 0
5+
max_outliers = 90
6+
7+
[[image_comparisons.output.checks]]
8+
tolerance = 128
9+
max_outliers = 14
10+
11+
[player_options]
12+
with_renderer = { optional = true, sample_count = 4 }
13+
14+
[fonts.test_font]
15+
family = "TestFont"
16+
path = "TestFont.ttf"
17+
bold = false
18+
italic = false

0 commit comments

Comments
 (0)