Skip to content

Commit

Permalink
tests: Port remainder of shumway tests over
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Feb 18, 2024
1 parent 0eab440 commit 8d9b50d
Show file tree
Hide file tree
Showing 406 changed files with 4,208 additions and 0 deletions.
126 changes: 126 additions & 0 deletions tests/tests/swfs/from_shumway/3_joystick/code/Interactivity3.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package code
{
/*****************************************
* Interactivity3 :
* Demonstrates movement controlled by a joystick.
* http://www.adobe.com/devnet/actionscript/samples/interactivity_3.html
* -------------------
* See 3_joystick.fla
****************************************/

import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;

public class Interactivity3 extends MovieClip
{
//*************************
// Properties:

public var initx:Number = 0;
public var inity:Number = 0;
public var tension:Number = .5;
public var decay:Number = .5;
public var xSpeed:Number = 0;
public var dragging:Boolean = false;
private var moved:Boolean = false;

//*************************
// Constructor:

public function Interactivity3()
{
trace('Interactivity3 init');
initx = joystick.x;
inity = joystick.y;

// Respond to mouse events
joystick.addEventListener(MouseEvent.MOUSE_DOWN,dragPressHandler);
stage.addEventListener(MouseEvent.MOUSE_UP,dragReleaseHandler);

// Update screen every frame
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}

//*************************
// Event Handling:

protected function dragPressHandler(event:MouseEvent):void
{
trace('dragPressHandler');
dragging = true;
}

protected function dragReleaseHandler(event:MouseEvent):void
{
trace('dragReleaseHandler');
dragging = false;
}

protected function enterFrameHandler(event:Event):void
{
with( joystick )
{
if( dragging )
{
// Calculate the angle
// of the joystick
var angle = Math.atan2(root.mouseY-inity,root.mouseX-initx)/(Math.PI/180);
rotation = angle;

with( knob )
{
// Rotate the knob inversely to
// the rotation of the whole joystick
rotation = -angle;

// Drag the joystick but constrain it
// to a circle with a radius of 75
x = parent.mouseX;
if( x > 75 ){
x = 75;
}
}
with( beetle )
{
// Set rotation of beetle equal to
// the rotation of the joystick
rotation = angle;

// Loop to opposite side of the masked
// area when the beetle travels off-screen
if( y < 0 ) {
y = 231;
}
if( y > 231 ){
y = 0;
}
if( x < 231 ){
x = 465;
}
if (x > 370 && !moved) {
moved = true;
trace('wrap');
}
if( x > 465 ){
x = 231;
}
// Move the beetle in proportion to how far
// the joystick is dragged from its center
y += Math.sin(angle*(Math.PI/180))*(knob.x/8);
x += Math.cos(angle*(Math.PI/180))*(knob.x/8);
}
// Scale the length of the joystick shaft
shaft.width = (knob.x-shaft.x);
shaft.alpha = 1;
}
else{
// Snap back to center when the joystick is released
xSpeed = -knob.x*tension+(xSpeed*decay);
knob.x += xSpeed;
shaft.alpha = 0;
}
}
}
}
}
24 changes: 24 additions & 0 deletions tests/tests/swfs/from_shumway/3_joystick/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{"type": "Wait"},
{"type": "MouseMove", "pos": [115.1, 116]},
{"type": "Wait"},
{"type": "MouseDown", "pos": [115.1, 116], "btn": "Left"},
{"type": "Wait"},
{"type": "MouseMove", "pos": [135.1, 116]},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "Wait"},
{"type": "MouseUp", "pos": [135.1, 116], "btn": "Left"},
{"type": "Wait"}
]
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/from_shumway/3_joystick/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Interactivity3 init
dragPressHandler
wrap
dragReleaseHandler
Binary file added tests/tests/swfs/from_shumway/3_joystick/test.fla
Binary file not shown.
Binary file added tests/tests/swfs/from_shumway/3_joystick/test.swf
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests/swfs/from_shumway/3_joystick/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
num_ticks = 20

[image_comparisons.output]
tolerance = 3

[player_options]
with_renderer = { optional = true, sample_count = 1 }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
20 changes: 20 additions & 0 deletions tests/tests/swfs/from_shumway/MaskTest/test.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package {

import flash.display.MovieClip;
import flash.display.Sprite;

public class MaskTest extends MovieClip {
public function MaskTest() {
graphics.beginFill(0xFF00FF);
graphics.drawCircle(100, 100, 100);
graphics.endFill();

var sprite : Sprite = new Sprite();
sprite.graphics.beginFill(0xFF00FF);
sprite.graphics.drawRect(20, 0, 160, 200);
sprite.graphics.endFill();

mask = sprite;
}
}
}
Binary file added tests/tests/swfs/from_shumway/MaskTest/test.swf
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/tests/swfs/from_shumway/MaskTest/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
num_frames = 1

[image_comparisons.output]
tolerance = 0

[player_options]
with_renderer = { optional = false, sample_count = 1 }
Empty file.
Binary file added tests/tests/swfs/from_shumway/MaskTest2/test.fla
Binary file not shown.
Binary file added tests/tests/swfs/from_shumway/MaskTest2/test.swf
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/tests/swfs/from_shumway/MaskTest2/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
num_frames = 1
known_failure = true

[image_comparisons.output]
tolerance = 3

[player_options]
with_renderer = { optional = false, sample_count = 1 }
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/from_shumway/MaskTest3/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[object Shape]
null
[object Sprite]
null
Binary file added tests/tests/swfs/from_shumway/MaskTest3/test.fla
Binary file not shown.
Binary file added tests/tests/swfs/from_shumway/MaskTest3/test.swf
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/tests/swfs/from_shumway/MaskTest3/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
num_frames = 4
known_failure = true

[image_comparisons.output]
tolerance = 3

[player_options]
with_renderer = { optional = false, sample_count = 1 }
11 changes: 11 additions & 0 deletions tests/tests/swfs/from_shumway/add/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
3
NaN
NaN
_level0a
NaN
1a
a1
NaN
nulla
b[type Function]
[type Object]c
Binary file added tests/tests/swfs/from_shumway/add/test.fla
Binary file not shown.
Binary file added tests/tests/swfs/from_shumway/add/test.swf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/from_shumway/add/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 1
5 changes: 5 additions & 0 deletions tests/tests/swfs/from_shumway/as3-interfaces/Interface1.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package {
public interface Interface1 {
function run():void;
}
}
41 changes: 41 additions & 0 deletions tests/tests/swfs/from_shumway/as3-interfaces/LoadService.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Compiled with:
node utils/compileabc.js --swf LoadService,100,100,60 -p test/swfs/as3-interfaces/Interface1.as test/swfs/as3-interfaces/LoadService.as
*/

package {
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.fscommand;
import Interface1;

public class LoadService extends Sprite {

private var _loader:Loader;

public function LoadService() {
trace('loading started');
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete);
addChild(_loader);
_loader.load(new URLRequest("./Service1.swf"));
}

private function loader_complete(event:Event):void {
trace("loading complete");

var content: * = _loader.content;
var service_as: Interface1 = content as Interface1;
trace('content as Interface1 != null: ' + (service_as != null));

var service_co: Interface1 = Interface1(content);
trace(service_co);
service_co.run();

fscommand('quit');
}
}

}
23 changes: 23 additions & 0 deletions tests/tests/swfs/from_shumway/as3-interfaces/Service1.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Compiled with:
node utils/compileabc.js --swf Service1,100,100,60 -p test/swfs/as3-interfaces/Interface1.as test/swfs/as3-interfaces/Service1.as
*/

package {
import flash.display.Sprite;
import flash.events.Event;
import Interface1;

public class Service1 extends Sprite implements Interface1 {
public function Service1() {
trace('service initialized');
}

public function run(): void {
trace('service: run()');
graphics.clear();
graphics.beginFill( 0x00FF00);
graphics.drawRect(0, 0, 100, 100);
}
}
}
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/tests/swfs/from_shumway/as3-interfaces/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
loading started
service initialized
loading complete
content as Interface1 != null: true
[object Service1]
service: run()
Binary file not shown.
1 change: 1 addition & 0 deletions tests/tests/swfs/from_shumway/as3-interfaces/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 2
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loadee frame executed
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 2
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is not a valid SWF file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
num_ticks = 2
9 changes: 9 additions & 0 deletions tests/tests/swfs/from_shumway/as3-loader/events/Child.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package {
import flash.display.MovieClip;

public class Child extends MovieClip {
public function Child() {
trace('construct ' + this.name + ', parent: ' + parent);
}
}
}
14 changes: 14 additions & 0 deletions tests/tests/swfs/from_shumway/as3-loader/events/LoaderEvents.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package {
import flash.display.MovieClip;
import flash.events.Event;

public class LoaderEvents extends MovieClip {
public function LoaderEvents() {
var self = this;
trace('constructed ' + this.name);
addEventListener(Event.ADDED, function(e) {
trace('added ' + e.target['name']);
});
}
}
}
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 8d9b50d

Please sign in to comment.