Skip to content

Commit

Permalink
tests: Add avm1/movieclip_create_text_field test
Browse files Browse the repository at this point in the history
This test verifies the behavior of MovieClip.createTextField's params.
  • Loading branch information
kjarosh authored and Dinnerbone committed Jun 6, 2024
1 parent c3ad08c commit 0c50083
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions tests/tests/swfs/avm1/movieclip_create_text_field/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
_level0.text1
x = 2
y = 3
w = 2
h = 3
_level0.text1
x = 2.1
y = 3.9
w = 2.1
h = 3.9
_level0.text2
x = 0
y = 0
w = 0
h = 0
_level0.text3
x = 0
y = 0
w = 0
h = 0
_level0.text4
x = 0
y = 0
w = 0
h = 0
_level0.text5
x = 1
y = 1
w = 1
h = 1
_level0.text6
x = 0
y = 0
w = 0
h = 0
_level0.text7
x = 0
y = 0
w = 0
h = 0
_level0.text8
x = 0
y = 0
w = 0
h = 0
_level0.text9
x = -2
y = -2
w = 2
h = 2
_level0.text10
x = -2
y = -2
w = 2
h = 2
_level0.text11
x = -2
y = -2
w = 2
h = 2
_level0.text12
x = 0
y = 0
w = 0
h = 0
_level0.text13
x = 0
y = 0
w = 0
h = 0
_level0.text14
x = 0
y = 0
w = 0
h = 0
_level0.text15
x = 0
y = 0
w = 0
h = 0
_level0.text16
x = 0
y = 0
w = 0
h = 0
_level0.text17
x = 50
y = 50
w = 50
h = 50
51 changes: 51 additions & 0 deletions tests/tests/swfs/avm1/movieclip_create_text_field/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function printProps(obj) {
trace(obj);
trace(" x = " + obj._x);
trace(" y = " + obj._y);
trace(" w = " + obj._width);
trace(" h = " + obj._height);
}

function testCreateTextField(i, value) {
printProps(_root.createTextField(
"text" + i,
_root.getNextHighestDepth(),
value, value, value, value));
}

var text1 = _root.createTextField(
"text1",
_root.getNextHighestDepth(),
2.1, 3.94, 2.1, 3.94);
printProps(text1);

text1._x = 2.1;
text1._y = 3.94;
text1._width = 2.1;
text1._height = 3.94;
printProps(text1);

var i = 2;
testCreateTextField(i++, 0);
testCreateTextField(i++, "0");
testCreateTextField(i++, 0.1);
testCreateTextField(i++, true);
testCreateTextField(i++, false);
testCreateTextField(i++, "");
testCreateTextField(i++, new Object());
testCreateTextField(i++, -2);
testCreateTextField(i++, -2.9);
testCreateTextField(i++, "-2");
testCreateTextField(i++, "text");
testCreateTextField(i++, null);
testCreateTextField(i++, undefined);
testCreateTextField(i++, 1.0 / 0.0);
testCreateTextField(i++, 0.0 / 0.0);

var tf = _root.createTextField(
"text" + i++,
_root.getNextHighestDepth(),
50, 50, -50, -50);
printProps(tf);
tf.background = true;
tf.backgroundColor = 0;
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/tests/swfs/avm1/movieclip_create_text_field/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
num_ticks = 1

image_comparisons."output".trigger = 1

[player_options]
with_renderer = { optional = true, sample_count = 1 }

0 comments on commit 0c50083

Please sign in to comment.