Skip to content

Commit

Permalink
tests: Add tests for early SimpleButton allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Nov 26, 2023
1 parent daea056 commit bcd6e28
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 7 deletions.
3 changes: 3 additions & 0 deletions tests/tests/swfs/avm2/simplebutton_childevents/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@


public var my_button:SimpleButton;

public static var INSTANCE: Main;

public function Main()
{
INSTANCE = this;
var self:*;

addFrameScript(0,this.frame1,1,this.frame2);
Expand Down
16 changes: 16 additions & 0 deletions tests/tests/swfs/avm2/simplebutton_childevents/MyButton.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package {

import flash.display.SimpleButton;


public class MyButton extends SimpleButton {


public function MyButton() {
trace("Calling MyButton super()");
super();
trace("Called MyButton super()");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public class UpButtonShape extends EventWatcher {
public function UpButtonShape() {
trace("//Constructed UpButtonShape (", this.name, "): this.parent = " + this.parent + " this.stage " + this.stage);
trace("//Constructed UpButtonShape (", this.name, "): this.parent = " + this.parent + " this.stage " + this.stage + " Main.INSTANCE.my_button = " + Main.INSTANCE.my_button);
}
}

Expand Down
6 changes: 4 additions & 2 deletions tests/tests/swfs/avm2/simplebutton_childevents/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instance2:[Event type="added" bubbles=true cancelable=false eventPhase=3] target
target.stage: [object Stage] target.name: instance3 target.parent: [object UpButtonShape] target.parent.parent: null
root1:[Event type="added" bubbles=true cancelable=false eventPhase=3] target: [object Shape]
target.stage: [object Stage] target.name: instance3 target.parent: [object UpButtonShape] target.parent.parent: null
//Constructed UpButtonShape ( instance2 ): this.parent = null this.stage [object Stage]
//Constructed UpButtonShape ( instance2 ): this.parent = null this.stage [object Stage] Main.INSTANCE.my_button = [object MyButton]
instance4:[Event type="added" bubbles=true cancelable=false eventPhase=3] target: [object Shape]
target.stage: [object Stage] target.name: instance5 target.parent: [object OverButtonShape] target.parent.parent: null
root1:[Event type="added" bubbles=true cancelable=false eventPhase=3] target: [object Shape]
Expand Down Expand Up @@ -38,7 +38,9 @@ instance4:[Event type="exitFrame" bubbles=false cancelable=false eventPhase=2] t
target.stage: null target.name: instance4 target.parent: null target.parent.parent: <missing>
instance6:[Event type="exitFrame" bubbles=false cancelable=false eventPhase=2] target: [object DownButtonShape]
target.stage: null target.name: instance6 target.parent: null target.parent.parent: <missing>
root1:[Event type="added" bubbles=true cancelable=false eventPhase=3] target: [object SimpleButton]
Calling MyButton super()
Called MyButton super()
root1:[Event type="added" bubbles=true cancelable=false eventPhase=3] target: [object MyButton]
target.stage: [object Stage] target.name: my_button target.parent: [object Main] target.parent.parent: [object Stage]
root1:[Event type="added" bubbles=true cancelable=false eventPhase=2] target: [object Main]
target.stage: [object Stage] target.name: root1 target.parent: [object Stage] target.parent.parent: null
Expand Down
Binary file modified tests/tests/swfs/avm2/simplebutton_childevents/test.fla
Binary file not shown.
Binary file modified tests/tests/swfs/avm2/simplebutton_childevents/test.swf
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/tests/swfs/avm2/simplebutton_symbolclass/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

public dynamic class Main extends MovieClip
{

public static var INSTANCE: Main;


public var timeline_symbol:MyButton;
Expand All @@ -25,7 +27,10 @@

public function Main()
{
INSTANCE = this;
trace("Calling Main super()");
super();
trace("Called Main super()");
addFrameScript(0,this.frame1,1,this.frame2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public class OverButtonShape extends MovieClip {
public function OverButtonShape() {
trace("//Constructed OverButtonShape (", this.name, ")!");
trace("//Constructed OverButtonShape (", this.name, "): Main.INSTANCE.my_button = " + Main.INSTANCE.my_button);
}
}

Expand Down
8 changes: 5 additions & 3 deletions tests/tests/swfs/avm2/simplebutton_symbolclass/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Calling Main super()
Called Main super()
//var my_button = new MyButton();
//Constructed UpButtonShape ( instance3 )!
//Constructed OverButtonShape ( instance5 )!
//Constructed OverButtonShape ( instance5 ): Main.INSTANCE.my_button = undefined
//Constructed DownButtonShape ( instance7 )!
///MyButton constructor!
//this.addChild(my_button);
Expand All @@ -24,7 +26,7 @@
//my_button.upState = new UpButtonShape();
//Constructed UpButtonShape ( instance11 )!
//my_button.overState = new OverButtonShape();
//Constructed OverButtonShape ( instance13 )!
//Constructed OverButtonShape ( instance13 ): Main.INSTANCE.my_button = [object MyButton]
//my_button.downState = new DownButtonShape();
//Constructed DownButtonShape ( instance15 )!
//my_button.hitTestState = new HitButtonShape();
Expand All @@ -46,7 +48,7 @@
// numChildren: 1
[object Shape]
//Constructed UpButtonShape ( instance20 )!
//Constructed OverButtonShape ( instance22 )!
//Constructed OverButtonShape ( instance22 ): Main.INSTANCE.my_button = [object MyButton]
//Constructed DownButtonShape ( instance24 )!
//this.timeline_symbol.upState
[object Sprite]
Expand Down
Binary file modified tests/tests/swfs/avm2/simplebutton_symbolclass/test.swf
Binary file not shown.

0 comments on commit bcd6e28

Please sign in to comment.