Skip to content

Commit

Permalink
tests: Add avm1/focus_remove test
Browse files Browse the repository at this point in the history
This test verifies the behavior of Selection.getFocus()
when the focus is removed.
  • Loading branch information
kjarosh authored and Dinnerbone committed May 7, 2024
1 parent b551d14 commit b3091ec
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/tests/swfs/avm1/focus_remove/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
===== clip
Object: _level0.clip
Focus changed
old: null
new: _level0.clip
Focus: _level0.clip
Focus: null
Focus: null
===== text
Object: _level0.clip.text
Focus changed
old: null
new: _level0.clip.text
Focus: _level0.clip.text
Focus: null
Focus: null
===== button
Object: _level0.clip.button
Focus changed
old: null
new: _level0.clip.button
Focus: _level0.clip.button
Focus: null
Focus: null
48 changes: 48 additions & 0 deletions tests/tests/swfs/avm1/focus_remove/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
var listener = new Object();
listener.onSetFocus = function(oldFocus, newFocus) {
if (newFocus) {
trace("Focus changed");
trace(" old: " + oldFocus);
trace(" new: " + newFocus);
}
};
Selection.addListener(listener);

function testObject(create, remove) {
var obj = create();
trace("Object: " + obj);
obj.focusEnabled = true;
Selection.setFocus(obj);
trace("Focus: " + Selection.getFocus());
remove();
trace("Focus: " + Selection.getFocus());

create();
trace("Focus: " + Selection.getFocus());
remove();
}

trace("===== clip");
testObject(function() {
return _root.createEmptyMovieClip("clip", 2);
}, function() {
_root.clip.removeMovieClip();
});

trace("===== text");
testObject(function() {
var mc = _root.createEmptyMovieClip("clip", 3);
var tf = mc.createTextField("text", 1, 0, 0, 150, 20);
tf.type = "input";
return tf;
}, function() {
_root.clip.removeMovieClip();
});

trace("===== button");
testObject(function() {
var mc = _root.attachMovie("CustomButton", "clip", 3);
return mc.button;
}, function() {
_root.clip.removeMovieClip();
});
Binary file added tests/tests/swfs/avm1/focus_remove/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm1/focus_remove/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit b3091ec

Please sign in to comment.