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 18, 2024
1 parent b436673 commit 6c0356a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
36 changes: 36 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,36 @@
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);
}
}
}
11 changes: 11 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,11 @@
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>
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 6c0356a

Please sign in to comment.