tests: Add tab_ordering_automatic_advanced test

This test verifies the exact behavior of the automatic tab order.
This commit is contained in:
Kamil Jarosz 2024-05-14 21:56:47 +02:00 committed by Nathan Adams
parent aeabe3cbb5
commit 710232ee69
5 changed files with 784 additions and 0 deletions

View File

@ -0,0 +1,472 @@
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
[SWF(width="1000", height="1000", backgroundColor="#000000")]
public class Test extends MovieClip {
// This is the originally focused sprite.
// Upon pressing tab, the focus will switch to other sprites.
// By selecting the positions of others we can verify
// which object is preferred by the automatic tab ordering.
var origin:Sprite;
var others:Array = [];
// Tab collectors are used to prevent the order from performing a cycle.
// They are placed far outside the visible area and "collect" the focus.
var tabCollectors:Array = [];
var nextTestStage:int = 0;
var testStages:Array = [];
public function Test() {
super();
// Set up collectors
for each (var x in [-100000, 0, 100000]) {
for each (var y in [-100000, 0, 100000]) {
if (x == 0 && y == 0) continue;
var tabCollector = newSprite();
tabCollector.x = x;
tabCollector.y = y;
tabCollector.addEventListener("focusIn", function (evt:*):void {
trace("Collected the tab at " + evt.target.x + ", " + evt.target.y);
nextStage();
});
tabCollectors.push(tabCollector);
stage.addChild(tabCollector);
}
}
// Set up origin
origin = newSprite();
origin.x = 500;
origin.y = 500;
stage.addChild(origin);
setUpTestCases();
nextStage();
stage.addEventListener("keyDown", function (evt:KeyboardEvent):void {
if (evt.keyCode == 27) {
stage.focus = origin;
}
});
}
function newSprite() {
var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xFF00FF);
sprite.graphics.drawRect(0, 0, 10, 10);
sprite.tabEnabled = true;
return sprite;
}
function nextStage() {
// Clean up
for each (var other in others) {
other.tabEnabled = false;
stage.removeChild(other);
}
others = [];
if (nextTestStage >= testStages.length) {
origin.tabEnabled = false;
for each (var tabCollector in tabCollectors) {
tabCollector.tabEnabled = false;
}
stage.focus = null;
trace("===== Finished");
return;
}
var config:* = testStages[nextTestStage];
if (config["message"]) {
trace("===== Stage " + nextTestStage + " (" + config["message"] + ")");
} else {
trace("===== Stage " + nextTestStage);
}
++nextTestStage;
var othersConfig = config["others"];
var i = 0;
for each (var otherConfig in othersConfig) {
var other = newSprite();
other.x = 500 + otherConfig["dx"];
other.y = 500 + otherConfig["dy"];
if (otherConfig["scale"]) {
other.scaleX = otherConfig["scale"];
other.scaleY = otherConfig["scale"];
}
other.name = "other" + (i++);
other.addEventListener("focusIn", function (evt:*):void {
trace("Focused " + evt.target.name + " at dx=" + (evt.target.x - 500) + ", dy=" + (evt.target.y - 500));
});
stage.addChild(other);
others.push(other);
}
stage.focus = origin;
}
function setUpTestCases() {
testStages.push({
"message": "IV quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": 10, "dy": 0},
{"dx": 0, "dy": 10}
]
});
testStages.push({
"others": [
{"dx": 59, "dy": 0},
{"dx": 0, "dy": 10}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": 0},
{"dx": 0, "dy": 10}
]
});
testStages.push({
"others": [
{"dx": 61, "dy": 0},
{"dx": 0, "dy": 10}
]
});
testStages.push({
"others": [
{"dx": 119, "dy": 0},
{"dx": 0, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": 120, "dy": 0},
{"dx": 0, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": 121, "dy": 0},
{"dx": 0, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": 219, "dy": 100},
{"dx": 100, "dy": 120}
]
});
testStages.push({
"others": [
{"dx": 220, "dy": 100},
{"dx": 100, "dy": 120}
]
});
testStages.push({
"others": [
{"dx": 221, "dy": 100},
{"dx": 100, "dy": 120}
]
});
testStages.push({
"message": "III/IV quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": 59, "dy": 0},
{"dx": -60, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": 0},
{"dx": -60, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": 61, "dy": 0},
{"dx": -60, "dy": 20}
]
});
testStages.push({
"message": "III quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": -61, "dy": 100},
{"dx": -120, "dy": 110}
]
});
testStages.push({
"others": [
{"dx": -60, "dy": 100},
{"dx": -120, "dy": 110}
]
});
testStages.push({
"others": [
{"dx": -59, "dy": 100},
{"dx": -120, "dy": 110}
]
});
testStages.push({
"message": "I/IV quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": 259, "dy": -5},
{"dx": 200, "dy": 5}
]
});
testStages.push({
"others": [
{"dx": 260, "dy": -5},
{"dx": 200, "dy": 5}
]
});
testStages.push({
"others": [
{"dx": 261, "dy": -5},
{"dx": 200, "dy": 5}
]
});
testStages.push({
"message": "I quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": 259, "dy": -15},
{"dx": 200, "dy": -5}
]
});
testStages.push({
"others": [
{"dx": 260, "dy": -15},
{"dx": 200, "dy": -5}
]
});
testStages.push({
"others": [
{"dx": 261, "dy": -15},
{"dx": 200, "dy": -5}
]
});
testStages.push({
"message": "I/III quadrant preference over y = -(x - p) / 6",
"others": [
{"dx": 119, "dy": -10},
{"dx": -120, "dy": 30}
]
});
testStages.push({
"others": [
{"dx": 120, "dy": -10},
{"dx": -120, "dy": 30}
]
});
testStages.push({
"others": [
{"dx": 121, "dy": -10},
{"dx": -120, "dy": 30}
]
});
testStages.push({
"message": "Cutoff over y < x / 6 around 60,-10",
"others": [
{"dx": 60, "dy": -10}
]
});
testStages.push({
"others": [
{"dx": 59, "dy": -10}
]
});
testStages.push({
"others": [
{"dx": 61, "dy": -10}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": -9}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": -11}
]
});
testStages.push({
"message": "Cutoff over y < x / 6 around 0,0",
"others": [
{"dx": 0, "dy": 0}
]
});
testStages.push({
"others": [
{"dx": -1, "dy": 0}
]
});
testStages.push({
"others": [
{"dx": 1, "dy": 0}
]
});
testStages.push({
"others": [
{"dx": 0, "dy": 1}
]
});
testStages.push({
"others": [
{"dx": 0, "dy": -1}
]
});
testStages.push({
"message": "Cutoff over y < x / 6 around -120,20",
"others": [
{"dx": -120, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": -121, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": -119, "dy": 20}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 21}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 19}
]
});
testStages.push({
"message": "Scale should not influence the preference",
"others": [
{"dx": 59, "dy": 0, "scale": 0.5},
{"dx": 0, "dy": 10, "scale": 2}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": 0, "scale": 0.5},
{"dx": 0, "dy": 10, "scale": 2}
]
});
testStages.push({
"others": [
{"dx": 61, "dy": 0, "scale": 0.5},
{"dx": 0, "dy": 10, "scale": 2}
]
});
testStages.push({
"others": [
{"dx": 59, "dy": 0, "scale": 3},
{"dx": 0, "dy": 10, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": 60, "dy": 0, "scale": 3},
{"dx": 0, "dy": 10, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": 61, "dy": 0, "scale": 3},
{"dx": 0, "dy": 10, "scale": 0.1}
]
});
testStages.push({
"message": "Scale should not influence the cutoff line",
"others": [
{"dx": -120, "dy": 20, "scale": 3}
]
});
testStages.push({
"others": [
{"dx": -121, "dy": 20, "scale": 3}
]
});
testStages.push({
"others": [
{"dx": -119, "dy": 20, "scale": 3}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 21, "scale": 3}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 19, "scale": 3}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 20, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": -121, "dy": 20, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": -119, "dy": 20, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 21, "scale": 0.1}
]
});
testStages.push({
"others": [
{"dx": -120, "dy": 19, "scale": 0.1}
]
});
testStages.push({
"message": "Same preference vs order",
"others": [
{"dx": 60, "dy": 0},
{"dx": 0, "dy": 10}
]
});
testStages.push({
"others": [
{"dx": 0, "dy": 10},
{"dx": 60, "dy": 0}
]
});
testStages.push({
"message": "Same position vs order",
"others": [
{"dx": 60, "dy": 10},
{"dx": 60, "dy": 10}
]
});
}
}
}

View File

@ -0,0 +1,127 @@
[
{ "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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 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": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 },
{ "type": "KeyDown", "key_code": 9 }
]

View File

@ -0,0 +1,184 @@
===== Stage 0 (IV quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=10, dy=0
Focused other1 at dx=0, dy=10
Collected the tab at 100000, 0
===== Stage 1
Focused other0 at dx=59, dy=0
Focused other1 at dx=0, dy=10
Collected the tab at 100000, 0
===== Stage 2
Focused other0 at dx=60, dy=0
Collected the tab at 100000, 0
===== Stage 3
Focused other1 at dx=0, dy=10
Focused other0 at dx=61, dy=0
Collected the tab at 100000, 0
===== Stage 4
Focused other0 at dx=119, dy=0
Focused other1 at dx=0, dy=20
Collected the tab at 100000, 0
===== Stage 5
Focused other0 at dx=120, dy=0
Collected the tab at 100000, 0
===== Stage 6
Focused other1 at dx=0, dy=20
Focused other0 at dx=121, dy=0
Collected the tab at 100000, 0
===== Stage 7
Focused other0 at dx=219, dy=100
Focused other1 at dx=100, dy=120
Collected the tab at 100000, 0
===== Stage 8
Focused other0 at dx=220, dy=100
Collected the tab at 100000, 0
===== Stage 9
Focused other1 at dx=100, dy=120
Focused other0 at dx=221, dy=100
Collected the tab at 100000, 0
===== Stage 10 (III/IV quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=59, dy=0
Focused other1 at dx=-60, dy=20
Collected the tab at 100000, 0
===== Stage 11
Focused other0 at dx=60, dy=0
Collected the tab at 100000, 0
===== Stage 12
Focused other1 at dx=-60, dy=20
Focused other0 at dx=61, dy=0
Collected the tab at 100000, 0
===== Stage 13 (III quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=-61, dy=100
Focused other1 at dx=-120, dy=110
Collected the tab at 100000, 0
===== Stage 14
Focused other0 at dx=-60, dy=100
Collected the tab at 100000, 0
===== Stage 15
Focused other1 at dx=-120, dy=110
Focused other0 at dx=-59, dy=100
Collected the tab at 100000, 0
===== Stage 16 (I/IV quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=259, dy=-5
Focused other1 at dx=200, dy=5
Collected the tab at 100000, 0
===== Stage 17
Focused other0 at dx=260, dy=-5
Collected the tab at 100000, 0
===== Stage 18
Focused other1 at dx=200, dy=5
Focused other0 at dx=261, dy=-5
Collected the tab at 100000, 0
===== Stage 19 (I quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=259, dy=-15
Focused other1 at dx=200, dy=-5
Collected the tab at 100000, 0
===== Stage 20
Focused other0 at dx=260, dy=-15
Collected the tab at 100000, 0
===== Stage 21
Focused other1 at dx=200, dy=-5
Focused other0 at dx=261, dy=-15
Collected the tab at 100000, 0
===== Stage 22 (I/III quadrant preference over y = -(x - p) / 6)
Focused other0 at dx=119, dy=-10
Focused other1 at dx=-120, dy=30
Collected the tab at 100000, 0
===== Stage 23
Focused other0 at dx=120, dy=-10
Collected the tab at 100000, 0
===== Stage 24
Focused other1 at dx=-120, dy=30
Focused other0 at dx=121, dy=-10
Collected the tab at 100000, 0
===== Stage 25 (Cutoff over y < x / 6 around 60,-10)
Collected the tab at 100000, 0
===== Stage 26
Collected the tab at 100000, 0
===== Stage 27
Focused other0 at dx=61, dy=-10
Collected the tab at 100000, 0
===== Stage 28
Focused other0 at dx=60, dy=-9
Collected the tab at 100000, 0
===== Stage 29
Collected the tab at 100000, 0
===== Stage 30 (Cutoff over y < x / 6 around 0,0)
Collected the tab at 100000, 0
===== Stage 31
Collected the tab at 100000, 0
===== Stage 32
Focused other0 at dx=1, dy=0
Collected the tab at 100000, 0
===== Stage 33
Focused other0 at dx=0, dy=1
Collected the tab at 100000, 0
===== Stage 34
Collected the tab at 100000, 0
===== Stage 35 (Cutoff over y < x / 6 around -120,20)
Collected the tab at 100000, 0
===== Stage 36
Collected the tab at 100000, 0
===== Stage 37
Focused other0 at dx=-119, dy=20
Collected the tab at 100000, 0
===== Stage 38
Focused other0 at dx=-120, dy=21
Collected the tab at 100000, 0
===== Stage 39
Collected the tab at 100000, 0
===== Stage 40 (Scale should not influence the preference)
Focused other0 at dx=59, dy=0
Focused other1 at dx=0, dy=10
Collected the tab at 100000, 0
===== Stage 41
Focused other0 at dx=60, dy=0
Collected the tab at 100000, 0
===== Stage 42
Focused other1 at dx=0, dy=10
Focused other0 at dx=61, dy=0
Collected the tab at 100000, 0
===== Stage 43
Focused other0 at dx=59, dy=0
Focused other1 at dx=0, dy=10
Collected the tab at 100000, 0
===== Stage 44
Focused other0 at dx=60, dy=0
Collected the tab at 100000, 0
===== Stage 45
Focused other1 at dx=0, dy=10
Focused other0 at dx=61, dy=0
Collected the tab at 100000, 0
===== Stage 46 (Scale should not influence the cutoff line)
Collected the tab at 100000, 0
===== Stage 47
Collected the tab at 100000, 0
===== Stage 48
Focused other0 at dx=-119, dy=20
Collected the tab at 100000, 0
===== Stage 49
Focused other0 at dx=-120, dy=21
Collected the tab at 100000, 0
===== Stage 50
Collected the tab at 100000, 0
===== Stage 51
Collected the tab at 100000, 0
===== Stage 52
Collected the tab at 100000, 0
===== Stage 53
Focused other0 at dx=-119, dy=20
Collected the tab at 100000, 0
===== Stage 54
Focused other0 at dx=-120, dy=21
Collected the tab at 100000, 0
===== Stage 55
Collected the tab at 100000, 0
===== Stage 56 (Same preference vs order)
Focused other0 at dx=60, dy=0
Collected the tab at 100000, 0
===== Stage 57
Focused other0 at dx=0, dy=10
Collected the tab at 100000, 0
===== Stage 58 (Same position vs order)
Focused other0 at dx=60, dy=10
Collected the tab at 100000, 0
===== Finished

Binary file not shown.

View File

@ -0,0 +1 @@
num_ticks = 1