Skip to content

Commit

Permalink
tests: Add avm2/edittext_get_line_index_of_char test
Browse files Browse the repository at this point in the history
Verifies the behavior of TextField.getLineIndexOfChar().
  • Loading branch information
kjarosh committed Jun 27, 2024
1 parent eedfb02 commit 3b2cd0d
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/tests/swfs/avm2/edittext_get_line_index_of_char/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package {
import flash.display.Sprite;
import flash.text.TextField;

public class Test extends Sprite {
private var text1: TextField;
private var text2: TextField;
private var text3: TextField;

public function Test() {
text1 = new TextField();
text1.text = "line 1\n line2\n\n line 4\n";
text2 = new TextField();
text2.htmlText = "<p>line 1 </p><br/><li>line 2 </li>\n\n<li> line 4</li>";
text3 = new TextField();
text3.wordWrap = true;
text3.width = 50;
text3.text = "first second\nthird";

addChild(text1);
addChild(text2);
addChild(text3);
printValues("text1", text1, 25);
printValues("text2", text2, 25);
printValues("text3", text3, 20);
}

private function printValues(name:String, text:TextField, len: int):void {
trace("Field: " + name);
for (var i = -1; i < len; ++i) {
trace(" " + name + ".getLineIndexOfChar(" + i + ") = " + text.getLineIndexOfChar(i));
}
}
}
}
76 changes: 76 additions & 0 deletions tests/tests/swfs/avm2/edittext_get_line_index_of_char/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Field: text1
text1.getLineIndexOfChar(-1) = -1
text1.getLineIndexOfChar(0) = 0
text1.getLineIndexOfChar(1) = 0
text1.getLineIndexOfChar(2) = 0
text1.getLineIndexOfChar(3) = 0
text1.getLineIndexOfChar(4) = 0
text1.getLineIndexOfChar(5) = 0
text1.getLineIndexOfChar(6) = 0
text1.getLineIndexOfChar(7) = 1
text1.getLineIndexOfChar(8) = 1
text1.getLineIndexOfChar(9) = 1
text1.getLineIndexOfChar(10) = 1
text1.getLineIndexOfChar(11) = 1
text1.getLineIndexOfChar(12) = 1
text1.getLineIndexOfChar(13) = 1
text1.getLineIndexOfChar(14) = 2
text1.getLineIndexOfChar(15) = 3
text1.getLineIndexOfChar(16) = 3
text1.getLineIndexOfChar(17) = 3
text1.getLineIndexOfChar(18) = 3
text1.getLineIndexOfChar(19) = 3
text1.getLineIndexOfChar(20) = 3
text1.getLineIndexOfChar(21) = 3
text1.getLineIndexOfChar(22) = 3
text1.getLineIndexOfChar(23) = -1
text1.getLineIndexOfChar(24) = -1
Field: text2
text2.getLineIndexOfChar(-1) = -1
text2.getLineIndexOfChar(0) = 0
text2.getLineIndexOfChar(1) = 0
text2.getLineIndexOfChar(2) = 0
text2.getLineIndexOfChar(3) = 0
text2.getLineIndexOfChar(4) = 0
text2.getLineIndexOfChar(5) = 0
text2.getLineIndexOfChar(6) = 0
text2.getLineIndexOfChar(7) = 0
text2.getLineIndexOfChar(8) = 0
text2.getLineIndexOfChar(9) = 0
text2.getLineIndexOfChar(10) = 0
text2.getLineIndexOfChar(11) = 0
text2.getLineIndexOfChar(12) = 0
text2.getLineIndexOfChar(13) = 0
text2.getLineIndexOfChar(14) = 0
text2.getLineIndexOfChar(15) = 1
text2.getLineIndexOfChar(16) = 2
text2.getLineIndexOfChar(17) = 2
text2.getLineIndexOfChar(18) = 2
text2.getLineIndexOfChar(19) = 2
text2.getLineIndexOfChar(20) = 2
text2.getLineIndexOfChar(21) = 2
text2.getLineIndexOfChar(22) = 2
text2.getLineIndexOfChar(23) = -1
text2.getLineIndexOfChar(24) = -1
Field: text3
text3.getLineIndexOfChar(-1) = -1
text3.getLineIndexOfChar(0) = 0
text3.getLineIndexOfChar(1) = 0
text3.getLineIndexOfChar(2) = 0
text3.getLineIndexOfChar(3) = 0
text3.getLineIndexOfChar(4) = 0
text3.getLineIndexOfChar(5) = 0
text3.getLineIndexOfChar(6) = 1
text3.getLineIndexOfChar(7) = 1
text3.getLineIndexOfChar(8) = 1
text3.getLineIndexOfChar(9) = 1
text3.getLineIndexOfChar(10) = 1
text3.getLineIndexOfChar(11) = 1
text3.getLineIndexOfChar(12) = 1
text3.getLineIndexOfChar(13) = 2
text3.getLineIndexOfChar(14) = 2
text3.getLineIndexOfChar(15) = 2
text3.getLineIndexOfChar(16) = 2
text3.getLineIndexOfChar(17) = 2
text3.getLineIndexOfChar(18) = -1
text3.getLineIndexOfChar(19) = -1
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 3b2cd0d

Please sign in to comment.