Skip to content

Commit

Permalink
tests: Add avm2/focus_remove test
Browse files Browse the repository at this point in the history
This test verifies the behavior of stage.focus
when the focus is removed from the stage.
  • Loading branch information
kjarosh authored and Dinnerbone committed May 7, 2024
1 parent b3091ec commit 45dca76
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/tests/swfs/avm2/focus_remove/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package {

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

[SWF(width="50", height="50", backgroundColor="#000000")]
public class Test extends MovieClip {
public function Test() {
super();

trace("===== sprite");
testObject(new Sprite());
trace("===== clip");
testObject(new MovieClip());
trace("===== text");
testObject(new TextField());
trace("===== button");
testObject(new SimpleButton());
}

function testObject(obj:InteractiveObject) {
stage.focus = obj;
trace("Focus: " + stage.focus);
stage.addChild(obj);
trace("Focus: " + stage.focus);
stage.removeChild(obj);
trace("Focus: " + stage.focus);
stage.focus = obj;
trace("Focus: " + stage.focus);
}
}
}
20 changes: 20 additions & 0 deletions tests/tests/swfs/avm2/focus_remove/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
===== sprite
Focus: [object Sprite]
Focus: [object Sprite]
Focus: null
Focus: [object Sprite]
===== clip
Focus: [object MovieClip]
Focus: [object MovieClip]
Focus: null
Focus: [object MovieClip]
===== text
Focus: [object TextField]
Focus: [object TextField]
Focus: null
Focus: [object TextField]
===== button
Focus: [object SimpleButton]
Focus: [object SimpleButton]
Focus: null
Focus: [object SimpleButton]
Binary file added tests/tests/swfs/avm2/focus_remove/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm2/focus_remove/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit 45dca76

Please sign in to comment.