Make tests runnable in IDE Remove unnecessary files and methods Added target in ant file for running tests from script - without respons from player to script yet.
Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/e31da7b5 Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/e31da7b5 Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/e31da7b5 Branch: refs/heads/develop Commit: e31da7b59b22434480f1c8554d873d62b4ded475 Parents: cd48715 Author: piotrz <[email protected]> Authored: Sat Sep 27 10:49:12 2014 +0200 Committer: piotrz <[email protected]> Committed: Sat Sep 27 10:49:12 2014 +0200 ---------------------------------------------------------------------- .../src/UnitTest/TestDescriptorRunner.mxml | 6 +- .../src/UnitTest/TestRunnerWindow.mxml | 57 -- .../src/UnitTest/TreeItemRenderer.as | 645 ------------------- automation_apps/src/UntrustingLoader.mxml | 38 -- automation_apps/src/VellumUnit.mxml | 431 ++----------- .../UnitTest/ExtendedClasses/VellumTestCase.as | 10 +- .../src/UnitTest/Fixtures/FileRepository.as | 19 +- .../src/UnitTest/Fixtures/MeasureConstants.as | 16 + .../src/UnitTest/Tests/AllParaAttributeTest.as | 5 +- .../UnitTest/Tests/BoundsAndAlignmentTest.as | 423 ++++++------ build.xml | 16 +- 11 files changed, 315 insertions(+), 1351 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_apps/src/UnitTest/TestDescriptorRunner.mxml ---------------------------------------------------------------------- diff --git a/automation_apps/src/UnitTest/TestDescriptorRunner.mxml b/automation_apps/src/UnitTest/TestDescriptorRunner.mxml index 433032d..25ef01a 100644 --- a/automation_apps/src/UnitTest/TestDescriptorRunner.mxml +++ b/automation_apps/src/UnitTest/TestDescriptorRunner.mxml @@ -16,11 +16,12 @@ limitations under the License. --> <s:Group xmlns:s="library://ns.adobe.com/flex/spark" - xmlns:flexunituirunner="http://www.adobe.com/2009/flexUnitUIRunner" xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:flexunituirunner="http://www.adobe.com/2009/flexUnitUIRunner" xmlns:fx="http://ns.adobe.com/mxml/2009"> <fx:Script> <![CDATA[ import org.flexunit.runner.FlexUnitCore; + import org.flexunit.runner.notification.RunListener; private var core:FlexUnitCore; @@ -28,7 +29,10 @@ { core = new FlexUnitCore(); + core.addUncaughtErrorListener( systemManager.loaderInfo ); + core.addListener(new RunListener()); core.addListener(testRunner); + if (isMinimalTests) { core.run(new MinimalTestsSuite()); http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_apps/src/UnitTest/TestRunnerWindow.mxml ---------------------------------------------------------------------- diff --git a/automation_apps/src/UnitTest/TestRunnerWindow.mxml b/automation_apps/src/UnitTest/TestRunnerWindow.mxml deleted file mode 100644 index ae07920..0000000 --- a/automation_apps/src/UnitTest/TestRunnerWindow.mxml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="475" title="Performance Benchmark Test" borderColor="#000000" backgroundAlpha="1.0"> - <mx:Script> - <![CDATA[ - private var testRun:Boolean=false; - public var runTestFunction:Function; - public var uploadDataFunction:Function; - public var closeFunction:Function; - public var detailedData:String = "1"; - public var summaryData:String = "2"; - - public function viewData():void - { - if (rbDetailed.selected) - lstBenchmarkData.text = detailedData; - else - lstBenchmarkData.text = summaryData; - } - - ]]> - </mx:Script> - <mx:Form backgroundColor="#ffffff" width="100%" top="0" height="100%"> - <mx:VBox width="100%" height="100%" backgroundColor="#ffffff" horizontalGap="0" verticalAlign="middle" verticalGap="0"> - <mx:HBox width="100%" horizontalAlign="right" verticalAlign="middle" height="30"> - <mx:HBox width="100%"> - <mx:Label text="Performance Benchmark Data:" fontWeight="bold"/> - </mx:HBox> - <mx:Label text="View: " fontWeight="bold"/> - <mx:RadioButton label="Detailed" groupName="DataView" id="rbDetailed" click="viewData()" enabled="true"/> - <mx:RadioButton label="Summary" groupName="DataView" id="rbSummary" click="viewData()" enabled="true" selected="true"/> - </mx:HBox> - <mx:HBox width="100%" height="100%"> - <mx:TextArea width="100%" height="100%" id="lstBenchmarkData"/> - </mx:HBox> - </mx:VBox> - </mx:Form> - <mx:ControlBar horizontalAlign="center" verticalAlign="middle"> - <mx:Button label="Upload Performance Data" id="cmdUpload" click="uploadDataFunction()" width="180" enabled="false"/> - <mx:Button label="Close" width="180" id="cmd_Close" click="closeFunction()" color="#000000"/> - </mx:ControlBar> -</mx:Panel> http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_apps/src/UnitTest/TreeItemRenderer.as ---------------------------------------------------------------------- diff --git a/automation_apps/src/UnitTest/TreeItemRenderer.as b/automation_apps/src/UnitTest/TreeItemRenderer.as deleted file mode 100644 index 139b5d5..0000000 --- a/automation_apps/src/UnitTest/TreeItemRenderer.as +++ /dev/null @@ -1,645 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package UnitTest -{ - -import flash.display.DisplayObject; -import flash.display.InteractiveObject; -import flash.events.Event; -import flash.events.MouseEvent; -import flash.geom.Point; -import flash.geom.Rectangle; - -import mx.controls.CheckBox; -import mx.controls.Tree; -import mx.controls.listClasses.BaseListData; -import mx.controls.listClasses.IDropInListItemRenderer; -import mx.controls.listClasses.IListItemRenderer; -import mx.controls.treeClasses.TreeListData; -import mx.core.FlexVersion; -import mx.core.IDataRenderer; -import mx.core.IFlexDisplayObject; -import mx.core.IFlexModuleFactory; -import mx.core.IFontContextComponent; -import mx.core.IToolTip; -import mx.core.SpriteAsset; -import mx.core.UIComponent; -import mx.core.mx_internal; -import mx.events.FlexEvent; -import mx.events.ToolTipEvent; -import mx.events.TreeEvent; - -use namespace mx_internal; - -/** - * Dispatched when the <code>data</code> property changes. - * - * <p>When you use a component as an item renderer, - * the <code>data</code> property contains the data to display. - * You can listen for this event and update the component - * when the <code>data</code> property changes.</p> - * - * @eventType mx.events.FlexEvent.DATA_CHANGE - */ -[Event(name="dataChange", type="mx.events.FlexEvent")] - -/** - * Text color of a component label. - * The default value is <code>0x0B333C</code>. - */ -[Style(name="color", type="uint", format="Color", inherit="yes")] - -/** - * Color of the component if it is disabled. - * The default value is <code>0xAAB3B3</code>. - * - */ -[Style(name="disabledColor", type="uint", format="Color", inherit="yes")] - -/** - * The TreeItemRenderer class defines the default item renderer for a Tree control. - * By default, the item renderer draws the text associated with each item in the tree, - * an optional icon, and an optional disclosure icon. - * - * <p>You can override the default item renderer by creating a custom item renderer.</p> - * - * @see mx.controls.Tree - * @see mx.core.IDataRenderer - * @see mx.controls.listClasses.IDropInListItemRenderer - */ -public class TreeItemRenderer extends UIComponent - implements IDataRenderer, IDropInListItemRenderer, IListItemRenderer, - IFontContextComponent -{ - //include "../../core/Version.as"; - - //-------------------------------------------------------------------------- - // - // Constructor - // - //-------------------------------------------------------------------------- - - /** - * Constructor. - */ - public function TreeItemRenderer() - { - super(); - } - - //-------------------------------------------------------------------------- - // - // Variables - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - private var listOwner:Tree; - - //-------------------------------------------------------------------------- - // - // Overridden properties: UIComponent - // - //-------------------------------------------------------------------------- - - //---------------------------------- - // baselinePosition - //---------------------------------- - - /** - * @private - * The baselinePosition of a TreeItemRenderer is calculated - * for its label. - */ - override public function get baselinePosition():Number - { - if (FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0) - super.baselinePosition; - - if (!validateBaselinePosition()) - return NaN; - - return label.y + label.baselinePosition; - } - - //-------------------------------------------------------------------------- - // - // Properties - // - //-------------------------------------------------------------------------- - - //---------------------------------- - // data - //---------------------------------- - - /** - * @private - * Storage for the data property. - */ - private var _data:Object; - - [Bindable("dataChange")] - - /** - * The implementation of the <code>data</code> property as - * defined by the IDataRenderer interface. - * - * @see mx.core.IDataRenderer - */ - public function get data():Object - { - return _data; - } - - /** - * @private - */ - public function set data(value:Object):void - { - _data = value; - - invalidateProperties(); - - dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE)); - } - - //---------------------------------- - // disclosureIcon - //---------------------------------- - - /** - * The internal IFlexDisplayObject that displays the disclosure icon - * in this renderer. - */ - protected var disclosureIcon:IFlexDisplayObject; - - //---------------------------------- - // fontContext - //---------------------------------- - - /** - * @private - */ - public function get fontContext():IFlexModuleFactory - { - return moduleFactory; - } - - /** - * @private - */ - public function set fontContext(moduleFactory:IFlexModuleFactory):void - { - this.moduleFactory = moduleFactory; - } - - //---------------------------------- - // icon - //---------------------------------- - - /** - * The internal IFlexDisplayObject that displays the icon in this renderer. - */ - protected var icon:IFlexDisplayObject; - - //---------------------------------- - // label - //---------------------------------- - - /** - * The internal UITextField that displays the text in this renderer. - */ - protected var label:CheckBox; - - //---------------------------------- - // listData - //---------------------------------- - - /** - * @private - * Storage for the listData property. - */ - private var _listData:TreeListData; - - [Bindable("dataChange")] - - /** - * The implementation of the <code>listData</code> property as - * defined by the IDropInListItemRenderer interface. - * - * @see mx.controls.listClasses.IDropInListItemRenderer - */ - public function get listData():BaseListData - { - return _listData; - } - - /** - * @private - */ - public function set listData(value:BaseListData):void - { - _listData = TreeListData(value); - - invalidateProperties(); - } - - //-------------------------------------------------------------------------- - // - // Overridden methods - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - override protected function createChildren():void - { - super.createChildren(); - - createLabel(-1); - - addEventListener(ToolTipEvent.TOOL_TIP_SHOW, toolTipShowHandler, false, 0, true); - } - - /** - * @private - */ - override protected function commitProperties():void - { - super.commitProperties(); - - // if the font changed and we already created the label, we will need to - // destory it so it can be re-created, possibly in a different swf context. - if (hasFontContextChanged() && label != null) - { - var index:int = getChildIndex(DisplayObject(label)); - removeLabel(); - createLabel(index); - } - - if (icon) - { - removeChild(DisplayObject(icon)); - icon = null; - } - - if (disclosureIcon) - { - disclosureIcon.removeEventListener(MouseEvent.MOUSE_DOWN, - disclosureMouseDownHandler); - removeChild(DisplayObject(disclosureIcon)); - disclosureIcon = null; - } - - if (_data != null) - { - listOwner = Tree(_listData.owner); - - if (_listData.disclosureIcon) - { - var disclosureIconClass:Class = _listData.disclosureIcon; - var disclosureInstance:* = new disclosureIconClass(); - - // If not already an interactive object, then we'll wrap - // in one so we can dispatch mouse events. - if (!(disclosureInstance is InteractiveObject)) - { - var wrapper:SpriteAsset = new SpriteAsset(); - wrapper.addChild(disclosureInstance as DisplayObject); - disclosureIcon = wrapper as IFlexDisplayObject; - } - else - { - disclosureIcon = disclosureInstance; - } - - addChild(disclosureIcon as DisplayObject); - disclosureIcon.addEventListener(MouseEvent.MOUSE_DOWN, - disclosureMouseDownHandler, false, 0, true); - } - /* - if (_listData.icon) - { - var iconClass:Class = _listData.icon; - icon = new iconClass(); - - addChild(DisplayObject(icon)); - } - */ - if (_data.@selected == true) - label.selected = true; - else - label.selected = false; - label.label = _listData.label; - // Booga/ - //label.multiline = listOwner.variableRowHeight; - //label.wordWrap = listOwner.wordWrap; - } - else - { - label.label = " "; - toolTip = null; - } - - invalidateDisplayList(); - } - - /** - * @private - */ - override protected function measure():void - { - super.measure(); - - var w:Number = _data ? _listData.indent : 0; - - if (disclosureIcon) - w += disclosureIcon.width; - - if (icon) - w += icon.measuredWidth; - - // guarantee that label width isn't zero because it messes up ability to measure - if (label.width < 4 || label.height < 4) - { - label.width = 4; - label.height = 16; - } - - if (isNaN(explicitWidth)) - { - w += label.getExplicitOrMeasuredWidth(); - measuredWidth = w; - measuredHeight = label.getExplicitOrMeasuredHeight(); - } - else - { - label.width = Math.max(explicitWidth - w, 4); - measuredHeight = label.getExplicitOrMeasuredHeight(); - if (icon && icon.measuredHeight > measuredHeight) - measuredHeight = icon.measuredHeight; - } - } - - /** - * @private - */ - override protected function updateDisplayList(unscaledWidth:Number, - unscaledHeight:Number):void - { - super.updateDisplayList(unscaledWidth, unscaledHeight); - - var startx:Number = _data ? _listData.indent : 0; - - if (disclosureIcon) - { - disclosureIcon.x = startx; - - startx = disclosureIcon.x + disclosureIcon.width; - - disclosureIcon.setActualSize(disclosureIcon.width, - disclosureIcon.height); - - disclosureIcon.visible = _data ? - _listData.hasChildren : - false; - } - - if (icon) - { - icon.x = startx; - startx = icon.x + icon.measuredWidth; - icon.setActualSize(icon.measuredWidth, icon.measuredHeight); - } - - label.x = startx; - label.setActualSize(unscaledWidth - startx, measuredHeight); - - var verticalAlign:String = getStyle("verticalAlign"); - if (verticalAlign == "top") - { - label.y = 0; - if (icon) - icon.y = 0; - if (disclosureIcon) - disclosureIcon.y = 0; - } - else if (verticalAlign == "bottom") - { - label.y = unscaledHeight - label.height + 2; // 2 for gutter - if (icon) - icon.y = unscaledHeight - icon.height; - if (disclosureIcon) - disclosureIcon.y = unscaledHeight - disclosureIcon.height; - } - else - { - label.y = (unscaledHeight - label.height) / 2; - if (icon) - icon.y = (unscaledHeight - icon.height) / 2; - if (disclosureIcon) - disclosureIcon.y = (unscaledHeight - disclosureIcon.height) / 2; - } - - var labelColor:Number; - - if (data && parent) - { - if (!enabled) - labelColor = getStyle("disabledColor"); - - else if (listOwner.isItemHighlighted(listData.uid)) - labelColor = getStyle("textRollOverColor"); - - else if (listOwner.isItemSelected(listData.uid)) - labelColor = getStyle("textSelectedColor"); - - else - labelColor = getStyle("color"); - - // Booga - Need to fix for Checkbox. - //label.setColor(labelColor); - } - /* Booga - if (_data != null) - { - if (listOwner.showDataTips) - { - if (label.textWidth > label.width || - listOwner.dataTipFunction != null) - { - toolTip = listOwner.itemToDataTip(_data); - } - else - { - toolTip = null; - } - } - else - { - toolTip = null; - } - } - */ - } - - //-------------------------------------------------------------------------- - // - // Methods - // - //-------------------------------------------------------------------------- - - /** - * @private - * Creates the label and adds it as a child of this component. - * - * @param childIndex The index of where to add the child. - * If -1, the text field is appended to the end of the list. - */ - - private function onCheck(eventObj:Event):void - { - if (eventObj.target.selected == false) - { - var xmlParent:XML; - xmlParent = _data.parent(); - while (xmlParent != null) - { - xmlParent.@selected = false; - xmlParent = xmlParent.parent(); - } - } - if (_data.children().length() > 0) - { - checkKids(_data, eventObj.target.selected) - } - _data.@selected = eventObj.target.selected; - } - - private function checkKids(data:Object, state:Boolean):void - { - for each (var f:XML in data) - { - if (f.children().length() > 0) - { - checkKids(f.children(), state); - } - f.@selected = state; - } - } - - mx_internal function createLabel(childIndex:int):void - { - if (!label) - { - label = new CheckBox(); - label.styleName = this; - - if (childIndex == -1) - addChild(DisplayObject(label)); - else - addChildAt(DisplayObject(label), childIndex); - - label.addEventListener(Event.CHANGE, onCheck, false, 0, true); - } - } - - /** - * @private - * Removes the label from this component. - */ - mx_internal function removeLabel():void - { - if (label != null) - { - removeChild(DisplayObject(label)); - label = null; - } - } - - //-------------------------------------------------------------------------- - // - // Event handlers - // - //-------------------------------------------------------------------------- - - /** - * @private - */ - private function toolTipShowHandler(event:ToolTipEvent):void - { - var toolTip:IToolTip = event.toolTip; - - // Calculate global position of label. - var pt:Point = new Point(0, 0); - pt = label.localToGlobal(pt); - pt = stage.globalToLocal(pt); - - toolTip.move(pt.x, pt.y + (height - toolTip.height) / 2); - - var screen:Rectangle = systemManager.screen; - var screenRight:Number = screen.x + screen.width; - if (toolTip.x + toolTip.width > screenRight) - toolTip.move(screenRight - toolTip.width, toolTip.y); - } - - /** - * @private - */ - private function disclosureMouseDownHandler(event:Event):void - { - event.stopPropagation(); - - if (listOwner.isOpening || !listOwner.enabled) - return; - - var open:Boolean = _listData.open; - _listData.open = !open; - - listOwner.dispatchTreeEvent(TreeEvent.ITEM_OPENING, - _listData.item, //item - this, //renderer - event, //trigger - !open, //opening - true, //animate - true) //dispatch - } - - /** - * @private - */ - mx_internal function getLabel():CheckBox - { - return label; - } - - /** - * @private - */ - mx_internal function getDisclosureIcon():IFlexDisplayObject - { - return disclosureIcon; - } - -} - -} http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_apps/src/UntrustingLoader.mxml ---------------------------------------------------------------------- diff --git a/automation_apps/src/UntrustingLoader.mxml b/automation_apps/src/UntrustingLoader.mxml deleted file mode 100644 index f74c683..0000000 --- a/automation_apps/src/UntrustingLoader.mxml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" - xmlns:s="library://ns.adobe.com/flex/spark" - xmlns:mx="library://ns.adobe.com/flex/halo" - xmlns:ns="library://ns.adobe.com/flex/mx" - width="1100" height="800" - > - <fx:Script> - <![CDATA[ - - public function updateSWF():void - { - loader.load(urlField.text); - } - ]]> - </fx:Script> - <s:layout> - <s:VerticalLayout/> - </s:layout> -<s:TextInput id="urlField" width="100%" text="http://aaa.sea.adobe.com/~astearns/explicitFormField.swf" change="updateSWF()"/> -<ns:SWFLoader id="loader" source="http://aaa.sea.adobe.com/~astearns/explicitFormField.swf" trustContent="false"/> -</s:Application> http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_apps/src/VellumUnit.mxml ---------------------------------------------------------------------- diff --git a/automation_apps/src/VellumUnit.mxml b/automation_apps/src/VellumUnit.mxml index b23beb8..7478275 100644 --- a/automation_apps/src/VellumUnit.mxml +++ b/automation_apps/src/VellumUnit.mxml @@ -31,25 +31,16 @@ <Script> <![CDATA[ - import UnitTest.ExtendedClasses.TestDescriptor; import UnitTest.ExtendedClasses.TestSuiteExtended; import UnitTest.ExtendedClasses.VellumTestCase; import UnitTest.Fixtures.FileRepository; import UnitTest.Fixtures.TestApp; import UnitTest.Fixtures.TestConfig; - import UnitTest.MenuItemObj; - import UnitTest.TestRunnerWindow; - import flashx.textLayout.elements.Configuration; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.tlf_internal; import mx.collections.ArrayCollection; - import mx.collections.ListCollectionView; - import mx.collections.Sort; - import mx.collections.SortField; - import mx.controls.Alert; - import mx.managers.PopUpManager; import mx.managers.SystemManager; import mx.managers.systemClasses.MarshallingSupport; import mx.utils.LoaderUtil; @@ -64,7 +55,7 @@ private var socket:XMLSocket; private var curDialog:Object; //TODO: Remove - // private var treeData:XMLList; + // private var treeData:XMLList; private var testCasesList:ArrayCollection; private var useTestSelectDialog:Boolean = false; @@ -91,7 +82,6 @@ private var curURL:String; - private var myLoader:URLLoader = new URLLoader(); private var myXMLURL:URLRequest = new URLRequest(); private var urlReqSnapShotStore:URLRequest = new URLRequest(); @@ -111,10 +101,6 @@ public var testXMLStore:Object = null; public var skipList:Array; - //private var snapshotStack:Array; - - [Bindable] - private var canRun:Boolean = true; // The data from these files is read on creationcomplete and // placed into the store. The raw XML can be accessed using @@ -122,7 +108,7 @@ // Examples: // XFLStore.simple // XFLStore.tableExample - public var XFLFileNameList:Array = [ + public var xmlFileNameList:Array = [ "simple.xml", "tableExample.xml", "asknot.xml", @@ -130,6 +116,7 @@ "sampleArabic.xml", "aliceExcerpt.xml" ]; + public var reportXMLResults:Boolean = false; // this testApp object needs to be used to set @@ -137,6 +124,9 @@ // before any VellumTestCase constructors are called. public var testApp:TestApp = new TestApp(); + private var xmlFileNameListLength:int; + private var xmlFileNameListCounter:int; + public function checkMemoryUsage():void { currentlyUsedMemory = Math.round(System.totalMemory / 1000000); @@ -171,51 +161,6 @@ Font.registerFont(arialFontRoundedMTBold); */ } - /** - * If the testcase counter hasn't reached the end, read another - * testcase XML file. Otherwise load up the tests and start testing - */ - public function readTestCaseFiles():void - { - while (testXMLStore.suiteIndex < testXMLStore.suiteList.children().length()) - { - var fileName:String = testXMLStore.suiteList.*[testXMLStore.suiteIndex].@fileName; - if (fileName.length > 0) - { - FileRepository.readFile(normalizedURL, "../../test/" + fileName, onTestCaseFileRead, null, null, true); - break; - } - ++testXMLStore.suiteIndex; - } - if (testXMLStore.suiteIndex >= testXMLStore.suiteList.children().length()) - { - if (antSkipTestFile != "") - { - FileRepository.readFile(normalizedURL, "../../test/" + antSkipTestFile, readSkipList, loadAndRunTests, loadAndRunTests, true); - } - else - { - loadAndRunTests(); - } - } - } - - public function readSkipList(evtObj:Event):void - { - var fileContents:String = evtObj.target.data; - var lineSeparator:String; - if (fileContents.search("\r") == -1) - { - lineSeparator = "\n"; - } - else - { - lineSeparator = "\r\n"; - } - skipList = evtObj.target.data.split(lineSeparator); - loadAndRunTests(); - } - private function loadAndRunTests(isMinimialTests:Boolean = false):void { var config:TestConfig = TestConfig.getInstance(); @@ -248,117 +193,6 @@ private var xmlRoot:XML = null; - private function createXMLTree(testSuiteTests:Array):XML - { - if (xmlRoot) - return xmlRoot; - - xmlRoot = <root/>; - var curContainer:XML; - var curTestCase:XML; - var testCaseIndex:int = 0; - - var curContainerName:String = null; - - var containerCount:int = 0; - var menuCollection:ListCollectionView = createMenuCollection(testSuiteTests); - if (testEndIndex < 0) - testEndIndex = menuCollection.length; - for (var i:int = 0; i < menuCollection.length; i++) - { - // Store the list of tests in a structure so they can be called upon later. - // Need to be stored so they can be executed. - var menuItem:MenuItemObj = MenuItemObj(menuCollection.getItemAt(i)); - if (curContainerName != menuItem.testGroupName) - { - curContainer = <Container/>; - curContainer.@["label"] = menuItem.testGroupName; - xmlRoot.appendChild(curContainer); - curContainerName = menuItem.testGroupName; - ++containerCount; - } - curTestCase = <TestCase/>; - curTestCase.@["label"] = menuItem.testName; - curTestCase.@["testID"] = testCaseIndex; - - testCasesList.addItem(menuItem.testCase); - if (rangeOfTests) - { - curTestCase.@["selected"] = (testCaseIndex >= testStartIndex) && (testCaseIndex <= testEndIndex) - } - else - { - curTestCase.@["selected"] = false; - } - curContainer.appendChild(curTestCase); - testCaseIndex++; - } - - return xmlRoot; - } - - private function createMenuCollection(testSuiteTests:Array):ArrayCollection - { - // Create and populate the list - var menuCollection:ArrayCollection = new ArrayCollection(); - // so far I've flattened the test descriptor list. Seems as arbitrary as expecting one - // level of test suites. - var groupName:String = null; // Force the groupName to be regenerated for the suite - for (var caseIndex:int = 0; caseIndex < testSuiteTests.length; caseIndex++) - { - var testDesc:TestDescriptor = testSuiteTests[caseIndex]; - - groupName = testDesc.className(); - - // Store the list of tests in a structure so they can be called upon later. - // Need to be stored so they can be executed. - var menuItem:MenuItemObj = new MenuItemObj(); - - var strTmp:String = testDesc.testID; - //menuItem.testName = strTmp; - menuItem.testName = strTmp.substr(strTmp.lastIndexOf(":") + 1); - menuItem.testGroupName = groupName; - menuItem.testCase = testDesc; - menuItem.writingDirection = testDesc.config.writingDirection; - menuCollection.addItem(menuItem); - } - - // Sort the list - /* Create the SortField object for the "data" field in the ArrayCollection object, and make sure we do a numeric sort. */ - var dataSortField1:SortField = new SortField(); - dataSortField1.name = "testGroupName"; - dataSortField1.numeric = false; - - var dataSortField2:SortField = new SortField(); - dataSortField2.name = "testName"; - dataSortField2.numeric = false; - - /* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */ - var numericDataSort:Sort = new Sort(); - numericDataSort.fields = [dataSortField1, dataSortField2]; - - /* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */ - menuCollection.sort = numericDataSort; - menuCollection.refresh(); - - return menuCollection; - } - - private function doJUnitRun(runID:int):void - { - doSnapshotData.runID = runID; - testRunner.startTest(); - } - - /** - * This is the callback function used to run the tests that are selected. - * It is supplied on the initial creation of the dialog. - */ - public function runUnitTests(doBeforeAndAfterTest:Boolean = false, iterations:int = 1):void - { - testRunner.startTest(); - } - public function beforeRunTest(testCase:VellumTestCase, callBack:Function):void { beforeTestCallback = callBack; @@ -366,42 +200,6 @@ beforeTestCallback(testCase); } - /** - * This function walks the test data set from the tree to determine - * what items are selected to be run. - */ - private function walkTests(data:Object, testsToRun:Array):void - { - for each (var f:XML in data) - { - if (f.children().length() > 0) - walkTests(f.children(), testsToRun); - - if (f.@selected == true && [email protected]() > 0) - testsToRun.push(int(f.@testID)); - } - } - - /** - * callback function of HandleRunInfo - * **/ - private function finishHandleRunInfo(runID:int):void - { - doSnapshotData.runID = runID; - } - - private function errorWithMachineID(info:Object, token:Object):void - { - //trace ("could not retrieve machine ID: snapshot tests aborted"); - Alert.show(info.toString()); - } - - - private function handleError(info:Object, token:Object):void - { - Alert.show(info.toString()); - } - private function ioErrorPutBaseline(evtObj:IOErrorEvent):void { // Remove the event listeners to plug up memory leaks. @@ -437,17 +235,6 @@ //*********************************************************************/ /** - * Add testcaseXML to testXMLStore with a property name from the - * suiteXML file, then go to the next entry - */ - public function onTestCaseFileRead(evtObj:Event):void - { - testXMLStore[testXMLStore.suiteList.*[testXMLStore.suiteIndex].@suiteName] = XML(evtObj.target.data); - testXMLStore.suiteIndex++; - readTestCaseFiles(); - } - - /** * Read through a test suite and return a new suite of tests * that have the minimal flag set and are not in the skip list. */ @@ -546,61 +333,12 @@ filePrefix = filePrefixLine.replace (filePrefixPattern, "$1"); } */ } - readTestPropertiesFromProject(); - } - - public function readTestPropertiesFromProject(event:Event = null):void - { - testPropertiesPath = "../../build/test.properties"; - FileRepository.readFile(normalizedURL, testPropertiesPath, getTestProperties, readTestPropertiesFromDist); - } - - public function readTestPropertiesFromDist(event:Event = null):void - { - testPropertiesPath = "../../../../../../build/test.properties"; - FileRepository.readFile(normalizedURL, testPropertiesPath, getTestProperties, turnOffSnapshots); } public function turnOffSnapshots(event:Event = null):void { snapshotsOn = "false"; - chooseTestRunner(); - } - - public function getTestProperties(event:Event = null):void - { - var testPropContents:String = FileRepository.getFile(normalizedURL, testPropertiesPath); - if (testPropContents) - { - - } - - chooseTestRunner(); - } - - /** - * Use JUnit runner if it has been specified in testMachine.txt - */ - public function chooseTestRunner(evtObj:IOErrorEvent = null):void - { - canRun = true; - - // if it was specified in testMachine.txt, run the tests with Junit - if (generateReport == "true") - { - reportXMLResults = true; - - // If we haven't read in all the tests, do that first. onSuiteFileRead will also call loadAndRunTests(). - // Else tests have already been read in, we just need to run them. - /* if (testXMLStore == null) - FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError, true); - else */ - loadAndRunTests(); - } - if (rangeOfTests) - { - callLater(startRangeTests); - } + // chooseTestRunner(); } public function securityHandler(evtObj:SecurityErrorEvent):void @@ -615,35 +353,10 @@ private function startRangeTests():void { useTestSelectDialog = true; // we select the range in the XML for this dialog - /* if (testXMLStore == null) - FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError, true); - else */ - loadAndRunTests(); - } - - private function onSuiteDone(evtObj:Event):void - { - if (evtObj) - { - evtObj.target.removeEventListener("complete", onSuiteDone); - } - - // Remove the Event Listener because it has fired. - this.removeEventListener("TestComplete", onSuiteDone); - canRun = true; - //if (rangeOfTests) testRunner.sendResults(); - - if (reportXMLResults) - { - myLoader.load(new URLRequest("CoverageManagerExit.swf")); - myLoader.addEventListener(Event.COMPLETE, onLoad_Coverage); - myLoader.addEventListener(IOErrorEvent.IO_ERROR, onLoad_Flow); - } - } - - private function onLoad_Flow(ev:IOErrorEvent):void - { - myLoader.removeEventListener(IOErrorEvent.IO_ERROR, onLoad_Flow); + /* if (testXMLStore == null) + FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError, true); + else */ + loadAndRunTests(); } private function onLoad_Coverage(ev:Event):void @@ -651,96 +364,10 @@ loadedSWF.load("CoverageManagerExit.swf"); } - - private function onRunAllTests():void - { - /* - * In the VellumPerformance tests a timer had to be added after the - * FileRepository.readFile method in order to provide time necessary for loading. - * This has yet to be a problem in VellumUnit, but may be in the future. - * Refer to the VellumPerformance.mxml. - */ - canRun = false; - useTestSelectDialog = true; - reportXMLResults = false; - - /* if (testXMLStore == null) - FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError); - else */ - loadAndRunTests(); - } - - private function onRunMinimalTests():void - { - /* - * In the VellumPerformance tests a timer had to be added after the - * FileRepository.readFile method in order to provide time necessary for loading. - * This has yet to be a problem in VellumUnit, but may be in the future. - * Refer to the VellumPerformance.mxml. - */ - useTestSelectDialog = true; - reportXMLResults = false; - testStartIndex = 0; - testEndIndex = -1; - rangeOfTests = true; - - /* if (testXMLStore == null) - FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError); - else */ - loadAndRunTests(true); - } - - private function onCloseTestWindow():void - { - PopUpManager.removePopUp(TestRunnerWindow(curDialog)); - curDialog = null; - } - - private function createXMLElement(xmlDoc:XMLDocument, nodeName:String, nodeValue:String):XMLNode - { - var tmpNode:XMLNode = xmlDoc.createElement(nodeName); - var tmpNodeText:XMLNode = xmlDoc.createTextNode(nodeValue); - tmpNode.appendChild(tmpNodeText); - return (tmpNode); - } - - private function setDebugOrRelease():void - { - var e:Error = new Error(); - var s:String = e.getStackTrace(); - debugOrRelease = s; - try - { - var i:int = s.indexOf("setDebugOrRelease"); - if (s.charAt(i + 19) == '[') - { - debugOrRelease = "Debug Player"; - } - else - { - debugOrRelease = "Release Player"; - } - } - catch (err:Error) - { - debugOrRelease = "Release Player"; - } - if (Configuration.tlf_internal::debugCodeEnabled) - { - vellumDebugOrRelease = "Debug"; - } - else - { - vellumDebugOrRelease = "Release"; - } - } - //********************************************************* public function handleCreationComplete():void { - setDebugOrRelease(); - normalizedURL = LoaderUtil.normalizeURL(loaderInfo); // if we're in the AIR runtime, we get app:/VellumUnit.swf instead of // a file:/// URL. This checks for that and changes it to file:/// @@ -751,29 +378,47 @@ } //Security.loadPolicyFile("http://flashqa.macromedia.com/crossdomain.xml"); - for (var i:int = 0; i < XFLFileNameList.length; ++i) - FileRepository.readFile(normalizedURL, "../../test/testFiles/markup/tlf/" + XFLFileNameList[i]); - - // We're going to look for the machine.txt, to fill out default machine name. - // If we don't find it, go ahead and start the test runner. - FileRepository.readFile(normalizedURL, "../../test/testMachine.txt", readMachineName, readTestPropertiesFromProject, securityHandler, true); + xmlFileNameListLength = xmlFileNameList.length; + for (var i:int = 0; i < xmlFileNameListLength; i++) + { + FileRepository.readFile(normalizedURL, "../../test/testFiles/markup/tlf/" + xmlFileNameList[i], + onXmlFileListLoadComplete, onXmlFileListError, onXmlFileListSecurityError); + } // Load Arial Font SWF to Embed it in the application. loadEmbeddedFont(normalizedURL); } + + private function onXmlFileListLoadComplete(event:Event):void + { + xmlFileNameListCounter++; + if (xmlFileNameListCounter == xmlFileNameListLength) + { + loadAndRunTests(); + xmlFileNameListCounter = 0; + } + } + + private function onXmlFileListError(event:IOErrorEvent):void + { + //TODO: Error handlig for xml config filex + } + + private function onXmlFileListSecurityError(event:SecurityErrorEvent):void + { + //TODO: Error handlig for xml config filex + } ]]> </Script> <s:VGroup height="100%" width="100%"> <s:HGroup> - <s:Button label="Run Tests" id="cmdRunTests" click="onRunAllTests()" enabled="{canRun}"/> - <s:Button label="Run Minimal Tests" id="cmdRunAllTests" click="onRunMinimalTests()" enabled="{canRun}"/> <!-- <mx:Button label="Run Selected Tests" id="cmdRunSelectedTests" click="onRunTest()" enabled="{canRun}"/> --> <s:Label text="memory usage:"/> <s:TextInput text="{currentlyUsedMemory}" width="71" height="20"/> </s:HGroup> <local:TestDescriptorRunner id="testRunner" height="30%" width="100%"/> - <s:SWFLoader id="loadedSWF" source="Flow.swf" height="536" width="1100" /> + <s:SWFLoader id="loadedSWF" source="Flow.swf" height="536" width="1100"/> </s:VGroup> </s:Application> http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_core/src/UnitTest/ExtendedClasses/VellumTestCase.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/ExtendedClasses/VellumTestCase.as b/automation_core/src/UnitTest/ExtendedClasses/VellumTestCase.as index 520ec6a..d15c275 100644 --- a/automation_core/src/UnitTest/ExtendedClasses/VellumTestCase.as +++ b/automation_core/src/UnitTest/ExtendedClasses/VellumTestCase.as @@ -631,7 +631,6 @@ package UnitTest.ExtendedClasses public function importContent(content:Object):void { - var beginTime:int = getTimer(); //TestFrame.removeAllChildren(); var parser:ITextImporter = importParser; var textFlow:TextFlow = parser.importToFlow(content); @@ -662,11 +661,18 @@ package UnitTest.ExtendedClasses var extension:String = getExtension(fileName); if (extension == "html") + { fileData = FileRepository.getFile(baseURL, "../../test/testFiles/markup/html/" + fileName); + } else if (extension == "txt") + { fileData = FileRepository.getFile(baseURL, "../../test/testFiles/markup/plainText/" + fileName); + } else + { fileData = FileRepository.getFileAsXML(baseURL, "../../test/testFiles/markup/tlf/" + fileName); + } + return fileData; } @@ -674,8 +680,6 @@ package UnitTest.ExtendedClasses public function loadTestFile(fileName:String):void { - var containerFormat:TextLayoutFormat; - if (fileName == defaultFileName && cacheTestFile != null) { var textFlow:TextFlow = cacheTestFile.deepCopy(0, cacheTestFile.textLength) as TextFlow; http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_core/src/UnitTest/Fixtures/FileRepository.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/Fixtures/FileRepository.as b/automation_core/src/UnitTest/Fixtures/FileRepository.as index b83d8d2..965f7dc 100644 --- a/automation_core/src/UnitTest/Fixtures/FileRepository.as +++ b/automation_core/src/UnitTest/Fixtures/FileRepository.as @@ -44,7 +44,6 @@ package UnitTest.Fixtures */ static public function getFileAsXML(baseURL:String, fileName:String):XML { - var xmlData:XML = null; var sourceString:String = getFile(baseURL, fileName); return sourceString ? convertToXML(sourceString) : null; } @@ -143,7 +142,9 @@ class CustomURLLoader extends URLLoader this.securityErrorHandler = securityErrorHandler; if (!_fileCache) + { _fileCache = new Object(); + } } /** Returns number of file read requests that are pending -- i.e., that have neither @@ -159,13 +160,16 @@ class CustomURLLoader extends URLLoader { // If it's in the cache, just return it if (_fileCache[fileName] != null) + { return _fileCache[fileName]; - + } // We have a request out, and we're waiting for the result. Unfortunately, there's no // way we know to wait and still handle the events that would cause the pending status // to complete. So we return failure here as well. if (_fileCache.hasOwnProperty(fileName)) + { return null; + } // We've never seen this file return null; @@ -188,8 +192,9 @@ class CustomURLLoader extends URLLoader { // Remove the event listener that was attached so this function could get called. if (event) + { event.target.removeEventListener(Event.COMPLETE, defaultCompleteHandler); - + } // This request handled; is no longer pending --_requestsPending; @@ -199,7 +204,9 @@ class CustomURLLoader extends URLLoader // Call the custom completion handler if (urlLoader.completeHandler != null) + { urlLoader.completeHandler(event); + } urlLoader.close(); } @@ -216,7 +223,9 @@ class CustomURLLoader extends URLLoader var urlLoader:CustomURLLoader = CustomURLLoader(event.target); addToCache(urlLoader, FILE_ERROR); if (urlLoader.securityErrorHandler != null) + { urlLoader.securityErrorHandler(event); + } } /** Default handler. This will get called on every i/o error of a read that goes @@ -226,13 +235,17 @@ class CustomURLLoader extends URLLoader static private function defaultIOErrorHandler(event:IOErrorEvent):void { if (event) + { event.target.removeEventListener(IOErrorEvent.IO_ERROR, defaultIOErrorHandler); + } --_requestsPending; var urlLoader:CustomURLLoader = CustomURLLoader(event.target); addToCache(urlLoader, FILE_ERROR); if (urlLoader.ioErrorHandler != null) + { urlLoader.ioErrorHandler(event); + } } /* Start a file read. http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_core/src/UnitTest/Fixtures/MeasureConstants.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/Fixtures/MeasureConstants.as b/automation_core/src/UnitTest/Fixtures/MeasureConstants.as new file mode 100644 index 0000000..a1e91b5 --- /dev/null +++ b/automation_core/src/UnitTest/Fixtures/MeasureConstants.as @@ -0,0 +1,16 @@ +/** + * Created with IntelliJ IDEA. + * User: Hellix + * Date: 01.06.14 + * Time: 22:23 + * To change this template use File | Settings | File Templates. + */ +package UnitTest.Fixtures +{ + public class MeasureConstants + { + public static const MEASURE_WIDTH:String = "measureW"; + public static const MEASURE_HEIGHT:String = "measureH"; + public static const MEASURE_BOTH:String = "measureWH"; + } +} http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/e31da7b5/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as ---------------------------------------------------------------------- diff --git a/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as b/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as index 148d9c3..cdc0bc9 100644 --- a/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as +++ b/automation_tests/src/UnitTest/Tests/AllParaAttributeTest.as @@ -234,13 +234,14 @@ package UnitTest.Tests * This builds testcases for properties in attributes in description that are Enumerated types types. A testcase is generated * for each possible enumerated value */ + [Ignore] [Test] public function testAllEnumProps():void { var range:Object = null; var value:Object = null; - - for each (testProp in TextLayoutFormat.description) + var desc:Object = TextLayoutFormat.description; + for each (testProp in desc) { // new code if (testProp.category == Category.PARAGRAPH)
