Skip to content

Commit 126062a

Browse files
committed
tests: Add avm2/edittext_autosize_lazy_bounds_interactions test
This test verifies when lazy autosize bounds are applied taking into consideration various interactions with other objects and classes.
1 parent 48d3156 commit 126062a

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package {
2+
import flash.display.Sprite;
3+
import flash.display.DisplayObject;
4+
import flash.text.TextField;
5+
import flash.text.TextFormat;
6+
import flash.events.Event;
7+
8+
public class Test extends Sprite {
9+
private var desc: String = null;
10+
11+
public function Test() {
12+
stage.scaleMode = "noScale";
13+
14+
testInteractions();
15+
16+
trace("Tests finished");
17+
}
18+
19+
private function testInteractions() {
20+
testBoundsUpdate("addChild", function(text:TextField, cb:Function) {
21+
addChild(text);
22+
cb();
23+
});
24+
25+
testBoundsUpdate("contains", function(text:TextField, cb:Function) {
26+
contains(text);
27+
cb();
28+
});
29+
30+
testBoundsUpdate("hitTestObject as argument", function(text:TextField, cb:Function) {
31+
hitTestObject(text);
32+
cb();
33+
});
34+
35+
testBoundsUpdate("setting focus", function(text:TextField, cb:Function) {
36+
stage.focus = text;
37+
cb();
38+
});
39+
40+
testBoundsUpdate("resetting focus", function(text:TextField, cb:Function) {
41+
stage.focus = text;
42+
cb();
43+
}, function(text:TextField) {
44+
stage.focus = text;
45+
});
46+
47+
testBoundsUpdate("setting maskee", function(text:TextField, cb:Function) {
48+
var maskee = new Sprite();
49+
addChild(maskee);
50+
addChild(text);
51+
maskee.mask = text;
52+
cb();
53+
});
54+
55+
testBoundsUpdate("getBounds relative", function(text:TextField, cb:Function) {
56+
var other = new Sprite();
57+
other.x = 0;
58+
other.y = 0;
59+
other.width = 10;
60+
other.height = 5;
61+
addChild(other);
62+
addChild(text);
63+
trace("// getBounds = " + other.getBounds(text));
64+
cb();
65+
});
66+
67+
testBoundsUpdate("getRect relative", function(text:TextField, cb:Function) {
68+
var other = new Sprite();
69+
other.x = 0;
70+
other.y = 0;
71+
other.width = 10;
72+
other.height = 5;
73+
addChild(other);
74+
addChild(text);
75+
trace("// getRect = " + other.getRect(text));
76+
cb();
77+
});
78+
}
79+
80+
private function testBoundsUpdate(desc: String, fun: Function, before: Function = null):void {
81+
this.desc = desc;
82+
var text = new TextField();
83+
text.width = 100;
84+
text.height = 20;
85+
if (before != null) {
86+
before(text);
87+
}
88+
89+
text.autoSize = "center";
90+
fun(text, function():void {
91+
text.wordWrap = true;
92+
trace("Testing: " + desc);
93+
trace(" " + text.x + "," + text.y + "," + text.width + "," + text.height);
94+
});
95+
}
96+
}
97+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Testing: addChild
2+
0,0,100,4
3+
Testing: contains
4+
0,0,100,4
5+
Testing: hitTestObject as argument
6+
48,0,4,4
7+
Testing: setting focus
8+
48,0,4,4
9+
Testing: resetting focus
10+
48,0,4,4
11+
Testing: setting maskee
12+
0,0,100,4
13+
// getBounds = (x=0, y=0, w=0, h=0)
14+
Testing: getBounds relative
15+
0,0,100,4
16+
// getRect = (x=0, y=0, w=0, h=0)
17+
Testing: getRect relative
18+
0,0,100,4
19+
Tests finished
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
num_ticks = 4

0 commit comments

Comments
 (0)