Skip to content

Commit

Permalink
tests: Add avm2/focus_root_movie test
Browse files Browse the repository at this point in the history
This test verifies the behavior of focus and focusrect
on the root movie clip.
  • Loading branch information
kjarosh authored and Dinnerbone committed Jun 5, 2024
1 parent 5c89dd8 commit 091aa23
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/tests/swfs/avm2/focus_root_movie/Test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package {

import flash.display.MovieClip;
import flash.display.Shape;
import flash.events.FocusEvent;

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

var root: MovieClip = MovieClip(this.root);
root.tabEnabled = true;
root.tabIndex = 1;
root.focusRect = true;
root.buttonMode = true;

var clip: MovieClip = new MovieClip();
clip.tabEnabled = true;
clip.tabIndex = 2;
clip.focusRect = true;
clip.addChild(newShape(1));
stage.addChild(clip);

stage.addEventListener("focusIn", function(obj) {
return function (evt: FocusEvent): void {
if (evt.relatedObject != null && evt.target != null) {
trace("Focus changed at " + obj.name + ": " + evt.relatedObject.name + " -> " + evt.target.name);
}
};
}(stage));

stage.focus = clip;
trace("After set: " + stage.focus);
stage.focus = root;
trace("After set: " + stage.focus);
trace("=====");
}

function newShape(n: int): Shape {
var shape = new Shape();
shape.graphics.beginFill(0xFF0000);
shape.graphics.drawRect(0, 0, 10, 10);
shape.graphics.endFill();
shape.x = 10 * n;
shape.y = 10 * n;
return shape;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/tests/swfs/avm2/focus_root_movie/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
After set: [object MovieClip]
Focus changed at null: instance2 -> root1
After set: [object Test]
=====
Binary file added tests/tests/swfs/avm2/focus_root_movie/test.swf
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/tests/swfs/avm2/focus_root_movie/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
num_ticks = 1

image_comparisons.output.trigger = 1

[player_options]
with_renderer = { optional = false, sample_count = 1 }

0 comments on commit 091aa23

Please sign in to comment.