Created
November 8, 2010 16:59
-
-
Save Stray/667941 to your computer and use it in GitHub Desktop.
Example roboteyes actual UI Test
This file contains hidden or 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 com.client.project.xendtoendtests { | |
| import asunit.framework.TestCase; | |
| import AcademyShell; | |
| import shell.AcademyShellSkin; | |
| import com.newloop.roboteyes.inViewOf; | |
| import com.newloop.roboteyes.core.RobotEyes; | |
| import com.newloop.roboteyes.drivers.DisplayObjectDriver; | |
| import com.newloop.roboteyes.drivers.TextFieldDriver; | |
| import com.newloop.roboteyes.drivers.InteractiveObjectDriver; | |
| import com.client.project.shell.restricted.ShellContextView; | |
| import com.client.project.shell.restricted.view.LoginPanel; | |
| import flash.display.DisplayObject; | |
| import flash.display.InteractiveObject; | |
| import flash.display.Sprite; | |
| import flash.utils.Timer; | |
| import flash.events.TimerEvent; | |
| import flash.events.Event; | |
| import flash.text.TextField; | |
| public class LoginIncorrectlyTest extends TestCase { | |
| private var robotEyes:RobotEyes; | |
| public function LoginIncorrectlyTest(methodName:String=null) { | |
| super(methodName) | |
| } | |
| override public function run():void{ | |
| if(robotEyes==null){ | |
| robotEyes = new RobotEyes(AcademyShell); | |
| addChild(robotEyes); | |
| robotEyes.visible = false; | |
| } | |
| // need to wait a while | |
| var timer:Timer = new Timer(1000,1); | |
| timer.addEventListener(TimerEvent.TIMER, timerHandler); | |
| timer.start(); | |
| } | |
| private function timerHandler(e:TimerEvent):void{ | |
| robotEyes.visible = true; | |
| super.run(); | |
| } | |
| override protected function setUp():void { | |
| super.setUp(); | |
| } | |
| override protected function tearDown():void { | |
| super.tearDown(); | |
| } | |
| override protected function cleanUp():void{ | |
| removeChild(robotEyes); | |
| robotEyes = null; | |
| } | |
| public function testEndToEndProcessFail():void{ | |
| var textFieldDriver:TextFieldDriver = inViewOf(LoginPanel).getA(TextField).named("username_txt") as TextFieldDriver; | |
| textFieldDriver.enterText('Another User'); | |
| var passwordTextFieldDriver:TextFieldDriver = iinViewOf(LoginPanel).getA(TextField).named("password_txt") as TextFieldDriver; | |
| passwordTextFieldDriver.enterText('Some password'); | |
| var buttonDriver:InteractiveObjectDriver = inViewOf(LoginPanel).getA(Sprite).withProperty("name", "btn_login") as InteractiveObjectDriver; | |
| var asyncTest:Function = addAsync(null, 4000,loginShouldBeOnScreen); | |
| buttonDriver.click(); | |
| } | |
| public function loginShouldBeOnScreen(e:Event):void{ | |
| var loginScreenDriver:DisplayObjectDriver = inViewOf(ShellContextView).getA(LoginPanel); | |
| var loginScreen:DisplayObject = loginScreenDriver.view; | |
| assertTrue('LoginPanel is on screen', (loginScreen.y == 0)); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment