http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_apps/src/VellumUnit.mxml ---------------------------------------------------------------------- diff --git a/automation_apps/src/VellumUnit.mxml b/automation_apps/src/VellumUnit.mxml index ce40fd8..b23beb8 100644 --- a/automation_apps/src/VellumUnit.mxml +++ b/automation_apps/src/VellumUnit.mxml @@ -18,413 +18,316 @@ <!--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> +<s:Application + xmlns="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + 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 AND instantiate MarshallingSupport. Enables being loaded as a sub-swf and loading a sub-swf with marshall plan features - import mx.managers.systemClasses.MarshallingSupport; MarshallingSupport; - - 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" - ]; + 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; + + include "UnitTest/General_Functions.as"; + + use namespace tlf_internal; + + // import AND instantiate MarshallingSupport. Enables being loaded as a sub-swf and loading a sub-swf with marshall plan features + MarshallingSupport; + + private var socket:XMLSocket; + private var curDialog:Object; + //TODO: Remove + // private var treeData:XMLList; + private var testCasesList:ArrayCollection; + private var useTestSelectDialog:Boolean = false; + + 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(); + + 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); */ + } + + /** + * 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(); + config.baseURL = normalizedURL; + config.testXMLStore = XML(testXMLStore); + // 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; + + testRunDate = MakeMySQLDate(new Date()); + + testRunner.startTest(isMinimialTests); + } + + 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; + dataSortField1.numeric = false; var dataSortField2:SortField = new SortField(); dataSortField2.name = "testName"; @@ -438,620 +341,439 @@ 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 = ""; - 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 && [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. - 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); - CrossContainerTest.suite(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); - TableBackgroundTest.suite(config, ts); - TableTests.suite(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); - } - - ]]> + 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; + 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 && [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. + 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."); + // 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); + } + + //*********************************************************************/ + + /** + * 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. + */ + 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 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:/// + 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: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:VGroup> + </s:Application>
http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_core/libs/flexunit.swc ---------------------------------------------------------------------- diff --git a/automation_core/libs/flexunit.swc b/automation_core/libs/flexunit.swc new file mode 100644 index 0000000..0722885 Binary files /dev/null and b/automation_core/libs/flexunit.swc differ http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_core/src/AutomationCoreClasses.as ---------------------------------------------------------------------- diff --git a/automation_core/src/AutomationCoreClasses.as b/automation_core/src/AutomationCoreClasses.as index 5c5affd..f2da5aa 100644 --- a/automation_core/src/AutomationCoreClasses.as +++ b/automation_core/src/AutomationCoreClasses.as @@ -20,27 +20,31 @@ package { internal class AutomationCoreClasses { - import UnitTest.ExtendedClasses.TestDescriptor; TestDescriptor; + import UnitTest.ExtendedClasses.VellumTestCase; VellumTestCase; + import UnitTest.Validation.BoundsChecker; BoundsChecker; + import UnitTest.Validation.CompositionResults; CompositionResults; + import UnitTest.Validation.SelectionEventValidator; SelectionEventValidator; + import UnitTest.Validation.DamageEventValidator; DamageEventValidator; + import UnitTest.Validation.StatusChangeEventValidator; StatusChangeEventValidator; + import UnitTest.Validation.FlowOperationEventValidator; FlowOperationEventValidator; + import UnitTest.Validation.CompositionCompleteEventValidator; CompositionCompleteEventValidator; + import UnitTest.Validation.FlowElementMouseEventValidator; FlowElementMouseEventValidator; + import UnitTest.Validation.EventValidator; EventValidator; + import UnitTest.Validation.UpdateCompleteEventValidator; UpdateCompleteEventValidator; + + /*import UnitTest.ExtendedClasses.TestDescriptor; TestDescriptor; import UnitTest.ExtendedClasses.TestSuiteExtended; TestSuiteExtended; import UnitTest.ExtendedClasses.VellumPerformanceCase; VellumPerformanceCase; - import UnitTest.ExtendedClasses.VellumTestCase; VellumTestCase; + import UnitTest.Fixtures.FileRepository; FileRepository; import UnitTest.Fixtures.TestApp; TestApp; import UnitTest.Fixtures.TestConfig; TestConfig; import UnitTest.Fixtures.TestEditManager; TestEditManager; - import UnitTest.Validation.BoundsChecker; BoundsChecker; - import UnitTest.Validation.CompositionCompleteEventValidator; CompositionCompleteEventValidator; - import UnitTest.Validation.CompositionResults; CompositionResults; - import UnitTest.Validation.DamageEventValidator; DamageEventValidator; - import UnitTest.Validation.EventValidator; EventValidator; - import UnitTest.Validation.FlowElementMouseEventValidator; FlowElementMouseEventValidator; - import UnitTest.Validation.FlowOperationEventValidator; FlowOperationEventValidator; + import UnitTest.Validation.LineSnapshot; LineSnapshot; - import UnitTest.Validation.SelectionEventValidator; SelectionEventValidator; - import UnitTest.Validation.StatusChangeEventValidator; StatusChangeEventValidator; - import UnitTest.Validation.UpdateCompleteEventValidator; UpdateCompleteEventValidator; - import UnitTest.Validation.XMLSnapshot; XMLSnapshot; + + import UnitTest.Validation.XMLSnapshot; XMLSnapshot; */ // Alphabetical list of classes to be included as part of vellum.swc. // This should mirror what's in the .flexLibProperties } http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_core/src/UnitTest/ExtendedClasses/TestCaseBase.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/ExtendedClasses/TestCaseBase.as b/automation_core/src/UnitTest/ExtendedClasses/TestCaseBase.as new file mode 100644 index 0000000..ff6ff8b --- /dev/null +++ b/automation_core/src/UnitTest/ExtendedClasses/TestCaseBase.as @@ -0,0 +1,35 @@ +/** + * Created with IntelliJ IDEA. + * User: piotr.zarzycki + * Date: 24.03.14 + * Time: 20:49 + * To change this template use File | Settings | File Templates. + */ +package UnitTest.ExtendedClasses +{ + public class TestCaseBase + { + public var setUpDuration:Number; + public var setUpMemInitial:Object; + public var setUpMemFinal:Object; + public var middleDuration:Number; + public var middleMemInitial:Object; + public var middleMemFinal:Object; + public var tearDownDuration:Number; + public var tearDownMemInitial:Object; + public var tearDownMemFinal:Object; + public var metaData:Object; + + public var methodName:String; + + public function TestCaseBase(methodName:String = null) + { + this.methodName = methodName; + } + + public function toString():String + { + return methodName; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as b/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as index bc6e763..81137a3 100644 --- a/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as +++ b/automation_core/src/UnitTest/ExtendedClasses/TestSuiteExtended.as @@ -16,131 +16,128 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// -package UnitTest.ExtendedClasses -{ - import flash.events.Event; - import flash.system.System; - import flash.utils.*; - - import flexunit.flexui.*; - import flexunit.framework.*; - import flexunit.runner.*; - import flexunit.textui.*; - import flexunit.utils.*; - - public class TestSuiteExtended extends TestSuite - { - public var _parent:Object; - public var currentTest:Test; - public var testDescArrayList : Collection; - private var runDescIter:Iterator; - private var listener : TestSuiteTestListener; - - public function TestSuiteExtended(parent:Object=null) - { - super(null); - testDescArrayList = Collection( new ArrayList()); - _parent = parent; - } - - override public function runWithResult( result:TestResult ):void - { - runDescIter = testDescArrayList.iterator(); - listener = new TestSuiteTestListener(this, result); - runNext(result); - } +package UnitTest.ExtendedClasses { + + import UnitTest.ExtendedClasses.*; + + import flash.events.Event; + + import flexunit.framework.*; + import flexunit.utils.*; - private static const _a:uint = 1664525; - private static const _c:uint = 1013904223; - private static var _rand:uint = 47; - - // random from 0 to 1 inclusive I think - private static function getRandom():Number - { - _rand = _a*_rand+_c; - return Number(_rand)/uint.MAX_VALUE; - } - - private function chooseRandomTest():Object - { - _rand = _a*_rand+_c; - var index:int = getRandom() * (testDescArrayList.length()+1) - if (index >= testDescArrayList.length()) - index = testDescArrayList.length()-1; - return testDescArrayList.getItemAt(index); - } - - private var __testCount:int = 0; - private var _maxDeltaMemory:int = -1; - private var _maxDeltaTest:int = -1; - - private var repeatForever:Boolean = false; - private var useRandomTest:Boolean = false; - - override public function runNext( result : TestResult) : void + public dynamic class TestSuiteExtended extends TestSuite { - currentTest = null; - if (!runDescIter.hasNext() && repeatForever) - runDescIter = testDescArrayList.iterator(); - if ( runDescIter.hasNext() ) + public var _parent:Object; + public var currentTest:Test; + public var testDescArrayList:Collection; + private var runDescIter:Iterator; + private var listener:TestSuiteTestListener; + + public function TestSuiteExtended(parent:Object = null) + { + super(null); + testDescArrayList = Collection(new ArrayList()); + _parent = parent; + } + + override public function runWithResult(result:TestResult):void + { + runDescIter = testDescArrayList.iterator(); + listener = new TestSuiteTestListener(this, result); + runNext(result); + } + + private static const _a:uint = 1664525; + private static const _c:uint = 1013904223; + private static var _rand:uint = 47; + + // random from 0 to 1 inclusive I think + private static function getRandom():Number + { + _rand = _a * _rand + _c; + return Number(_rand) / uint.MAX_VALUE; + } + + private function chooseRandomTest():Object + { + _rand = _a * _rand + _c; + var index:int = getRandom() * (testDescArrayList.length() + 1) + if (index >= testDescArrayList.length()) + index = testDescArrayList.length() - 1; + return testDescArrayList.getItemAt(index); + } + + private var __testCount:int = 0; + private var _maxDeltaMemory:int = -1; + private var _maxDeltaTest:int = -1; + + private var repeatForever:Boolean = false; + private var useRandomTest:Boolean = false; + + override public function runNext(result:TestResult):void { - if ( result.shouldStop() ) + currentTest = null; + if (!runDescIter.hasNext() && repeatForever) + runDescIter = testDescArrayList.iterator(); + if (runDescIter.hasNext()) { + if (result.shouldStop()) + { + listener.pop(); + return; + } + + currentTest = useRandomTest ? chooseRandomTest().makeTest() : runDescIter.next().makeTest(); + + /*var curMemory:int = System.totalMemory; + __testCount++; + trace(__testCount,_maxDeltaTest,_maxDeltaMemory,currentTest.toString());*/ + + runTest(currentTest, result); + + /*System.gc();System.gc(); + var aftMemory:int = System.totalMemory; + var deltaMemory:int = aftMemory-curMemory; + if (deltaMemory > _maxDeltaMemory) + { + _maxDeltaMemory = deltaMemory; + _maxDeltaTest = __testCount; + }*/ + } + else + { + if (_parent != null) + _parent.dispatchEvent(new Event("TestComplete")); listener.pop(); - return; } + } - currentTest = useRandomTest ? chooseRandomTest().makeTest() : runDescIter.next().makeTest(); + private function runTest(test:Test, result:TestResult):void + { + test.runWithResult(result); + } - /*var curMemory:int = System.totalMemory; - __testCount++; - trace(__testCount,_maxDeltaTest,_maxDeltaMemory,currentTest.toString());*/ + override public function testCount():Number + { + return testDescArrayList.length(); + } - runTest( currentTest, result ); + override public function getTests():Array + { + var tempArray:Array = testDescArrayList.toArray(); + return testDescArrayList.toArray(); + } - /*System.gc();System.gc(); - var aftMemory:int = System.totalMemory; - var deltaMemory:int = aftMemory-curMemory; - if (deltaMemory > _maxDeltaMemory) - { - _maxDeltaMemory = deltaMemory; - _maxDeltaTest = __testCount; - }*/ + public function addTestDescriptor(descriptor:TestDescriptor):void + { + testDescArrayList.addItem(descriptor); } - else + + override public function countTestCases():Number { - if (_parent != null) - _parent.dispatchEvent(new Event("TestComplete")); - listener.pop(); + return testCount(); // currently it's a flat list. } - } - private function runTest( test:Test, result:TestResult ):void - { - test.runWithResult( result ); - } - - override public function testCount() : Number - { - return testDescArrayList.length(); - } - - override public function getTests() : Array - { - var tempArray:Array = testDescArrayList.toArray(); - return testDescArrayList.toArray(); - } - - public function addTestDescriptor ( descriptor:TestDescriptor ) : void - { - testDescArrayList.addItem (descriptor); - } - - override public function countTestCases() : Number - { - return testCount(); // currently it's a flat list. - } - - } + } } http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/cad064e0/automation_core/src/UnitTest/ExtendedClasses/VellumPerformanceCase.as ---------------------------------------------------------------------- diff --git a/automation_core/src/UnitTest/ExtendedClasses/VellumPerformanceCase.as b/automation_core/src/UnitTest/ExtendedClasses/VellumPerformanceCase.as index 2f032c8..a914729 100644 --- a/automation_core/src/UnitTest/ExtendedClasses/VellumPerformanceCase.as +++ b/automation_core/src/UnitTest/ExtendedClasses/VellumPerformanceCase.as @@ -19,15 +19,16 @@ package UnitTest.ExtendedClasses { import flash.events.Event; + import flash.utils.getQualifiedClassName; - import flexunit.framework.TestCase; + import flexunit.framework.TestCase; import flexunit.framework.TestSuite; import mx.collections.ArrayCollection; import mx.controls.ComboBox; import mx.containers.Canvas; - public class VellumPerformanceCase extends TestCase + public class VellumPerformanceCase extends TestCaseBase { private static const standardTimeout:int = 1000000; public static var testApp:Canvas; @@ -48,7 +49,8 @@ package UnitTest.ExtendedClasses } // always add className to the TestID - TestID = className.substr(className.lastIndexOf(':')+1) + '.'; + var className:String = getQualifiedClassName(this); + TestID = className.substr(className.lastIndexOf(':')+1) + '.'; TestID = TestID + ((TestData.id) ? TestData.id : methodName); super(methodName); @@ -56,7 +58,7 @@ package UnitTest.ExtendedClasses override public function toString():String { - return TestID + " (" + className + ")"; + return TestID + " (" + getQualifiedClassName(this) + ")"; } public static function suiteFromXML(testCaseClass:Class, testListXML:XML):TestSuite @@ -69,14 +71,15 @@ package UnitTest.ExtendedClasses return ts; } - override public function tearDown() : void + public function tearDown() : void { TestData = null; } public function addAsyncForTestComplete (timeout:int = standardTimeout):void { - testApp.addEventListener(Event.COMPLETE, addAsync(testComplete, timeout, null)); + //TODO: Add Support for addSync PZ + //testApp.addEventListener(Event.COMPLETE, addAsync(testComplete, timeout, null)); } /** empty testComplete to call once the performance app sends
