Skip to content

Commit

Permalink
tests: Add tab_ordering_children test
Browse files Browse the repository at this point in the history
This test verifies the behavior of `tabChildren`: how it affects
automatic and custom tabbing, and how it behaves in a hierarchy.
  • Loading branch information
kjarosh authored and adrian17 committed Mar 29, 2024
1 parent 0169bbc commit c86daed
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_children/input.json
@@ -0,0 +1,78 @@
[
{ "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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 9 }
]
208 changes: 208 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_children/output.txt
@@ -0,0 +1,208 @@
Focus changed
old: null
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter.text3
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.clipOuter.text4
Tab pressed
Focus changed
old: _level0.clipOuter.text4
new: _level0.clipOuter.clipInner.text5
Tab pressed
Focus changed
old: _level0.clipOuter.clipInner.text5
new: _level0.clipOuter.clipInner.text6
Tab pressed
Focus changed
old: _level0.clipOuter.clipInner.text6
new: _level0.text1
Escape pressed, moving to stage 1
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Escape pressed, moving to stage 2
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Escape pressed, moving to stage 3
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter.text3
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.clipOuter.text4
Tab pressed
Focus changed
old: _level0.clipOuter.text4
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter.text3
Escape pressed, moving to stage 4
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Escape pressed, moving to stage 5
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Escape pressed, moving to stage 6
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter
Tab pressed
Focus changed
old: _level0.clipOuter
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter
Tab pressed
Focus changed
old: _level0.clipOuter
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Escape pressed, moving to stage 7
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter
Tab pressed
Focus changed
old: _level0.clipOuter
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Tab pressed
Focus changed
old: _level0.text2
new: _level0.clipOuter
Tab pressed
Focus changed
old: _level0.clipOuter
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.text2
Escape pressed, moving to stage 8
Tab pressed
Focus changed
old: _level0.text2
new: _level0.text1
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Escape pressed, moving to stage 9
Tab pressed
Focus changed
old: _level0.text1
new: _level0.clipOuter.text3
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.clipOuter.text3
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.text1
Tab pressed
Focus changed
old: _level0.text1
new: _level0.clipOuter.text3
Tab pressed
Focus changed
old: _level0.clipOuter.text3
new: _level0.text1
Escape pressed, moving to stage 10
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
Tab pressed
97 changes: 97 additions & 0 deletions tests/tests/swfs/avm1/tab_ordering_children/test.as
@@ -0,0 +1,97 @@
var listener = new Object();
listener.onSetFocus = function(oldFocus, newFocus) {
if (newFocus) {
trace("Focus changed");
trace(" old: " + oldFocus);
trace(" new: " + newFocus);
}
};
Selection.addListener(listener);

var testStage = 0;
function setUpStage(stage) {
if (stage == 0) {
// already set up
}
if (stage == 1) {
_root.tabChildren = false;
clipOuter.tabChildren = true;
clipOuter.clipInner.tabChildren = true;
}
if (stage == 2) {
_root.tabChildren = true;
clipOuter.tabChildren = false;
clipOuter.clipInner.tabChildren = true;
}
if (stage == 3) {
_root.tabChildren = true;
clipOuter.tabChildren = true;
clipOuter.clipInner.tabChildren = false;
}
if (stage == 4) {
_root.tabChildren = false;
clipOuter.tabChildren = true;
clipOuter.clipInner.tabChildren = false;
}
if (stage == 5) {
_root.tabChildren = true;
clipOuter.tabChildren = false;
clipOuter.tabEnabled = false;
clipOuter.clipInner.tabChildren = true;
}
if (stage == 6) {
_root.tabChildren = true;
clipOuter.tabChildren = false;
clipOuter.tabEnabled = true;
clipOuter.clipInner.tabChildren = true;
}
if (stage == 7) {
_root.tabChildren = true;
_root.tabEnabled = false;
clipOuter.tabChildren = false;
clipOuter.clipInner.tabChildren = true;
}
if (stage == 8) {
_root.tabChildren = true;
_root.tabEnabled = undefined;
clipOuter.tabChildren = false;
clipOuter.tabEnabled = undefined;
clipOuter.clipInner.tabChildren = true;

text1.tabIndex = 3;
clipOuter.text3.tabIndex = 1;
clipOuter.clipInner.text5.tabIndex = 2;
}
if (stage == 9) {
_root.tabChildren = true;
clipOuter.tabChildren = true;
clipOuter.clipInner.tabChildren = false;

text1.tabIndex = 3;
clipOuter.text3.tabIndex = 1;
clipOuter.clipInner.text5.tabIndex = 2;
}
if (stage == 10) {
_root.tabChildren = false;
clipOuter.tabChildren = false;
clipOuter.clipInner.tabChildren = true;

text1.tabIndex = 3;
clipOuter.text3.tabIndex = 1;
clipOuter.clipInner.text5.tabIndex = 2;
}
}

var listener = new Object();
listener.onKeyDown = function() {
if (Key.getCode() == 27) {
testStage += 1;
trace("Escape pressed, moving to stage " + testStage);
setUpStage(testStage);
} else if (Key.getCode() == 9) {
trace("Tab pressed");
}
};
Key.addListener(listener);

Selection.setFocus(text1);
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm1/tab_ordering_children/test.toml
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit c86daed

Please sign in to comment.