Skip to content

Commit

Permalink
tests: Add avm2/edittext_set_html_same test
Browse files Browse the repository at this point in the history
This test verifies the behavior of htmlText when
setting to the same value.
  • Loading branch information
kjarosh committed Dec 19, 2024
1 parent 9ca2b00 commit 71405d4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/tests/swfs/avm2/edittext_set_html_same/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.geom.*;

public class Test extends MovieClip {
public function Test() {
var tf = new TextField();
tf.multiline = true;
tf.defaultTextFormat = new TextFormat("Unknown Font");
tf.htmlText = "<p align=\"center\">x</p>";

trace("Before newline removal:");
trace(" " + tf.text.length);

tf.replaceText(1, 2, "");

trace("After newline removal:");
trace(" " + tf.text.length);
trace(" " + tf.htmlText);

tf.htmlText = "<P ALIGN=\"CENTER\"><FONT FACE=\"Unknown Font\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">x</FONT></P>";

trace("After setting to the same value:");
trace(" " + tf.text.length);
trace(" " + tf.htmlText);

tf.htmlText = "<P ALIGN=\"CENTER\"><FONT FACE=\"Unknown Font\" SIZE=\"12\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">x</FONT></P>";

trace("After setting to a slightly different value:");
trace(" " + tf.text.length);
trace(" " + tf.htmlText);

tf.htmlText = "<font face='Unknown Font 2'><b>x</b></font>";

trace("After setting to HTML x:");
trace(" " + tf.text.length);
trace(" " + tf.htmlText);

tf.text = "x";

trace("After setting text to x:");
trace(" " + tf.text.length);
trace(" " + tf.htmlText);
}
}
}
17 changes: 17 additions & 0 deletions tests/tests/swfs/avm2/edittext_set_html_same/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Before newline removal:
2
After newline removal:
1
<P ALIGN="CENTER"><FONT FACE="Unknown Font" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">x</FONT></P>
After setting to the same value:
1
<P ALIGN="CENTER"><FONT FACE="Unknown Font" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">x</FONT></P>
After setting to a slightly different value:
2
<P ALIGN="CENTER"><FONT FACE="Unknown Font" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">x</FONT></P>
After setting to HTML x:
1
<P ALIGN="LEFT"><FONT FACE="Unknown Font 2" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>x</B></FONT></P>
After setting text to x:
1
<P ALIGN="LEFT"><FONT FACE="Unknown Font 2" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0"><B>x</B></FONT></P>
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/edittext_set_html_same/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 71405d4

Please sign in to comment.