diff --git a/build_and_copy.sh b/build_and_copy.sh new file mode 100644 index 0000000..bc37201 --- /dev/null +++ b/build_and_copy.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./build.py -t all +cp org/flex_pilot/FlexPilot.swf tests +(cd tests && ./build.py -t all) diff --git a/src/org/flex_pilot/FPController.as b/src/org/flex_pilot/FPController.as index 25b4a6d..5b4c7b6 100644 --- a/src/org/flex_pilot/FPController.as +++ b/src/org/flex_pilot/FPController.as @@ -23,6 +23,7 @@ package org.flex_pilot { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import mx.events.* + import mx.controls.DateField; public class FPController { public function FPController():void {} @@ -325,7 +326,14 @@ package org.flex_pilot { // Do nothing } } - + + public static function date(params:Object):void { + // Look up the item to write to + var obj:* = FPLocator.lookupDisplayObject(params); + obj.selectedDate = DateField.stringToDate(params.date, "MM/DD/YYYY"); + Events.triggerCalendarLayoutChangeEvent(obj); + } + public static function getTextValue(params:Object):String { // Look up the item where we want to get the property var obj:* = FPLocator.lookupDisplayObject(params); diff --git a/src/org/flex_pilot/FPRecorder.as b/src/org/flex_pilot/FPRecorder.as index 6e3e5b9..ba7225d 100644 --- a/src/org/flex_pilot/FPRecorder.as +++ b/src/org/flex_pilot/FPRecorder.as @@ -28,8 +28,10 @@ package org.flex_pilot { import flash.events.KeyboardEvent; import flash.external.ExternalInterface; import mx.events.ListEvent; + import mx.events.CalendarLayoutChangeEvent; import mx.controls.ComboBox; import mx.controls.List; + import mx.controls.DateField; import mx.core.IRawChildrenContainer; public class FPRecorder { @@ -69,6 +71,10 @@ package org.flex_pilot { FPRecorder.listItems.push(item); item.addEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); } + if (item is DateField) { + FPRecorder.listItems.push(item); + item.addEventListener(CalendarLayoutChangeEvent.CHANGE, FPRecorder.handleEvent); + } if (item is DisplayObjectContainer) { if (item is IRawChildrenContainer) { count = item.rawChildren.numChildren; @@ -98,7 +104,6 @@ package org.flex_pilot { stage.addEventListener(MouseEvent.DOUBLE_CLICK, FPRecorder.handleEvent); stage.addEventListener(TextEvent.LINK, FPRecorder.handleEvent); stage.addEventListener(KeyboardEvent.KEY_DOWN, FPRecorder.handleEvent); - FPRecorder.running = true; } @@ -109,17 +114,28 @@ package org.flex_pilot { stage.removeEventListener(MouseEvent.DOUBLE_CLICK, FPRecorder.handleEvent); stage.removeEventListener(TextEvent.LINK, FPRecorder.handleEvent); stage.removeEventListener(KeyboardEvent.KEY_DOWN, FPRecorder.handleEvent); + var list:Array = FPRecorder.listItems; for each (var item:* in list) { - item.removeEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); + if (item is ComboBox || item is List) { + item.removeEventListener(ListEvent.CHANGE, FPRecorder.handleEvent); + } + if (item is DateField) { + item.removeEventListener(CalendarLayoutChangeEvent.CHANGE, FPRecorder.handleEvent); + } } } private static function handleEvent(e:*):void { + if (!FPRecorder.running) { return; } var targ:* = e.target; var _this:* = FPRecorder; var chain:String = FPLocator.generateLocator(targ); - + + if (e.target is DateField) { + _this.generateAction("date", targ, {date: DateField.dateToString(e.newDate, "MM/DD/YYYY")}); + return; + } switch (e.type) { // Keyboard input -- append to the stored string reference case KeyboardEvent.KEY_DOWN: @@ -239,9 +255,15 @@ package org.flex_pilot { case 'select': var sel:* = targ.selectedItem; // Can set a custom label field via labelField attr - var labelField:String = targ.labelField ? - targ.labelField : 'label'; - params.label = sel[labelField]; + try { + var labelField:String = targ.labelField ? + targ.labelField : 'label'; + params.label = sel[labelField]; + } + catch (e:Error) { + var idx:* = targ.selectedIndex; + params.index = idx; + } break; case 'type': break; diff --git a/src/org/flex_pilot/FlexPilot.as b/src/org/flex_pilot/FlexPilot.as index 894a604..e1f305c 100644 --- a/src/org/flex_pilot/FlexPilot.as +++ b/src/org/flex_pilot/FlexPilot.as @@ -16,7 +16,7 @@ Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc. package org.flex_pilot { import com.adobe.serialization.json.JSON; - + import org.flex_pilot.astest.ASTest; import org.flex_pilot.FPLocator; import org.flex_pilot.FPController; diff --git a/src/org/flex_pilot/events/Events.as b/src/org/flex_pilot/events/Events.as index d7efa82..0a30b3d 100644 --- a/src/org/flex_pilot/events/Events.as +++ b/src/org/flex_pilot/events/Events.as @@ -146,6 +146,7 @@ package org.flex_pilot.events { p.ctrlKey, p.altKey, p.shiftKey); obj.dispatchEvent(ev); } + public static function triggerListEvent(obj:*, type:String, ...args):void { // AS3 Object keys don't iterate in insertion order @@ -163,6 +164,20 @@ package org.flex_pilot.events { p.itemRenderer); obj.dispatchEvent(ev); } + + public static function triggerCalendarLayoutChangeEvent(obj:*, + ...args):void { + var defaults:Array = [ + ['bubbles', false], // Don't override -- the real one doesn't bubble + ['cancelable', false], + ['newDate', null], + ['triggerEvent', new Event("change")] + ]; + var p:Object = Events.normalizeParams(defaults, args); + var ev:CalendarLayoutChangeEvent = new CalendarLayoutChangeEvent("change", + p.bubbles, p.cancelable, p.newDate, p.triggerEvent); + obj.dispatchEvent(ev); + } } } diff --git a/tests/GetDocumentName.as b/tests/GetDocumentName.as new file mode 100644 index 0000000..c5eec7b --- /dev/null +++ b/tests/GetDocumentName.as @@ -0,0 +1,106 @@ +package +{ + + import flash.display.DisplayObject; + import flash.events.MouseEvent; + + import mx.containers.ControlBar; + import mx.containers.Panel; + import mx.containers.VBox; + import mx.controls.Button; + import mx.controls.Label; + import mx.controls.Spacer; + import mx.controls.TextInput; + import mx.managers.PopUpManager; + import mx.styles.StyleManager; + + public class GetDocumentName + { + private var panel:Panel; + private var parent:DisplayObject; + private var textInput:TextInput; + + + public function GetDocumentName(parent:DisplayObject) : void + { + var vb:VBox = new VBox(); + vb.percentWidth = 100; + var label:Label = new Label(); + var subHeader:Label = new Label(); + textInput = new TextInput(); + + var cb:ControlBar = new ControlBar(); + cb.percentWidth = 100; + var s:Spacer = new Spacer(); + var b1:Button = new Button(); + var b2:Button = new Button(); + + this.parent = parent; + + s.width = 100; + + textInput.maxChars = 50; + textInput.percentWidth = 100; + textInput.automationName = "modalSaveCancelButton"; + + b1.label = "Save"; + b1.addEventListener(MouseEvent.CLICK, setName); + b1.automationName = "modalSaveSaveButton"; + b1.width = 80; + b2.label = "Cancel"; + b2.automationName = "modalSaveCancelButton"; + b2.addEventListener(MouseEvent.CLICK, closePopUp); + b2.width = 80; + + cb.addChild(s); + cb.addChild(b2); + cb.addChild(b1); + + label.text = "Project Name:"; + label.percentWidth = 100; + + subHeader.text = "Enter your project name, and then click Save."; + subHeader.percentWidth = 100; + + + vb.setStyle("paddingBottom", 5); + vb.setStyle("paddingLeft", 5); + vb.setStyle("paddingRight", 5); + vb.setStyle("paddingTop", 5); + vb.addChild(subHeader); + vb.addChild(label); + vb.addChild(textInput); + + panel = new Panel(); + panel.title = "Save Your Project"; + panel.width = 300; + panel.height = 175; + panel.addChild(vb); + panel.addChild(cb); + panel.automationName = "modalDialogSave"; + } + + private function setName(evt:MouseEvent):void + { + + PopUpManager.removePopUp(panel); + } + + private function closePopUp(evt:MouseEvent):void + { + PopUpManager.removePopUp(panel); + } + + public function ShowPopUp(defaultName:String="Untitled Project") : void + { + var projName:String; + + PopUpManager.addPopUp(panel, parent, true); + PopUpManager.centerPopUp(panel); + this.textInput.text = defaultName; + this.textInput.selectionBeginIndex = 0; + this.textInput.selectionEndIndex = textInput.length; + this.textInput.setFocus(); + } + } +} \ No newline at end of file diff --git a/tests/TestAccordion.html b/tests/TestAccordion.html new file mode 100644 index 0000000..150d861 --- /dev/null +++ b/tests/TestAccordion.html @@ -0,0 +1,44 @@ + + + + + + + + + + +
+
+ + diff --git a/tests/accordion.html b/tests/TestBasic.html similarity index 96% rename from tests/accordion.html rename to tests/TestBasic.html index 87cc8f9..297b4dc 100644 --- a/tests/accordion.html +++ b/tests/TestBasic.html @@ -8,7 +8,7 @@ var testApp; function init() { var html = ''; - var swfName = 'TestAccordion.swf'; + var swfName = 'TestBasic.swf'; if (document.all) { html = '' + @@ -25,9 +25,9 @@ document.getElementById('testAppContainer').innerHTML = html; testApp = document.getElementById('testApp') } - /*function wmClick(p) { + function wmClick(p) { testApp.wm_click(p); - }*/ + } window.onload = init; + + +
+
+ + diff --git a/tests/TestCalendar.mxml b/tests/TestCalendar.mxml new file mode 100644 index 0000000..9459e36 --- /dev/null +++ b/tests/TestCalendar.mxml @@ -0,0 +1,30 @@ + + + + + + + + + + MM/DD/YY + MM/DD/YYYY + DD/MM/YY + DD/MM/YYYY + DD MM, YYYY + + + + + + \ No newline at end of file diff --git a/tests/TestRaw.html b/tests/TestRaw.html new file mode 100644 index 0000000..5620f24 --- /dev/null +++ b/tests/TestRaw.html @@ -0,0 +1,44 @@ + + + + + + + + + + +
+
+ + diff --git a/tests/TestRaw.mxml b/tests/TestRaw.mxml new file mode 100644 index 0000000..45d9755 --- /dev/null +++ b/tests/TestRaw.mxml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/build.py b/tests/build.py index 76c3ee8..9051ed6 100755 --- a/tests/build.py +++ b/tests/build.py @@ -12,7 +12,7 @@ as_re = re.compile('\.as$|\.mxml$') def app(): - cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestApp.mxml -o ./TestApp.swf' + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestBasic.mxml -o ./TestBasic.swf' print cmd os.system(cmd) @@ -21,6 +21,16 @@ def accordion(): print cmd os.system(cmd) +def calendar(): + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestCalendar.mxml -o ./TestCalendar.swf' + print cmd + os.system(cmd) + +def raw(): + cmd = MXMLC_PATH + ' -source-path=. -source-path+=../src ./TestRaw.mxml -o ./TestRaw.swf' + print cmd + os.system(cmd) + def tests(): for root, dirs, file_list in os.walk('./'): for file in file_list: @@ -36,7 +46,7 @@ def tests(): def clean(): for root, dirs, file_list in os.walk('./'): for file in file_list: - if file.endswith('.swf') or file.endswith('.swc'): + if file.endswith('.swf') or file.endswith('.swc') or file.endswith('.swf.cache'): path = root + '/' + file cmd = 'rm ' + path #print cmd @@ -64,6 +74,8 @@ def main(o, a): elif target == 'all': app() accordion() + calendar() + raw() tests() # Clean out any swfs in the directory elif target == 'clean': diff --git a/tests/index.html b/tests/index.html index b64a3ab..c9bfcc6 100644 --- a/tests/index.html +++ b/tests/index.html @@ -1,68 +1,21 @@ - - - - - - - - - - -
-

Testin' Flash

-
-
Here's a text input
-
-
 
-
Here's a select
-
- -
-
 
-
Here are some radio buttons
-
-  Geddy -  Neil -  Alex -
-
-
-
-
- + + + + + + Flex Test Index + + + + + +

Flex Test Application Index

+ + diff --git a/tests/se_tests/TestAccordion.sel b/tests/se_tests/TestAccordion.sel new file mode 100644 index 0000000..02c471b --- /dev/null +++ b/tests/se_tests/TestAccordion.sel @@ -0,0 +1,62 @@ + + + + + + +TestAccordion + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestAccordion
open/TestAccordion.html
waitForFlexReadyid=testApp
flexClickid=testAppchain=id:testApp/id:accordion1/id:shippingAddress/id:sfirstNameItem/id:sfirstName
flexTypeid=testApptext=first name,chain=id:testApp/id:accordion1/id:shippingAddress/id:sfirstNameItem/id:sfirstName
flexClickid=testApplabel=2. Billing Address,chain=id:testApp/id:accordion1
flexClickid=testAppchain=id:backButton
flexClickid=testApplabel=2. Billing Address,chain=id:testApp/id:accordion1
flexClickid=testAppchain=id:nextButton
flexClickid=testApplabel=1. Shipping Address,chain=id:testApp/id:accordion1
+ + diff --git a/tests/se_tests/TestBasic.sel b/tests/se_tests/TestBasic.sel new file mode 100644 index 0000000..245d55f --- /dev/null +++ b/tests/se_tests/TestBasic.sel @@ -0,0 +1,72 @@ + + + + + + +TestBasic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestBasic
open/TestBasic.html
waitForFlexReadyid=testApp
flexClickid=testAppchain=name:testTextArea/name:UITextField18
flexTypeid=testApptext=testing,chain=name:testTextArea/name:UITextField18
flexClickid=testAppchain=id:howdyButton
flexTypeid=testApptext=smaller box,chain=name:testTextInput/name:UITextField23
flexClickid=testAppchain=name:comboTest/name:Button36
flexSelectid=testApplabel=Geddy,chain=name:comboTest
flexDragDropElemToElemid=testAppchain=name:dragSprite, optchain=id:howdyButton
flexClickid=testAppchain=name:comboTest/name:Button36
flexSelectid=testApplabel=Alex,chain=name:comboTest
+ + diff --git a/tests/se_tests/TestRaw.sel b/tests/se_tests/TestRaw.sel new file mode 100644 index 0000000..3a126e4 --- /dev/null +++ b/tests/se_tests/TestRaw.sel @@ -0,0 +1,57 @@ + + + + + + +TestRaw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestRaw
open/TestRaw.html
waitForFlexReadyid=testApp
flexClickid=testAppchain=id:testApp/id:views/id:c1/automationName:testButton
flexClickid=testAppchain=id:testApp/automationName:viewButton
flexClickid=testAppchain=id:testApp/id:views/id:c2/automationName:testButton
flexClickid=testAppchain=id:testApp/id:views/id:c2/id:testPopUp2
flexTypeid=testApptext=asdasd,chain=automationName:modalSaveCancelButton/name:UITextField*
flexClickid=testAppchain=automationName:modalSaveSaveButton
+ +