Skip to content

Commit

Permalink
tests: Add edittext_autosize_align test
Browse files Browse the repository at this point in the history
This test verifies how text align is handled when
autosize and/or word wrap is set.
  • Loading branch information
kjarosh authored and Dinnerbone committed Nov 15, 2024
1 parent 6468cd1 commit 22498f7
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/tests/swfs/avm2/edittext_autosize_align/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;

[SWF(width="200", height="800")]
public class Test extends Sprite {
[Embed(source="TestFont.ttf", fontName="TestFont", embedAsCFF="false", unicodeRange="U+0061-U+0064")]
private var TestFont:Class;

private var nextY: int = 0;
private var nextX: int = 0;

public function Test() {
stage.scaleMode = "noScale";

newTextField("none", "left", false);
newTextField("none", "center", false);
newTextField("none", "right", false);
newTextField("left", "left", false);
newTextField("left", "center", false);
newTextField("left", "right", false);
newTextField("center", "left", false);
newTextField("center", "center", false);
newTextField("center", "right", false);
newTextField("right", "left", false);
newTextField("right", "center", false);
newTextField("right", "right", false);

nextY = 0;
nextX = 100;
newTextField("none", "left", true);
newTextField("none", "center", true);
newTextField("none", "right", true);
newTextField("left", "left", true);
newTextField("left", "center", true);
newTextField("left", "right", true);
newTextField("center", "left", true);
newTextField("center", "center", true);
newTextField("center", "right", true);
newTextField("right", "left", true);
newTextField("right", "center", true);
newTextField("right", "right", true);
}

private function newTextField(autosize: String, align: String, wordWrap: Boolean):void {
var text = new TextField();
text.multiline = true;
text.wordWrap = wordWrap;
text.border = true;
text.x = nextX;
text.y = nextY;
nextY += 62;
text.width = 100;
text.height = 60;
text.embedFonts = true;
var tf = new TextFormat();
tf.font = "TestFont";
tf.size = 20;
tf.align = align;
tf.leading = 5;
text.defaultTextFormat = tf;
text.text = "ab\nabab";
text.autoSize = autosize;
addChild(text);
}
}
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests/swfs/avm2/edittext_autosize_align/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
num_ticks = 1

[image_comparisons.output]
tolerance = 128

[player_options]
with_renderer = { optional = false, sample_count = 4 }

0 comments on commit 22498f7

Please sign in to comment.