Created
December 23, 2010 06:11
-
-
Save kristoferjoseph/752642 to your computer and use it in GitHub Desktop.
All the rigamarole needed to test a Flex 4 skin
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
//AS3/////////////////////////////////////////////////////////////////////////// | |
// | |
// Copyright 2010 Kristofer Joseph. | |
// | |
//////////////////////////////////////////////////////////////////////////////// | |
package com.developsigner.view.skins | |
{ | |
import org.flexunit.Assert; | |
import org.flexunit.async.Async; | |
import org.fluint.uiImpersonation.UIImpersonator; | |
import com.developsigner.view.components.Button; | |
import com.developsigner.view.skins.DamButtonSkin; | |
import mx.events.FlexEvent; | |
import flash.utils.getQualifiedClassName; | |
public class ButtonSkinTest | |
{ | |
private var _button:Button; | |
private var _buttonSkin:DamButtonSkin; | |
[Before(async,ui)] | |
public function setUp():void | |
{ | |
_button = new Button(); | |
_buttonSkin = new DamButtonSkin(); | |
_button.setStyle("skinClass", Class(DamButtonSkin)); | |
Async.proceedOnEvent( this, _button, FlexEvent.CREATION_COMPLETE, 200 ); | |
UIImpersonator.addChild( _button ); | |
} | |
[After] | |
public function tearDown():void | |
{ | |
UIImpersonator.removeChild( _button ); | |
_button = null; | |
_buttonSkin = null; | |
} | |
[BeforeClass] | |
public static function setUpBeforeClass():void | |
{ | |
} | |
[AfterClass] | |
public static function tearDownAfterClass():void | |
{ | |
} | |
[Test] | |
public function shouldHaveMinHeight():void | |
{ | |
Assert.assertEquals( 21, _buttonSkin.minHeight ); | |
} | |
[Test] | |
public function shouldHaveMinWidth():void | |
{ | |
Assert.assertEquals( 110, _buttonSkin.minWidth ); | |
} | |
[Test] | |
public function shouldHaveCornerRadiusSet():void | |
{ | |
_button.setStyle("cornerRadius", 5); | |
Assert.assertEquals( "Should have correct corner radius", 5, _button.skin.getStyle("cornerRadius") ); | |
} | |
[Test] | |
public function shouldHaveCorrectSkinSet():void | |
{ | |
Assert.assertEquals( "com.developsigner.view.skins::DamButtonSkin", getQualifiedClassName(_button.skin) ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment