http://uzzu.github.com/blog/2013/01/09/stage-reference-in-flexunit4/
Last active
December 10, 2015 20:58
-
-
Save uzzu/4491370 to your computer and use it in GitHub Desktop.
Stage reference in FlexUnit4 method A.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Stage; | |
import org.flexunit.asserts.assertNotNull; | |
import org.flexunit.assertThat; | |
import org.hamcrest.core.isA; | |
public class ATest | |
{ | |
[Test] | |
public function referToTheStage():void | |
{ | |
assertNotNull(ATestContext.virtualRoot.stage); | |
assertThat(ATestContext.virtualRoot.stage, isA(Stage)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.DisplayObjectContainer; | |
public class ATestContext | |
{ | |
public static var virtualRoot:DisplayObjectContainer; | |
public function ATestContext() | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" | |
creationComplete="onCreationComplete()" | |
xmlns:flexUnitUIRunner="http://www.adobe.com/2009/flexUnitUIRunner" | |
styleName="flexUnitApplication"> | |
<mx:Script> | |
<![CDATA[ | |
import mx.core.UIComponent; | |
import org.flexunit.listeners.UIListener; | |
import org.flexunit.runner.FlexUnitCore; | |
public var core:FlexUnitCore; | |
public function onCreationComplete():void | |
{ | |
var uiComponent:UIComponent = new UIComponent(); | |
addChildAt(uiComponent, 0); | |
ATestContext.virtualRoot = uiComponent; // ATestContextは任意のクラス | |
core = new FlexUnitCore(); | |
core.addListener(new UIListener(uiListener)); | |
core.run(ATestSuite); | |
} | |
]]> | |
</mx:Script> | |
<flexUnitUIRunner:TestRunnerBase id="uiListener" | |
width="100%" | |
height="100%" /> | |
</mx:Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
[Suite] | |
[RunWith("org.flexunit.runners.Suite")] | |
public class ATestSuite | |
{ | |
public var aTest:ATest; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment