Skip to content

Commit

Permalink
tests: Add focus_visibility_change test
Browse files Browse the repository at this point in the history
This test verifies the behavior of focus when its visibility is changed.
  • Loading branch information
kjarosh committed May 22, 2024
1 parent 10150f2 commit c8dd137
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/tests/swfs/avm1/focus_visibility_change/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
===== clip
Object: _level0.clip
Made visible
Focus changed
old: null
new: _level0.clip
Focus: _level0.clip
Focus changed
old: _level0.clip
new: null
Made invisible
Focus: null
Made visible
Focus: null
Made invisible
===== text
Object: _level0.text
Made visible
Focus changed
old: null
new: _level0.text
Focus: _level0.text
Focus changed
old: _level0.text
new: null
Made invisible
Focus: null
Made visible
Focus: null
Made invisible
===== button
Object: _level0.button
Made visible
Focus changed
old: null
new: _level0.button
Focus: _level0.button
Focus changed
old: _level0.button
new: null
Made invisible
Focus: null
Made visible
Focus: null
Made invisible
39 changes: 39 additions & 0 deletions tests/tests/swfs/avm1/focus_visibility_change/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var listener = new Object();
listener.onSetFocus = function(oldFocus, newFocus) {
trace("Focus changed");
trace(" old: " + oldFocus);
trace(" new: " + newFocus);
};
Selection.addListener(listener);

function testObject(obj) {
trace("Object: " + obj);
obj._visible = true;
trace("Made visible");
obj.focusEnabled = true;
Selection.setFocus(obj);
trace("Focus: " + Selection.getFocus());
obj._visible = false;
trace("Made invisible");
trace("Focus: " + Selection.getFocus());

obj._visible = true;
trace("Made visible");
trace("Focus: " + Selection.getFocus());
obj._visible = false;
trace("Made invisible");
}

var clip = _root.createEmptyMovieClip("clip", 10);
var text = _root.createTextField("text", 11, 0, 0, 150, 20);
text.type = "input";
var button = _root.attachMovie("CustomButton", "button", 12);

trace("===== clip");
testObject(clip);

trace("===== text");
testObject(text);

trace("===== button");
testObject(button);
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm1/focus_visibility_change/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit c8dd137

Please sign in to comment.