Skip to content

Commit

Permalink
tests: Add avm1/focus_mouse test
Browse files Browse the repository at this point in the history
This test verifies how FP handles focus changes on mouse clicks.
  • Loading branch information
kjarosh authored and Dinnerbone committed Jun 4, 2024
1 parent 516e10a commit cc70686
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/tests/swfs/avm1/focus_mouse/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{ "type": "MouseMove", "pos": [5, 5] },
{ "type": "MouseDown", "pos": [5, 5], "btn": "Left" }, { "type": "MouseUp", "pos": [5, 5], "btn": "Left" },

{ "type": "MouseMove", "pos": [70, 175] },
{ "type": "MouseDown", "pos": [70, 175], "btn": "Left" }, { "type": "MouseUp", "pos": [70, 175], "btn": "Left" },
{ "type": "MouseMove", "pos": [5, 5] },
{ "type": "MouseDown", "pos": [5, 5], "btn": "Left" }, { "type": "MouseUp", "pos": [5, 5], "btn": "Left" },

{ "type": "MouseMove", "pos": [230, 175] },
{ "type": "MouseDown", "pos": [230, 175], "btn": "Left" }, { "type": "MouseUp", "pos": [230, 175], "btn": "Left" },
{ "type": "MouseMove", "pos": [5, 5] },
{ "type": "MouseDown", "pos": [5, 5], "btn": "Left" }, { "type": "MouseUp", "pos": [5, 5], "btn": "Left" },

{ "type": "MouseMove", "pos": [360, 190] },
{ "type": "MouseDown", "pos": [360, 190], "btn": "Left" }, { "type": "MouseUp", "pos": [360, 190], "btn": "Left" },
{ "type": "MouseMove", "pos": [5, 5] },
{ "type": "MouseDown", "pos": [5, 5], "btn": "Left" }, { "type": "MouseUp", "pos": [5, 5], "btn": "Left" },

{ "type": "MouseMove", "pos": [360, 190] },
{ "type": "MouseDown", "pos": [360, 190], "btn": "Left" }, { "type": "MouseUp", "pos": [360, 190], "btn": "Left" },
{ "type": "MouseMove", "pos": [230, 175] },
{ "type": "MouseDown", "pos": [230, 175], "btn": "Left" }, { "type": "MouseUp", "pos": [230, 175], "btn": "Left" },

{ "type": "MouseMove", "pos": [360, 190] },
{ "type": "MouseDown", "pos": [360, 190], "btn": "Left" }, { "type": "MouseUp", "pos": [360, 190], "btn": "Left" },
{ "type": "MouseMove", "pos": [70, 175] },
{ "type": "MouseDown", "pos": [70, 175], "btn": "Left" }, { "type": "MouseUp", "pos": [70, 175], "btn": "Left" },

{ "type": "MouseMove", "pos": [360, 190] },
{ "type": "MouseDown", "pos": [360, 190], "btn": "Left" }, { "type": "MouseUp", "pos": [360, 190], "btn": "Left" },
{ "type": "MouseMove", "pos": [360, 190] },
{ "type": "MouseDown", "pos": [360, 190], "btn": "Left" }, { "type": "MouseUp", "pos": [360, 190], "btn": "Left" }
]
45 changes: 45 additions & 0 deletions tests/tests/swfs/avm1/focus_mouse/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
_level0.clip.onMouseDown
_level0.clip.onMouseUp
_level0.clip.onMouseDown
_level0.clip.onPress
_level0.clip.onMouseUp
_level0.clip.onRelease
_level0.clip.onMouseDown
_level0.clip.onMouseUp
_level0.clip.onMouseDown
press
_level0.button.onPress
_level0.clip.onMouseUp
release
_level0.button.onRelease
_level0.clip.onMouseDown
_level0.clip.onMouseUp
_level0.clip.onMouseDown
Focus at: _level0.text
_level0.clip.onMouseUp
_level0.clip.onMouseDown
Focus at: null
_level0.clip.onMouseUp
_level0.clip.onMouseDown
Focus at: _level0.text
_level0.clip.onMouseUp
_level0.clip.onMouseDown
Focus at: null
press
_level0.button.onPress
_level0.clip.onMouseUp
release
_level0.button.onRelease
_level0.clip.onMouseDown
Focus at: _level0.text
_level0.clip.onMouseUp
_level0.clip.onMouseDown
Focus at: null
_level0.clip.onPress
_level0.clip.onMouseUp
_level0.clip.onRelease
_level0.clip.onMouseDown
Focus at: _level0.text
_level0.clip.onMouseUp
_level0.clip.onMouseDown
_level0.clip.onMouseUp
20 changes: 20 additions & 0 deletions tests/tests/swfs/avm1/focus_mouse/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var listener = new Object();
listener.onSetFocus = function(oldFocus, newFocus) {
trace("Focus at: " + newFocus);
};
Selection.addListener(listener);

function setHandlers(obj) {
obj.onRelease = function () { trace(obj + ".onRelease"); }
obj.onKeyDown = function () { trace(obj + ".onKeyDown"); }
obj.onKeyUp = function () { trace(obj + ".onKeyUp"); }
obj.onPress = function () { trace(obj + ".onPress"); }
obj.onReleaseOutside = function () { trace(obj + ".onReleaseOutside"); }
obj.onMouseDown = function () { trace(obj + ".onMouseDown") }
obj.onMouseUp = function () { trace(obj + ".onMouseUp") }
}

clip.focusEnabled = true;
setHandlers(clip);
setHandlers(button);
setHandlers(text);
Binary file added tests/tests/swfs/avm1/focus_mouse/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/avm1/focus_mouse/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1

0 comments on commit cc70686

Please sign in to comment.