Skip to content

Commit

Permalink
tests: Add avm2/edittext_selected_text test
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh authored and torokati44 committed May 6, 2024
1 parent eef694e commit 0f1c647
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/tests/swfs/avm2/edittext_selected_text/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.text.TextField;

public class Test extends Sprite {
private var text:TextField;

public function Test() {
text = new TextField();
text.border = true;
text.width = 200;
text.height = 40;
text.type = "input";
text.multiline = true;
addChild(text);

stage.focus = text;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
}

private function keyPressedDown(event:KeyboardEvent):void {
if (event.keyCode == 27) {
trace("Selected: " + text.selectedText.replace("\r", "\n"));
}
}
}
}
34 changes: 34 additions & 0 deletions tests/tests/swfs/avm2/edittext_selected_text/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextInput", "codepoint": "1" },
{ "type": "TextInput", "codepoint": "2" },
{ "type": "TextInput", "codepoint": "3" },
{ "type": "TextInput", "codepoint": "4" },
{ "type": "TextInput", "codepoint": "5" },
{ "type": "TextInput", "codepoint": "6" },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextControl", "code": "SelectAll" },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextControl", "code": "MoveLeft" },
{ "type": "TextControl", "code": "MoveRight" },
{ "type": "TextControl", "code": "SelectRight" },
{ "type": "TextControl", "code": "SelectRight" },
{ "type": "TextControl", "code": "SelectRight" },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextControl", "code": "MoveRight" },
{ "type": "TextControl", "code": "MoveRightDocument" },
{ "type": "TextControl", "code": "Enter" },
{ "type": "TextInput", "codepoint": "7" },
{ "type": "TextInput", "codepoint": "8" },
{ "type": "TextInput", "codepoint": "9" },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextControl", "code": "SelectAll" },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "TextControl", "code": "MoveRight" },
{ "type": "TextControl", "code": "MoveLeft" },
{ "type": "TextControl", "code": "SelectLeft" },
{ "type": "TextControl", "code": "SelectLeft" },
{ "type": "TextControl", "code": "SelectLeft" },
{ "type": "TextControl", "code": "SelectLeft" },
{ "type": "KeyDown", "key_code": 27 }
]
9 changes: 9 additions & 0 deletions tests/tests/swfs/avm2/edittext_selected_text/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Selected:
Selected:
Selected: 123456
Selected: 234
Selected:
Selected: 123456
789
Selected: 6
78
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/edittext_selected_text/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 0f1c647

Please sign in to comment.