| <?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. |
| --> |
| |
| <!--Flow from one frame to another --> |
| |
| <s:Application |
| xmlns="http://ns.adobe.com/mxml/2009" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:flexunit="flexunit.flexui.*" |
| xmlns:local="UnitTest.*" |
| explicitMinWidth="100" |
| explicitMinHeight="100" |
| width="1100" |
| height="800" |
| applicationComplete="handleCreationComplete()" |
| fontFamily="Verdana"> |
| |
| <Script> |
| <![CDATA[ |
| import mx.collections.ListCollectionView; |
| include "UnitTest/General_Functions.as"; |
| |
| import UnitTest.Fixtures.FileRepository; |
| |
| import flashx.textLayout.TextLayoutVersion; |
| import flashx.textLayout.debug.Debugging; |
| import flashx.textLayout.edit.EditManager; |
| import flashx.textLayout.edit.SelectionManager; |
| import flashx.textLayout.elements.Configuration; |
| import flashx.textLayout.elements.TextFlow; |
| import flashx.textLayout.formats.BlockProgression; |
| import flashx.textLayout.formats.Direction; |
| import flashx.textLayout.tlf_internal; |
| |
| import flexunit.utils.Collection; |
| |
| import mx.collections.ArrayCollection; |
| import mx.collections.ListCollectionView; |
| import mx.collections.Sort; |
| import mx.collections.SortField; |
| import mx.collections.XMLListCollection; |
| import mx.controls.Alert; |
| import mx.rpc.AsyncResponder; |
| import mx.utils.LoaderUtil; |
| |
| use namespace tlf_internal; |
| |
| import flash.system.System; |
| import flash.system.Security; |
| |
| import mx.managers.PopUpManager; |
| import mx.managers.SystemManager; |
| |
| import UnitTest.ExtendedClasses.TestDescriptor; |
| import UnitTest.ExtendedClasses.TestSuiteExtended; |
| import UnitTest.ExtendedClasses.VellumTestCase; |
| import UnitTest.Fixtures.TestApp; |
| import UnitTest.Fixtures.TestConfig; |
| import UnitTest.TestRunnerWindow; |
| import UnitTest.TestDescriptorRunner; |
| import UnitTest.RunTests; |
| import UnitTest.MenuItemObj; |
| |
| import UnitTest.Tests.* |
| |
| import flash.display.Bitmap; |
| import flash.display.BitmapData; |
| import flash.events.Event; |
| import flash.utils.ByteArray; |
| |
| import flashx.textLayout.debug.assert; |
| |
| private var socket:XMLSocket; |
| private var curDialog:Object; |
| private var treeData:XMLList; |
| private var runTestsDialog:RunTests; |
| private var testCasesList:ArrayCollection; |
| private var useTestSelectDialog:Boolean = false; |
| // private var snapshotSaveDialog:SaveSnapshot; |
| |
| // test control data from testMachine.txt |
| public var testMachineName:String = "unspecified"; |
| public var testOwner:String = "tcalias"; |
| public var buildType:String = "Private"; |
| public var snapshotsOn:String = "false"; |
| public var normalizedURL:String = ""; // for reading control files |
| public var generateReport:String = "false"; |
| public var antSkipTestFile:String = ""; |
| public var testStartIndex:Number = 0; |
| public var testEndIndex:Number = 0; |
| public var rangeOfTests:Boolean = false; |
| public var testRunDate:String = ""; |
| |
| public var testPropertiesPath:String = ""; |
| |
| private var doSnapshotData:Object; |
| private var curTest:VellumTestCase; |
| private var beforeTestCallback:Function; |
| private var afterTestCallback:Function; |
| private var checkMemoryIntervalID:uint = setInterval(checkMemoryUsage,1000); |
| private var snapshotStack:Array; |
| |
| private var curURL:String; |
| |
| private var myLoader:URLLoader = new URLLoader(); |
| private var myXMLURL:URLRequest = new URLRequest(); |
| private var urlReqSnapShotStore:URLRequest = new URLRequest(); |
| |
| private var curSnapshotTypeToStore:String; |
| private var tryToStoreCount:Number = 0; |
| private var maxTryToStoreCount:Number = 5; |
| |
| //Set this option to have the test run do the visual compare before and after a test. |
| [Bindable] |
| public var doBeforeAfterCompare:Boolean = false; |
| |
| [Bindable] |
| public var currentlyUsedMemory:uint = 0; |
| |
| public var debugOrRelease:String; |
| public var vellumDebugOrRelease:String; |
| |
| 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 |
| // the filename as a property name |
| // Examples: |
| // XFLStore.simple |
| // XFLStore.tableExample |
| public var XFLFileNameList: Array = [ |
| "simple.xml", |
| "tableExample.xml", |
| "asknot.xml", |
| "empty.xml", |
| "sampleArabic.xml", |
| "aliceExcerpt.xml" |
| ]; |
| public var reportXMLResults:Boolean = false; |
| |
| // this testApp object needs to be used to set |
| // the static testApp member of VellumTestCase |
| // before any VellumTestCase constructors are called. |
| public var testApp:TestApp = new TestApp(); |
| |
| public function checkMemoryUsage():void |
| { |
| currentlyUsedMemory = Math.round(System.totalMemory/1000000); |
| } |
| /** |
| * Loads Arial font |
| */ |
| private function loadEmbeddedFont(baseURL:String):void |
| { |
| var fontLoader:Loader = new Loader(); |
| fontLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoadEmbeddedFont); |
| fontLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoadEmbeddedFontIOError); |
| fontLoader.load(new URLRequest(LoaderUtil.createAbsoluteURL(baseURL,"../../test/testFiles/assets/ARIAL_FONT.swf"))); |
| } |
| |
| private function handleLoadEmbeddedFontIOError(evtObj:IOErrorEvent):void |
| { |
| trace("Unable to load Arial Font."); |
| } |
| |
| |
| private function handleLoadEmbeddedFont(evtObj:Event):void |
| { |
| var arialFont:Class = evtObj.target.applicationDomain.getDefinition("Arial_DF4"); |
| Font.registerFont(arialFont); |
| var arialFontBlack:Class = evtObj.target.applicationDomain.getDefinition("Arial_Black_DF4"); |
| Font.registerFont(arialFontBlack); |
| var arialFontNarrow:Class = evtObj.target.applicationDomain.getDefinition("Arial_Narrow_DF4"); |
| Font.registerFont(arialFontNarrow); |
| var arialFontRoundedMTBold:Class = evtObj.target.applicationDomain.getDefinition("Arial_Rounded_MT_Bold_DF4"); |
| Font.registerFont(arialFontRoundedMTBold); |
| } |
| |
| public function onSuiteFileRead(evtObj:Event):void |
| { |
| testXMLStore = new Object(); |
| testXMLStore.suiteList = XML(evtObj.target.data); |
| testXMLStore.suiteIndex = 0; |
| readTestCaseFiles(); |
| } |
| /** |
| * 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():void |
| { |
| // Set up all of the application dependencies that the tests |
| // use and store them in a static member of VellumTestCase |
| testApp.getTextFlow = function ():TextFlow { |
| return SystemManager(loadedSWF.content).application["activeFlow"]; |
| } |
| testApp.getDisplayObject = function ():DisplayObject { |
| return SystemManager(loadedSWF.content).application["rootPanel"]; |
| } |
| testApp.setInteractionManager = SystemManager(loadedSWF.content).application["setInteractionManager"]; |
| testApp.contentChange = SystemManager(loadedSWF.content).application["changeContent"]; |
| testApp.detachActiveFlow = SystemManager(loadedSWF.content).application["detachActiveFlow"]; |
| testApp.changeContainerSetup = SystemManager(loadedSWF.content).application["changeContainerSetup"]; |
| |
| VellumTestCase.testApp = testApp; |
| |
| SystemManager(loadedSWF.content).application["visiblePanels"] = []; |
| SystemManager(loadedSWF.content).application["rulerVisible"] = false; |
| |
| collectTextLayoutVersion(); |
| testRunDate = MakeMySQLDate(new Date()); |
| |
| // ************* This code is for the snapshot application ******************// |
| // It gathers up the test to create a selectable list of tests to run. |
| // Set the type of containers on which the tests should be run. |
| var arContainers:Array = ["sprite"]; |
| var arWritingDirections:Array = [ |
| [BlockProgression.TB,Direction.LTR], |
| [BlockProgression.TB,Direction.RTL], |
| [BlockProgression.RL,Direction.LTR] ]; |
| // Create the test suite based on those containers. |
| var vellumTests:TestSuiteExtended = createSuite(arContainers, arWritingDirections); |
| if (useTestSelectDialog == true) |
| { |
| useTestSelectDialog = false; |
| |
| var testSuiteTests:Array = vellumTests.getTests(); |
| |
| // Initialize the test case object list. |
| if (testCasesList == null) |
| testCasesList = new ArrayCollection(); |
| |
| treeData = createXMLTree(testSuiteTests).children(); |
| |
| if (rangeOfTests) |
| { |
| runUnitTests(); |
| rangeOfTests = false; |
| } |
| else |
| { |
| // Booga - This is this code that brings up the run test dialog. |
| runTestsDialog = new RunTests(); |
| runTestsDialog.treeData = treeData; |
| runTestsDialog.closeFunction = closeRunTestDialog; |
| runTestsDialog.runTestFunction = runUnitTests; |
| |
| PopUpManager.addPopUp(runTestsDialog,this, true); |
| PopUpManager.centerPopUp(runTestsDialog); |
| } |
| } |
| else |
| { |
| testRunner.reportXML = reportXMLResults; |
| if (reportXMLResults) |
| { |
| // Call the function to make sure the MachineID is in the DB. |
| // This can be aynchronous, because the test does not depend on it. |
| doSnapshotData = new Object(); |
| // It needs to put the Machine ID in here from the automation machine. |
| doSnapshotData.machineID = testMachineName + ":" + TextLayoutVersion.BRANCH; |
| |
| /* |
| //var testRunnerJ:JUnitTestRunner = new JUnitTestRunner(this); |
| testRunner.beforeTest = beforeSnapshotTest; |
| testRunner.afterTest = afterSnapshotTest; |
| |
| var minimalSuite:TestSuiteExtended = createMinimalSuite (vellumTests); |
| testRunner.test = minimalSuite; |
| testRunner.startTest();*/ |
| } |
| else |
| { |
| // don't think we should ever get here - astearns 8/15/08 |
| testRunner.test = vellumTests; |
| testRunner.startTest(); |
| } |
| } |
| } |
| |
| 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; |
| |
| var arContainers:Array = ["sprite"]; |
| var arWritingDirections:Array = [ |
| [BlockProgression.TB,Direction.LTR], |
| [BlockProgression.TB,Direction.RTL], |
| [BlockProgression.RL,Direction.LTR] ]; |
| // Create the test suite based on those containers. |
| var vellumTests:TestSuiteExtended = createSuite(arContainers, arWritingDirections); |
| |
| var minimalSuite:TestSuiteExtended = createMinimalSuite (vellumTests); |
| testRunner.test = minimalSuite; |
| testRunner.startTest(); |
| } |
| |
| /** |
| * Set properties in testRunner that describe the build |
| * for use in the XML report. |
| */ |
| public function collectTextLayoutVersion():void |
| { |
| var buildAndChangelist:String = TextLayoutVersion.BUILD_NUMBER; |
| |
| testRunner.suiteMetaData.vellumBranch = TextLayoutVersion.BRANCH; |
| testRunner.suiteMetaData.vellumVersion = TextLayoutVersion.getVersionString(TextLayoutVersion.CURRENT_VERSION); |
| testRunner.suiteMetaData.vellumBuild = Number(buildAndChangelist.split(" ")[0]); |
| testRunner.suiteMetaData.vellumChangelistNumber = Number((buildAndChangelist.split("(")[1]).split(")")[0]); |
| testRunner.suiteMetaData.vellumDescription = vellumDebugOrRelease; |
| testRunner.suiteMetaData.vellumSDKVersion = "SDK 4.5.0.19786"; |
| testRunner.suiteMetaData.vellumPlayerGlobals = ""; |
| testRunner.suiteMetaData.testMachineName = testMachineName; |
| testRunner.suiteMetaData.testOwner = testOwner; |
| testRunner.suiteMetaData.buildType = buildType; |
| } |
| |
| /** |
| * 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 |
| { |
| doBeforeAfterCompare = doBeforeAndAfterTest; |
| // Close the select test dialog. |
| PopUpManager.removePopUp(runTestsDialog); |
| // Determine which items are checked and which are not. |
| var testsToRun:Array = new Array(); |
| if (treeData.children().length() > 0) |
| walkTests(treeData, testsToRun); |
| |
| var ts:TestSuiteExtended = new TestSuiteExtended(this); |
| var lengthOfTests:int = testsToRun.length; |
| |
| for (var i:int = 0; i < lengthOfTests; i++) |
| { |
| for (var j:int = 0; j < iterations; j++) |
| ts.addTestDescriptor( testCasesList[testsToRun[i]] ); |
| } |
| if (rangeOfTests) |
| { |
| ts = createMinimalSuite (ts); |
| } |
| if (ts.getTests().length > 0) |
| { |
| // Add the event listener to listen for put the TestComplete event. |
| addEventListener("TestComplete",onSuiteDone, false, 0, true); |
| |
| testRunner.reportXML = reportXMLResults; |
| testRunner.test = ts; |
| testRunner.beforeTest = beforeRunTest; |
| //testRunner.afterTest = afterSnapshotTest; |
| testRunner.startTest(); |
| } |
| } |
| |
| public function beforeRunTest(testCase:VellumTestCase, callBack:Function):void |
| { |
| beforeTestCallback = callBack; |
| testCase.doBeforeAfterCompare = doBeforeAfterCompare; |
| 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 && f.@testID.length() > 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. |
| if (evtObj) |
| { |
| evtObj.target.removeEventListener("complete", doSnapShotStoreStack); |
| evtObj.target.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorPutBaseline); |
| evtObj.target.removeEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatus); |
| } |
| trace ("Error trying to put the baseline."); |
| /* |
| if (tryToStoreCount < maxTryToStoreCount) |
| { |
| // Put it back on the stack and try again. |
| snapshotStack.push(curSnapshotTypeToStore); |
| // Increment the count of the number of tries. |
| tryToStoreCount ++; |
| trace ("Attempt #" + tryToStoreCount.toString() + " to store it again."); |
| } |
| else if (tryToStoreCount == maxTryToStoreCount) |
| { |
| trace("Max Try Count Exceeded - Snapshot failed to be stored. " + evtObj.text) |
| // Reset the tryToStoreCount for the next run. |
| tryToStoreCount = 0; |
| } |
| else |
| { |
| // Reset the tryToStoreCount for the next run. |
| tryToStoreCount = 0; |
| } |
| */ |
| // Continue doing the snapshots. |
| doSnapShotStoreStack(null); |
| } |
| |
| private function doSnapShotStoreStack(evtObj:Event):void |
| { |
| if (evtObj) |
| { |
| evtObj.target.removeEventListener("complete", doSnapShotStoreStack); |
| evtObj.target.removeEventListener(IOErrorEvent.IO_ERROR, ioErrorPutBaseline); |
| evtObj.target.removeEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatus); |
| } |
| var snapshotType:String = snapshotStack.shift(); |
| if (snapshotType != null) |
| { |
| //store result after test |
| |
| } |
| else |
| afterTestCallback(curTest); |
| } |
| |
| |
| //*********************************************************************/ |
| |
| /** |
| * This is the callback function used to close the run tests dialog. |
| * It is supplied on the initial creation of the dialog. |
| */ |
| private function closeRunTestDialog():void |
| { |
| PopUpManager.removePopUp(runTestsDialog); |
| canRun = true; |
| } |
| |
| /** |
| * 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(); |
| } |
| |
| /** |
| * Add all the tests to the test suite |
| */ |
| public function createSuite(arContainers:Array = null, arWritingDirections:Array = null):TestSuiteExtended |
| { |
| // In debug builds set extra check flags |
| CONFIG::debug { |
| // throw if vellum internal asserts occur |
| flashx.textLayout.debug.Debugging.tlf_internal::throwOnAssert = true; |
| // enables TextFlow.debugCheckTextFlow calls - these are scattered through the code |
| flashx.textLayout.debug.Debugging.tlf_internal::debugCheckTextFlow = true; |
| } |
| |
| var ts:TestSuiteExtended = new TestSuiteExtended(this); |
| var config:TestConfig = new TestConfig(); |
| config.baseURL = normalizedURL; |
| //config.useEmbeddedFonts = true; |
| |
| for (var i:int = 0; i < arContainers.length; i++) |
| { |
| config.containerType = arContainers[i]; |
| for (var j:int = 0; j < arWritingDirections.length; j++) |
| { |
| config.writingDirection = arWritingDirections[j]; |
| |
| // Add tests defined in the classes using suite() or suiteFromXML() |
| |
| AccessibilityMethodsTest.suite(config, ts); |
| AllCharAttributeTest.suite(config, ts); |
| AllContAttributeTest.suite(config, ts); |
| AllEventTest.suiteFromXML(testXMLStore.AllEventTest, config, ts); |
| AllParaAttributeTest.suite(config, ts); |
| AttributeTest.suite(config, ts); //KJT |
| BoundsAndAlignmentTest.suite(config, ts); |
| BoxTest.suite(config, ts); |
| CompositionTest.suite(config, ts); |
| ContainerAttributeTest.suiteFromXML(testXMLStore.ContainerAttributeTest, config, ts); |
| ContainerTypeTest.suiteFromXML(testXMLStore.ContainerTypeTest, config, ts); |
| ElementOperationTests.suite(config, ts); |
| EventOverrideTest.suiteFromXML(testXMLStore.EventOverrideTest, config, ts); |
| FactoryImportTest.suiteFromXML(testXMLStore.FactoryImportTest, config, ts); |
| FETest.suiteFromXML(testXMLStore.FETest, config, ts); |
| FloatTest.suite(config, ts); |
| FlowModelTest.suite(config, ts); |
| GeneralFunctionsTest.suite(config, ts); |
| HorizontalScrollingTest.suiteFromXML(testXMLStore.HorizontalScrollingTest, config, ts); |
| ImportAPITest.suite(config, ts); |
| ImportTest.suiteFromXML(testXMLStore.ImportTest, config, ts); |
| KeyboardGestureTest.suiteFromXML(testXMLStore.KeyboardGestureTest, config, ts); |
| LeadingTest.suite(config, ts); |
| LinkTest.suite(config, ts); |
| ListTest.suite(config, ts); |
| LocaleTests.suiteFromXML(testXMLStore.LocaleTests, config, ts); |
| MeasurementGridTest.suite(config, ts); |
| MeasurementTest.suiteFromXML(testXMLStore.MeasurementTest, config, ts); |
| //MXMLCompilationTest.suiteFromXML(testXMLStore.MXMLCompilationTest,config, ts); |
| OperationTest.suiteFromXML(testXMLStore.OperationTest, config, ts); |
| ParagraphTest.suiteFromXML(testXMLStore.ParagraphTest, config, ts); |
| ScrollToRangeTest.suiteFromXML(testXMLStore.ScrollToRangeTest, config, ts); |
| ScrollingTest.suiteFromXML(testXMLStore.ScrollingTest, config, ts); |
| SelectionTest.suiteFromXML(testXMLStore.SelectionTest, config, ts); |
| SpacingTest.suite(config, ts); |
| StyleTest.suiteFromXML(testXMLStore.StyleTest, config, ts); |
| SWFTest.suiteFromXML(testXMLStore.SWFTest, config, ts); |
| ImpliedParagraphTest.suiteFromXML(testXMLStore.ImpliedParagraphTest, config, ts); |
| UndoRedoTest.suiteFromXML(testXMLStore.UndoRedoTest, config, ts); |
| TabTest.suiteFromXML(testXMLStore.TabTest, config, ts); |
| TCYTests.suiteFromXML(testXMLStore.TCYTests, config, ts); |
| TextContainerManagerTest.suiteFromXML(testXMLStore.TextContainerManagerTest, config, ts); |
| TextFlowEditTest.suite(config, ts); //HBS |
| TextFlowTextLineFactoryTest.suiteFromXML(testXMLStore.TextFlowTextLineFactoryTest, config, ts); |
| TextLineFilterTest.suiteFromXML(testXMLStore.TextLineFilterTest, config, ts); |
| //VerticalScrollingTest.suiteFromXML(testXMLStore.VerticalScrollingTest, config, ts); |
| WritingModeTest.suiteFromXML(testXMLStore.WritingModeTest, config, ts); |
| |
| } |
| } |
| |
| // Add the event listener to listen for the TestComplete event. |
| addEventListener("TestComplete",onSuiteDone, false, 0, true); |
| return ts; |
| } |
| |
| /** |
| * 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. |
| */ |
| public function createMinimalSuite (fullSuite:TestSuiteExtended):TestSuiteExtended |
| { |
| // the way we iterate through tests here and in readTestCaseFiles |
| // assumes we have only one level of nesting of test suites, |
| // which may not always be true. |
| var minimalSuite:TestSuiteExtended = new TestSuiteExtended(this); |
| |
| var suiteList:Array = fullSuite.getTests(); |
| for (var i1:int = 0; i1 < suiteList.length; i1++) |
| { |
| if (suiteList[i1].minimal) |
| { |
| if (skipList) |
| { |
| if (skipList.indexOf(suiteList[i1].testID) == -1) |
| { |
| minimalSuite.addTestDescriptor(suiteList[i1]); |
| } |
| } |
| else |
| { |
| minimalSuite.addTestDescriptor(suiteList[i1]); |
| } |
| } |
| } |
| return minimalSuite; |
| } |
| |
| /** |
| * The machine name is stored in a file named testMachine.txt |
| * This is updated from the init task in the ant build. Once |
| * we've retrieved the machine name we generate a file read |
| * error to determine where VellumUnit is being run from |
| */ |
| public function readMachineName(event:Event):void |
| { |
| var fileContents:String = FileRepository.getFile(normalizedURL, "../../test/testMachine.txt"); |
| if (fileContents) |
| { |
| var namePattern:RegExp = /testMachineName=(.*)/; |
| if (fileContents.match(namePattern)) |
| { |
| var nameLine:String = fileContents.match(namePattern)[0]; |
| testMachineName = nameLine.replace (namePattern, "$1"); |
| } |
| var typePattern:RegExp = /buildType=(.*)/; |
| if (fileContents.match(typePattern)) |
| { |
| var typeLine:String = fileContents.match(typePattern)[0]; |
| buildType = typeLine.replace (typePattern, "$1"); |
| } |
| var ownerPattern:RegExp = /testOwner=(.*)/; |
| if (fileContents.match(ownerPattern)) |
| { |
| var ownerLine:String = fileContents.match(ownerPattern)[0]; |
| testOwner = ownerLine.replace (ownerPattern, "$1"); |
| } |
| var snapPattern:RegExp = /snapshots=(.*)/; |
| if (fileContents.match(snapPattern)) |
| { |
| var snapLine:String = fileContents.match(snapPattern)[0]; |
| snapshotsOn = snapLine.replace (snapPattern, "$1"); |
| } |
| var genPattern:RegExp = /generateReport=(.*)/; |
| if (fileContents.match(genPattern)) |
| { |
| var genLine:String = fileContents.match(genPattern)[0]; |
| generateReport = genLine.replace (genPattern, "$1"); |
| } |
| var skipFilePattern:RegExp = /antSkipTestFile=(.*)/; |
| if (fileContents.match(skipFilePattern)) |
| { |
| var skipLine:String = fileContents.match(skipFilePattern)[0]; |
| antSkipTestFile = skipLine.replace (skipFilePattern, "$1"); |
| } |
| var startPattern:RegExp = /startTest=(.*)/; |
| if (fileContents.match(startPattern)) |
| { |
| var startLine:String = fileContents.match(startPattern)[0]; |
| testStartIndex = Number(startLine.replace (startPattern, "$1")); |
| } |
| var endPattern:RegExp = /endTest=(.*)/; |
| if (fileContents.match(endPattern)) |
| { |
| var endLine:String = fileContents.match(endPattern)[0]; |
| testEndIndex = Number(endLine.replace (endPattern, "$1")); |
| } |
| rangeOfTests = (testStartIndex != 0) && (testEndIndex !=0); |
| /* var filePrefixPattern:RegExp = /testOwner=(.*)/; |
| if (fileContents.match(filePrefixPattern)) |
| { |
| var filePrefixLine:String = fileContents.match(filePrefixPattern)[0]; |
| 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); |
| } |
| } |
| |
| public function securityHandler(evtObj:SecurityErrorEvent):void |
| { |
| trace("ERROR",evtObj.toString()); |
| } |
| /** |
| * If we've read in a test index range from testMachine.txt, then go |
| * right to running that range of tests |
| */ |
| 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); |
| } |
| |
| private function onLoad_Coverage(ev:Event):void |
| { |
| loadedSWF.load("CoverageManagerExit.swf"); |
| } |
| |
| |
| private function onRunTest():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 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. |
| */ |
| useTestSelectDialog = true; |
| reportXMLResults = false; |
| testStartIndex = 0; |
| testEndIndex = -1; |
| rangeOfTests = true; |
| |
| if (testXMLStore == null) |
| FileRepository.readFile(normalizedURL, "../../test/testSuites.xml", onSuiteFileRead, onSuiteFileReadError, onSuiteFileSecurityError); |
| else |
| loadAndRunTests(); |
| } |
| |
| private function onSuiteFileReadError(o:Object):void |
| { |
| trace(o.toString()); |
| } |
| |
| private function onSuiteFileSecurityError(o:Object):void |
| { |
| trace(o.toString()); |
| } |
| |
| 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:/// |
| if (normalizedURL.charAt(0) == "a") |
| { |
| var c:Class = Class(ApplicationDomain.currentDomain.getDefinition("flash.filesystem.File")); |
| normalizedURL = new c(new c(normalizedURL)["nativePath"])["url"]; |
| } |
| |
| //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); |
| |
| // Load Arial Font SWF to Embed it in the application. |
| loadEmbeddedFont(normalizedURL); |
| } |
| |
| ]]> |
| </Script> |
| |
| <mx:VBox height="100%" width="100%"> |
| <mx:HBox> |
| <mx:Button label="Run Tests" id="cmdRunTests" click="onRunTest()" enabled="{canRun}"/> |
| <mx:Button label="Run Minimal Tests" id="cmdRunAllTests" click="onRunAllTests()" enabled="{canRun}"/> |
| <!-- <mx:Button label="Run Selected Tests" id="cmdRunSelectedTests" click="onRunTest()" enabled="{canRun}"/> --> |
| <mx:Label text="memory usage:"/> |
| <mx:Text text="{currentlyUsedMemory}" width="71" height="20"/> |
| </mx:HBox> |
| <local:TestDescriptorRunner id="testRunner" height = "30%" width="100%"/> |
| <mx:SWFLoader id = "loadedSWF" source="../../testApps/bin/Flow.swf" height="536" width="1100"/> |
| </mx:VBox> |
| |
| </s:Application> |