Skip to content

Commit

Permalink
tests: Add avm2/tab_ordering_automatic_basic
Browse files Browse the repository at this point in the history
This is an AVM2 version of avm1/tab_ordering_automatic_basic
  • Loading branch information
kjarosh committed Apr 20, 2024
1 parent 5b60c83 commit 04e3600
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
79 changes: 79 additions & 0 deletions tests/tests/swfs/avm2/tab_ordering_automatic_basic/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package {

import flash.display.DisplayObject;
import flash.display.InteractiveObject;
import flash.events.KeyboardEvent;
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.FocusEvent;

public class Test extends MovieClip {
var text1:TextField;
var text2:TextField;
var text3:TextField;
var text4:TextField;
var testStage:int = 0;

public function Test() {
super();

text1 = this.newTextField(1);
text2 = this.newTextField(2);
text3 = this.newTextField(3);
text4 = this.newTextField(4);

this.stage.focus = text1;

var test:Test = this;
for each (var obj in [text1, text2, text3, text4]) {
obj.addEventListener("focusIn", function (evt:FocusEvent):void {
trace("Focus changed: " + evt.relatedObject.name + " -> " + evt.target.name);
});
this.stage.addChild(obj);
}

this.stage.addEventListener("keyDown", function(evt:KeyboardEvent) {
if (evt.keyCode == 27) {
test.testStage += 1;
trace("Escape pressed, moving to stage " + test.testStage);
test.setUpTestStage();
} else if (evt.keyCode == 9) {
trace("Tab pressed");
}
});
}

function setUpTestStage() {
if (this.testStage == 0) {
// already set up
}
if (this.testStage == 1) {
this.stage.focus = text4;
}
if (this.testStage == 2) {
this.stage.focus = text1;
text2.tabEnabled = false;
}
if (this.testStage == 3) {
this.stage.focus = text1;
text1.tabEnabled = false;
text2.tabEnabled = true;
}
}

function newTextField(i:int):TextField {
var tf:TextField = new TextField();
tf.type = "input";
tf.name = "text" + i;
tf.border = true;
tf.x = 0;
tf.y = i * 20;
tf.height = 20;
tf.width = 100;
return tf;
}
}
}
25 changes: 25 additions & 0 deletions tests/tests/swfs/avm2/tab_ordering_automatic_basic/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 27 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 }
]
45 changes: 45 additions & 0 deletions tests/tests/swfs/avm2/tab_ordering_automatic_basic/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Tab pressed
Focus changed: text1 -> text2
Tab pressed
Focus changed: text2 -> text3
Tab pressed
Focus changed: text3 -> text4
Tab pressed
Focus changed: text4 -> text1
Tab pressed
Focus changed: text1 -> text2
Escape pressed, moving to stage 1
Focus changed: text2 -> text4
Tab pressed
Focus changed: text4 -> text1
Tab pressed
Focus changed: text1 -> text2
Tab pressed
Focus changed: text2 -> text3
Tab pressed
Focus changed: text3 -> text4
Tab pressed
Focus changed: text4 -> text1
Escape pressed, moving to stage 2
Tab pressed
Focus changed: text1 -> text3
Tab pressed
Focus changed: text3 -> text4
Tab pressed
Focus changed: text4 -> text1
Tab pressed
Focus changed: text1 -> text3
Tab pressed
Focus changed: text3 -> text4
Escape pressed, moving to stage 3
Focus changed: text4 -> text1
Tab pressed
Focus changed: text1 -> text2
Tab pressed
Focus changed: text2 -> text3
Tab pressed
Focus changed: text3 -> text4
Tab pressed
Focus changed: text4 -> text2
Tab pressed
Focus changed: text2 -> text3
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 04e3600

Please sign in to comment.