You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(45) |
Apr
(7) |
May
(2) |
Jun
(5) |
Jul
|
Aug
(8) |
Sep
(49) |
Oct
(13) |
Nov
(11) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(13) |
Feb
(4) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(7) |
Dec
(1) |
| 2008 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(15) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
| 2009 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <luk...@us...> - 2006-11-07 00:11:54
|
Revision: 133
http://svn.sourceforge.net/asunit/?rev=133&view=rev
Author: lukebayes
Date: 2006-11-06 16:11:50 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
Cleaned up LayoutManager code to avoid framework dependencies
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-11-07 00:01:21 UTC (rev 132)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-11-07 00:11:50 UTC (rev 133)
@@ -13,7 +13,7 @@
import flash.events.TimerEvent;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
- import mx.managers.LayoutManager;
+ import flash.utils.getDefinitionByName;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -94,6 +94,7 @@
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
+ private var layoutManager:Object;
/**
* Constructs a test case with the given name.
@@ -111,7 +112,24 @@
setTestMethods(methods);
}
setName(className.toString());
+ resolveLayoutManager();
}
+
+ private function resolveLayoutManager():void {
+ // Avoid creating import dependencies on flex framework
+ // If you have the framework.swc in your classpath,
+ // the layout manager will be found, if not, a mcok
+ // will be used.
+ try {
+ var manager:Class = getDefinitionByName("mx.managers.LayoutManager") as Class;
+ layoutManager = manager["getInstance"]();
+ }
+ catch(e:Error) {
+ layoutManager = new Object();
+ layoutManager.resetAll = function():void {
+ }
+ }
+ }
/**
* Sets the name of a TestCase
@@ -310,7 +328,7 @@
}
if(!runSingle) {
tearDown();
- LayoutManager.getInstance().resetAll();
+ layoutManager.resetAll();
}
setTimeout(runBare, 5);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-11-07 00:01:35
|
Revision: 132
http://svn.sourceforge.net/asunit/?rev=132&view=rev
Author: lukebayes
Date: 2006-11-06 16:01:21 -0800 (Mon, 06 Nov 2006)
Log Message:
-----------
Added custom Implementation of LayoutManager that will prevent Validation of Flex components after tearDown has been called, this greatly speeds up the execution of larger test suites
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
Added Paths:
-----------
trunk/framework/as3/mx/
trunk/framework/as3/mx/managers/
trunk/framework/as3/mx/managers/ILayoutManagerClient.as
trunk/framework/as3/mx/managers/LayoutManager.as
trunk/framework/as3/mx/managers/LayoutManagerTest.as
trunk/framework/as3/mx/managers/MockContainer.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-10-23 19:12:48 UTC (rev 131)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -1,12 +1,10 @@
package {
import asunit.textui.TestRunner;
- import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestCaseTest, "testCustomConstructor");
}
}
}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-23 19:12:48 UTC (rev 131)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -13,6 +13,7 @@
import flash.events.TimerEvent;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
+ import mx.managers.LayoutManager;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -309,6 +310,7 @@
}
if(!runSingle) {
tearDown();
+ LayoutManager.getInstance().resetAll();
}
setTimeout(runBare, 5);
}
Added: trunk/framework/as3/mx/managers/ILayoutManagerClient.as
===================================================================
--- trunk/framework/as3/mx/managers/ILayoutManagerClient.as (rev 0)
+++ trunk/framework/as3/mx/managers/ILayoutManagerClient.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,161 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
+// All Rights Reserved. The following is Source Code and is subject to all
+// restrictions on such code as contained in the End User License Agreement
+// accompanying this product.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.managers
+{
+
+import flash.events.IEventDispatcher;
+import mx.core.mx_internal;
+
+use namespace mx_internal;
+
+/**
+ * The ILayoutManagerClient interface defines the interface
+ * that a component must implement to participate in the
+ * LayoutManager's commit/measurement/layout sequence.
+ *
+ * <p>Objects that implement this interface can be passed to the
+ * LayoutManager's <code>invalidateProperties()</code> method.
+ * When the LayoutManager reaches the commit properties phase,
+ * the LayoutManager invokes this object's <code>validateProperties()</code>
+ * method.</p>
+ *
+ * <p>Similarly, if an object is passed to the LayoutManager's
+ * <code>invalidateSize()</code> method, then the LayoutManager
+ * calls that object's <code>validateSize()</code> method
+ * during its measurement phase, and if an object is passed
+ * to LayoutManager's <code>invalidateDisplayList()</code> method,
+ * then the LayoutManager calls its <code>validateDisplayList()</code> method
+ * during the layout phase.</p>
+ *
+ * <p>The ILayoutManagerClient interface is implemented by the UIComponent
+ * and ProgrammaticSkin classes.</p>
+ */
+public interface ILayoutManagerClient extends IEventDispatcher
+{
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // initialized
+ //----------------------------------
+
+ /**
+ * A flag that determines if an object has been through all three phases
+ * of layout validation (provided that any were required)
+ * This flag should only be modified by the LayoutManager.
+ */
+ function get initialized():Boolean;
+
+ /**
+ * @private
+ */
+ function set initialized(value:Boolean):void;
+
+ //----------------------------------
+ // nestLevel
+ //----------------------------------
+
+ /**
+ * The top-level SystemManager has a nestLevel of 1.
+ * Its immediate children (the top-level Application and any pop-up
+ * windows) have a <code>nestLevel</code> of 2.
+ * Their children have a <code>nestLevel</code> of 3, and so on.
+ *
+ * The <code>nestLevel</code> is used to sort ILayoutManagerClients
+ * during the measurement and layout phases.
+ * During the commit phase, the LayoutManager commits properties on clients
+ * in order of decreasing <code>nestLevel</code>, so that an object's
+ * children have already had their properties committed before Flex
+ * commits properties on the object itself.
+ * During the measurement phase, the LayoutManager measures clients
+ * in order of decreasing <code>nestLevel</code>, so that an object's
+ * children have already been measured before Flex measures
+ * the object itself.
+ * During the layout phase, the LayoutManager lays out clients
+ * in order of increasing <code>nestLevel</code>, so that an object
+ * has a chance to set the sizes of its children before the child
+ * objects are asked to position and size their children.
+ */
+ function get nestLevel():int;
+
+ /**
+ * @private
+ */
+ function set nestLevel(value:int):void;
+
+ //----------------------------------
+ // processedDescriptors
+ //----------------------------------
+
+ /**
+ * @copy mx.core.UIComponent#processedDescriptors
+ */
+ function get processedDescriptors():Boolean;
+
+ /**
+ * @private
+ */
+ function set processedDescriptors(value:Boolean):void;
+
+ //----------------------------------
+ // updateCompletePendingFlag
+ //----------------------------------
+
+ /**
+ * A flag that determines if an object is waiting to have its
+ * <code>updateComplete</code> event dispatched.
+ * This flag should only be modified by the LayoutManager.
+ */
+ function get updateCompletePendingFlag():Boolean;
+
+ /**
+ * @private
+ */
+ function set updateCompletePendingFlag(value:Boolean):void;
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Validates the properties of a component.
+ * If the <code>LayoutManager.invalidateProperties()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateProperties()</code> method
+ * is called when it's time to commit property values.
+ */
+ function validateProperties():void;
+
+ /**
+ * Validates the measured size of the component
+ * If the <code>LayoutManager.invalidateSize()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateSize()</code> method
+ * is called when it's time to do measurements.
+ *
+ * @param recursive If <code>true</code>, call this method
+ * on the objects children.
+ */
+ function validateSize(recursive:Boolean=false):void;
+
+ /**
+ * Validates the position and size of children and draws other
+ * visuals.
+ * If the <code>LayoutManager.invalidateDisplayList()</code> method is called with
+ * this ILayoutManagerClient, then the <code>validateDisplayList()</code> method
+ * is called when it's time to update the display list.
+ */
+ function validateDisplayList():void;
+}
+
+}
Added: trunk/framework/as3/mx/managers/LayoutManager.as
===================================================================
--- trunk/framework/as3/mx/managers/LayoutManager.as (rev 0)
+++ trunk/framework/as3/mx/managers/LayoutManager.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,945 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
+// All Rights Reserved. The following is Source Code and is subject to all
+// restrictions on such code as contained in the End User License Agreement
+// accompanying this product.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.managers
+{
+
+import flash.display.Stage;
+import flash.events.Event;
+import flash.events.EventDispatcher;
+import mx.core.Application;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+import mx.managers.layoutClasses.PriorityQueue;
+
+use namespace mx_internal;
+
+/**
+ * The LayoutManager is the engine behind
+ * Flex's measurement and layout strategy.
+ * Layout is performed in three phases; commit, measurement, and layout.
+ *
+ * <p>Each phase is distinct from the others and all UIComponents of
+ * one phase are processed prior to moving on to the next phase.
+ * During the processing of UIComponents in a phase, requests for
+ * UIComponents to get re-processed by some phase may occur.
+ * These requests are queued and are only processed
+ * during the next run of the phase.</p>
+ *
+ * <p>The <b>commit</b> phase begins with a call to
+ * <code>validateProperties()</code>, which walks through a list
+ * (sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateProperties()">
+ * <code>validateProperties()</code></a>method.</p>
+ *
+ * <p>The objects in the list are processed by nesting order,
+ * with the <b>most</b> deeply nested object accessed first.
+ * This can also be referred to as bottom-up inside-out ordering.</p>
+ *
+ * <p>This phase allows components whose contents depend on property
+ * settings to configure themselves prior to the measurement
+ * and the layout phases.
+ * For the sake of performance, sometimes a component's property setter
+ * method does not do all the work to update to the new property value.
+ * Instead, the property setter calls the <code>invalidateProperties()</code>
+ * method, deferring the work until this phase runs.
+ * This prevents unnecessary work if the property is set multiple times.</p>
+ *
+ * <p>The <b>measurement</b> phase begins with a call to
+ * <code>validateSize()</code>, which walks through a list
+ * (sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateSize()"><code>validateSize()</code></a>
+ * method to determine if the object has changed in size.</p>
+ *
+ * <p>If an object's <a href="../core/UIComponent.html#invalidateSize()">
+ * <code>invalidateSize()</code></a> method was previously called,
+ * then the <code>validateSize()</code> method is called.
+ * If the size or position of the object was changed as a result of the
+ * <code>validateSize()</code> call, then the object's
+ * <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> method is called, thus adding
+ * the object to the processing queue for the next run of the layout phase.
+ * Additionally, the object's parent is marked for both measurement
+ * and layout phases, by calling
+ * <a href="../core/UIComponent.html#invalidateSize()">
+ * <code>invalidateSize()</code></a> and
+ * <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> respectively.</p>
+ *
+ * <p>The objects in the list are processed by nesting order,
+ * with the <b>most</b> deeply nested object accessed first.
+ * This can also be referred to as bottom-up inside-out ordering.</p>
+ *
+ * <p>The <b>layout</b> phase begins with a call to the
+ * <code>validateDisplayList()</code> method, which walks through a list
+ * (reverse sorted by nesting level) of objects calling each object's
+ * <a href="../core/UIComponent.html#validateDisplayList()">
+ * <code>validateDisplayList()</code></a> method to request the object to size
+ * and position all components contained within it (i.e. its children).</p>
+ *
+ * <p>If an object's <a href="../core/UIComponent.html#invalidateDisplayList()">
+ * <code>invalidateDisplayList()</code></a> method was previously called,
+ * then <code>validateDisplayList()</code> method for the object is called.</p>
+ *
+ * <p>The objects in the list are processed in reversed nesting order,
+ * with the <b>least</b> deeply nested object accessed first.
+ * This can also be referred to as top-down or outside-in ordering.</p>
+ *
+ * <p>In general, components do not override the <code>validateProperties()</code>,
+ * <code>validateSize()</code>, or <code>validateDisplayList()</code> methods.
+ * In the case of UIComponents, most components override the
+ * <code>commitProperties()</code>, <code>measure()</code>, or
+ * <code>updateDisplayList()</code> methods, which are called
+ * by the <code>validateProperties()</code>,
+ * <code>validateSize()</code>, or
+ * <code>validateDisplayList()</code> methods, respectively.</p>
+ *
+ * <p>At application startup, a single instance of the LayoutManager is created
+ * and stored in the <code>UIComponent.layoutManager</code> property.
+ * All components are expected to use that instance.
+ * If you do not have access to the UIComponent object,
+ * you can also access the LayoutManager using the static
+ * <code>LayoutManager.getInstance()</code> method.</p>
+ */
+public class LayoutManager extends EventDispatcher
+{
+
+ //--------------------------------------------------------------------------
+ //
+ // Class variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * The sole instance of this singleton class.
+ */
+ private static var instance:LayoutManager;
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the sole instance of this singleton class,
+ * creating it if it does not already exist.
+ */
+ public static function getInstance():LayoutManager
+ {
+ if (!instance)
+ instance = new LayoutManager();
+
+ return instance;
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ */
+ public function LayoutManager()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Variables
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * @private
+ * A queue of objects that need to dispatch updateComplete events
+ * when invalidation processing is complete
+ */
+ private var updateCompleteQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A queue of objects to be processed during the first phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateProperties() method called (which in a UIComponent
+ * calls commitProperties()).
+ * Objects are added to this queue by invalidateProperties()
+ * and removed by validateProperties().
+ */
+ private var invalidatePropertiesQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidatePropertiesQueue.
+ * It is set true by invalidateProperties()
+ * and set false by validateProperties().
+ */
+ private var invalidatePropertiesFlag:Boolean = false;
+
+ // flag when in validateClient to check the properties queue again
+ private var invalidateClientPropertiesFlag:Boolean = false;
+
+ /**
+ * @private
+ * A queue of objects to be processed during the second phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateSize() method called (which in a UIComponent
+ * calls measure()).
+ * Objects are added to this queue by invalidateSize().
+ * and removed by validateSize().
+ */
+ private var invalidateSizeQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidateSizeQueue.
+ * It is set true by invalidateSize()
+ * and set false by validateSize().
+ */
+ private var invalidateSizeFlag:Boolean = false;
+
+ // flag when in validateClient to check the size queue again
+ private var invalidateClientSizeFlag:Boolean = false;
+
+ /**
+ * @private
+ * A queue of objects to be processed during the third phase
+ * of invalidation processing, when an ILayoutManagerClient has
+ * its validateDisplayList() method called (which in a
+ * UIComponent calls updateDisplayList()).
+ * Objects are added to this queue by invalidateDisplayList()
+ * and removed by validateDisplayList().
+ */
+ private var invalidateDisplayListQueue:PriorityQueue = new PriorityQueue();
+
+ /**
+ * @private
+ * A flag indicating whether there are objects
+ * in the invalidateDisplayListQueue.
+ * It is set true by invalidateDisplayList()
+ * and set false by validateDisplayList().
+ */
+ private var invalidateDisplayListFlag:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var callLaterObject:UIComponent;
+
+ /**
+ * @private
+ */
+ private var callLaterPending:Boolean = false;
+
+ /**
+ * @private
+ */
+ private var originalFrameRate:Number;
+
+ /**
+ * @private
+ * used in validateClient to quickly estimate whether we have to
+ * search the queues again
+ */
+ private var targetLevel:int = int.MAX_VALUE;
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ //----------------------------------
+ // usePhasedInstantiation
+ //----------------------------------
+
+ /**
+ * @private
+ * Storage for the usePhasedInstantiation property.
+ */
+ private var _usePhasedInstantiation:Boolean = false;
+
+ /**
+ * A flag that indicates whether the LayoutManager allows screen updates
+ * between phases.
+ * If <code>true</code>, measurement and layout are done in phases, one phase
+ * per screen update.
+ * All components have their <code>validateProperties()</code>
+ * and <code>commitProperties()</code> methods
+ * called until all their properties are validated.
+ * The screen will then be updated.
+ *
+ * <p>Then all components will have their <code>validateSize()</code>
+ * and <code>measure()</code>
+ * methods called until all components have been measured, then the screen
+ * will be updated again. </p>
+ *
+ * <p>Finally, all components will have their
+ * <code>validateDisplayList()</code> and
+ * <code>updateDisplayList()</code> methods called until all components
+ * have been validated, and the screen will be updated again.
+ * If in the validation of one phase, an earlier phase gets invalidated,
+ * the LayoutManager starts over.
+ * This is more efficient when large numbers of components
+ * are being created an initialized. The framework is responsible for setting
+ * this property.</p>
+ *
+ * <p>If <code>false</code>, all three phases are completed before the screen is updated.</p>
+ */
+ public function get usePhasedInstantiation():Boolean
+ {
+ return _usePhasedInstantiation;
+ }
+
+ /**
+ * @private
+ */
+ public function set usePhasedInstantiation(value:Boolean):void
+ {
+ if (_usePhasedInstantiation != value)
+ {
+ _usePhasedInstantiation = value;
+
+ // While we're doing phased instantiation, temporarily increase
+ // the frame rate. That will cause the enterFrame and render
+ // events to fire more promptly, which improves performance.
+ var stage:Stage = SystemManager.topLevelSystemManagers[0].stage;
+ if (value)
+ {
+ originalFrameRate = stage.frameRate;
+ stage.frameRate = 1000;
+ }
+ else
+ {
+ stage.frameRate = originalFrameRate;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: Invalidation
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Adds an object to the list of components that want their
+ * <code>validateProperties()</code> method called.
+ * A component should call this method when a property changes.
+ * Typically, a property setter method
+ * stores a the new value in a temporary variable and calls
+ * the <code>invalidateProperties()</code> method
+ * so that its <code>validateProperties()</code>
+ * and <code>commitProperties()</code> methods are called
+ * later, when the new value will actually be applied to the component and/or
+ * its children. The advantage of this strategy is that often, more than one
+ * property is changed at a time and the properties may interact with each
+ * other, or repeat some code as they are applied, or need to be applied in
+ * a specific order. This strategy allows the most efficient method of
+ * applying new property values.
+ *
+ * @param obj The object whose property changed.
+ */
+ public function invalidateProperties(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidatePropertiesFlag && Application.application.systemManager)
+ {
+ invalidatePropertiesFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidatePropertiesQueue");
+
+ if (targetLevel <= obj.nestLevel)
+ invalidateClientPropertiesFlag = true;
+
+ invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidatePropertiesQueue");
+ }
+
+ /**
+ * Adds an object to the list of components that want their
+ * <code>validateSize()</code> method called.
+ * Called when an object's size changes.
+ *
+ * <p>An object's size can change for two reasons:</p>
+ *
+ * <ol>
+ * <li>The content of the object changes. For example, the size of a
+ * button changes when its <code>label</code> is changed.</li>
+ * <li>A script explicitly changes one of the following properties:
+ * <code>minWidth</code>, <code>minHeight</code>,
+ * <code>explicitWidth</code>, <code>explicitHeight</code>,
+ * <code>maxWidth</code>, or <code>maxHeight</code>.</li>
+ * </ol>
+ *
+ * <p>When the first condition occurs, it's necessary to recalculate
+ * the measurements for the object.
+ * When the second occurs, it's not necessary to recalculate the
+ * measurements because the new size of the object is known.
+ * However, it's necessary to remeasure and relayout the object's
+ * parent.</p>
+ *
+ * @param obj The object whose size changed.
+ */
+ public function invalidateSize(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidateSizeFlag && Application.application.systemManager)
+ {
+ invalidateSizeFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidateSizeQueue");
+
+ if (targetLevel <= obj.nestLevel)
+ invalidateClientSizeFlag = true;
+
+ invalidateSizeQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidateSizeQueue");
+ }
+
+ /**
+ * Called when a component changes in some way that its layout and/or visuals
+ * need to be changed.
+ * In that case, it is necessary to run the component's layout algorithm,
+ * even if the component's size hasn't changed. For example, when a new child component
+ * is added, or a style property changes or the component has been given
+ * a new size by its parent.
+ *
+ * @param obj The object that changed.
+ */
+ public function invalidateDisplayList(obj:ILayoutManagerClient ):void
+ {
+ if (!invalidateDisplayListFlag && Application.application.systemManager)
+ {
+ invalidateDisplayListFlag = true;
+
+ if (!callLaterPending)
+ {
+ if (!callLaterObject)
+ {
+ callLaterObject = new UIComponent();
+ callLaterObject.systemManager =
+ Application.application.systemManager;
+ callLaterObject.callLater(waitAFrame);
+ }
+ else
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+
+ callLaterPending = true;
+ }
+ }
+
+ // trace("LayoutManager adding " + Object(obj) + " to invalidateDisplayListQueue");
+
+ invalidateDisplayListQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager added " + Object(obj) + " to invalidateDisplayListQueue");
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Methods: Commitment, measurement, layout, and drawing
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateProperties()</code> method.
+ * It calls the <code>validateProperties()</code> method on those components
+ * and will call <code>validateProperties()</code> on any other components that are
+ * invalidated while validating other components.
+ */
+ private function validateProperties():void
+ {
+ // trace("--- LayoutManager: validateProperties --->");
+
+ // Keep traversing the invalidatePropertiesQueue until we've reached the end.
+ // More elements may get added to the queue while we're in this loop, or a
+ // a recursive call to this function may remove elements from the queue while
+ // we're in this loop.
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateProperties() on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateProperties();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallest());
+ }
+
+ if (invalidatePropertiesQueue.isEmpty())
+ {
+ // trace("Properties Queue is empty");
+
+ invalidatePropertiesFlag = false;
+ }
+
+ // trace("<--- LayoutManager: validateProperties ---");
+ }
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateSize()</code> method.
+ * It calls the <code>validateSize()</code> method on those components
+ * and will call the <code>validateSize()</code> method
+ * on any other components that are
+ * invalidated while validating other components.
+ * The </code>validateSize()</code> method starts with
+ * the most deeply nested child in the tree of display objects
+ */
+ private function validateSize():void
+ {
+ // trace("--- LayoutManager: validateSize --->");
+
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateSize() on " + Object(obj));
+
+ obj.validateSize();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager validateSize: " + Object(obj) + " " + IFlexDisplayObject(obj).measuredWidth + " " + IFlexDisplayObject(obj).measuredHeight);
+
+ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargest());
+ }
+
+ if (invalidateSizeQueue.isEmpty())
+ {
+ // trace("Measurement Queue is empty");
+
+ invalidateSizeFlag = false;
+ }
+
+ // trace("<--- LayoutManager: validateSize ---");
+ }
+
+ /**
+ * Validates all components whose properties have changed and have called
+ * the <code>invalidateDisplayList()</code> method.
+ * It calls <code>validateDisplayList()</code> method on those components
+ * and will call the <code>validateDisplayList()</code> method
+ * on any other components that are
+ * invalidated while validating other components.
+ * The <code>validateDisplayList()</code> method starts with
+ * the least deeply nested child in the tree of display objects
+ *
+ */
+ private function validateDisplayList():void
+ {
+
+ // trace("--- LayoutManager: validateDisplayList --->");
+
+ var obj:ILayoutManagerClient = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
+ while (obj)
+ {
+ // trace("LayoutManager calling validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateDisplayList();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager return from validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallest());
+ }
+
+
+ if (invalidateDisplayListQueue.isEmpty())
+ {
+ // trace("Layout Queue is empty");
+
+ invalidateDisplayListFlag = false;
+ }
+
+ // trace("<--- LayoutManager: validateDisplayList ---");
+ }
+
+ /**
+ * @private
+ */
+ private function doPhasedInstantiation():void
+ {
+ // trace(">>DoPhasedInstantation");
+
+ // If phasing, do only one phase: validateProperties(),
+ // validateSize(), or validateDisplayList().
+ if (usePhasedInstantiation)
+ {
+ if (invalidatePropertiesFlag)
+ {
+ validateProperties();
+
+ // The Preloader listens for this event.
+ Application.application.dispatchEvent(
+ new Event("validatePropertiesComplete"));
+ }
+
+ else if (invalidateSizeFlag)
+ {
+ validateSize();
+
+ // The Preloader listens for this event.
+ Application.application.dispatchEvent(
+ new Event("validateSizeComplete"));
+ }
+
+ else if (invalidateDisplayListFlag)
+ {
+ validateDisplayList();
+
+ // The Preloader listens for this event.
+ Application.application.dispatchEvent(
+ new Event("validateDisplayListComplete"));
+ }
+ }
+
+ // Otherwise, do one pass of all three phases.
+ else
+ {
+ if (invalidatePropertiesFlag)
+ validateProperties();
+
+ if (invalidateSizeFlag)
+ validateSize();
+
+ if (invalidateDisplayListFlag)
+ validateDisplayList();
+ }
+
+ //// trace("invalidatePropertiesFlag " + invalidatePropertiesFlag);
+ //// trace("invalidateSizeFlag " + invalidateSizeFlag);
+ //// trace("invalidateDisplayListFlag " + invalidateDisplayListFlag);
+
+ if (invalidatePropertiesFlag ||
+ invalidateSizeFlag ||
+ invalidateDisplayListFlag)
+ {
+ callLaterObject.callLater(doPhasedInstantiation);
+ }
+ else
+ {
+ usePhasedInstantiation = false;
+
+ callLaterPending = false;
+
+ var obj:ILayoutManagerClient = ILayoutManagerClient(updateCompleteQueue.removeLargest());
+ while (obj)
+ {
+ if (!obj.initialized && obj.processedDescriptors)
+ obj.initialized = true;
+ obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
+ obj.updateCompletePendingFlag = false;
+ obj = ILayoutManagerClient(updateCompleteQueue.removeLargest());
+ }
+
+ // trace("updateComplete");
+
+ dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
+ }
+
+ // trace("<<DoPhasedInstantation");
+ }
+
+ /**
+ * When properties are changed, components generally do not apply those changes immediately.
+ * Instead the components usually call one of the LayoutManager's invalidate methods and
+ * apply the properties at a later time. The actual property you set can be read back
+ * immediately, but if the property affects other properties in the component or its
+ * children or parents, those other properties may not be immediately updated. To
+ * guarantee that the values are updated, you can call the <code>validateNow()</code> method.
+ * It updates all properties in all components before returning.
+ * Call this method only when necessary as it is a computationally intensive call.
+ */
+ public function validateNow():void
+ {
+ if (!usePhasedInstantiation)
+ {
+ var infiniteLoopGuard:int = 0;
+ while (callLaterPending && infiniteLoopGuard++ < 100)
+ doPhasedInstantiation();
+ }
+ }
+
+ /**
+ * When properties are changed, components generally do not apply those changes immediately.
+ * Instead the components usually call one of the LayoutManager's invalidate methods and
+ * apply the properties at a later time. The actual property you set can be read back
+ * immediately, but if the property affects other properties in the component or its
+ * children or parents, those other properties may not be immediately updated.
+ *
+ * <p>To guarantee that the values are updated,
+ * you can call the <code>validateClient()</code> method.
+ * It updates all properties in all components whose nest level is greater than or equal
+ * to the target component before returning.
+ * Call this method only when necessary as it is a computationally intensive call.</p>
+ *
+ * @param target The component passed in is used to test which components
+ * should be validated. All components contained by this component will have their
+ * <code>validateProperties()</code>, <code>commitProperties()</code>,
+ * <code>validateSize()</code>, <code>measure()</code>,
+ * <code>validateDisplayList()</code>,
+ * and <code>updateDisplayList()</code> methods called.
+ *
+ * @param skipDisplayList If <code>true</code>,
+ * does not call the <code>validateDisplayList()</code>
+ * and <code>updateDisplayList()</code> methods.
+ */
+ public function validateClient(target:ILayoutManagerClient , skipDisplayList:Boolean = false):void
+ {
+ var obj:ILayoutManagerClient;
+ var i:int = 0;
+ var done:Boolean = false;
+ var oldTargetLevel:int = targetLevel;
+
+ // the theory here is that most things that get validated are deep in the tree
+ // and so there won't be nested calls to validateClient. However if there is,
+ // we don't want to have a more sophisticated scheme of keeping track
+ // of dirty flags at each level that is being validated, but we definitely
+ // do not want to keep scanning the queues unless we're pretty sure that
+ // something might be dirty so we just say that if something got dirty
+ // during this call at a deeper nesting than the first call to validateClient
+ // then we'll scan the queues. So we only change targetLevel if we're the
+ // outer call to validateClient and only that call restores it.
+ if (targetLevel == int.MAX_VALUE)
+ targetLevel = target.nestLevel;
+
+ // trace("--- LayoutManager: validateClient ---> target = " + target);
+
+ while (!done)
+ {
+ // assume we won't find anything
+ done = true;
+
+ // Keep traversing the invalidatePropertiesQueue until we've reached the end.
+ // More elements may get added to the queue while we're in this loop, or a
+ // a recursive call to this function may remove elements from the queue while
+ // we're in this loop.
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
+ while (obj)
+ {
+ // trace("LayoutManager calling validateProperties() on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateProperties();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
+ }
+
+ if (invalidatePropertiesQueue.isEmpty())
+ {
+ // trace("Properties Queue is empty");
+
+ invalidatePropertiesFlag = false;
+ invalidateClientPropertiesFlag = false;
+ }
+
+ // trace("--- LayoutManager: validateSize --->");
+
+ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
+ while (obj)
+ {
+ // trace("LayoutManager calling validateSize() on " + Object(obj));
+
+ obj.validateSize();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager validateSize: " + Object(obj) + " " + IFlexDisplayObject(obj).measuredWidth + " " + IFlexDisplayObject(obj).measuredHeight);
+
+ if (invalidateClientPropertiesFlag)
+ {
+ // did any properties get invalidated while validating size?
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
+ if (obj)
+ {
+ // re-queue it. we'll pull it at the beginning of the loop
+ invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
+ done = false;
+ break;
+ }
+ }
+
+ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
+ }
+
+ if (invalidateSizeQueue.isEmpty())
+ {
+ // trace("Measurement Queue is empty");
+
+ invalidateSizeFlag = false;
+ invalidateClientSizeFlag = false;
+ }
+
+ if (!skipDisplayList)
+ {
+ // trace("--- LayoutManager: validateDisplayList --->");
+
+ obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target));
+ while (obj)
+ {
+ // trace("LayoutManager calling validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ obj.validateDisplayList();
+ if (!obj.updateCompletePendingFlag)
+ updateCompleteQueue.addObject(obj, obj.nestLevel);
+
+ // trace("LayoutManager return from validateDisplayList on " + Object(obj) + " " + DisplayObject(obj).width + " " + DisplayObject(obj).height);
+
+ if (invalidateClientPropertiesFlag)
+ {
+ // did any properties get invalidated while validating size?
+ obj = ILayoutManagerClient(invalidatePropertiesQueue.removeSmallestChild(target));
+ if (obj)
+ {
+ // re-queue it. we'll pull it at the beginning of the loop
+ invalidatePropertiesQueue.addObject(obj, obj.nestLevel);
+ done = false;
+ break;
+ }
+ }
+
+ if (invalidateClientSizeFlag)
+ {
+ obj = ILayoutManagerClient(invalidateSizeQueue.removeLargestChild(target));
+ if (obj)
+ {
+ // re-queue it. we'll pull it at the beginning of the loop
+ invalidateSizeQueue.addObject(obj, obj.nestLevel);
+ done = false;
+ break;
+ }
+ }
+
+ // Once we start, don't stop.
+ obj = ILayoutManagerClient(invalidateDisplayListQueue.removeSmallestChild(target));
+ }
+
+
+ if (invalidateDisplayListQueue.isEmpty())
+ {
+ // trace("Layout Queue is empty");
+
+ invalidateDisplayListFlag = false;
+ }
+ }
+ }
+
+ if (oldTargetLevel == int.MAX_VALUE)
+ {
+ targetLevel = int.MAX_VALUE;
+ if (!skipDisplayList)
+ {
+ obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
+ while (obj)
+ {
+ if (!obj.initialized)
+ obj.initialized = true;
+ obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
+ obj.updateCompletePendingFlag = false;
+ obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
+ }
+ }
+ }
+
+ // trace("<--- LayoutManager: validateClient --- target = " + target);
+ }
+
+ /**
+ * Returns <code>true</code> if there are components that need validating;
+ * <code>false</code> if all components have been validated.
+ */
+ public function isInvalid():Boolean
+ {
+ return invalidatePropertiesFlag ||
+ invalidateSizeFlag ||
+ invalidateDisplayListFlag;
+ }
+
+ /**
+ * @private
+ * callLater() is called immediately after an object is created.
+ * We really want to wait one more frame before starting in.
+ */
+ private function waitAFrame():void
+ {
+ //// trace(">>LayoutManager:WaitAFrame");
+
+ callLaterObject.callLater(doPhasedInstantiation);
+
+ //// trace("<<LayoutManager:WaitAFrame");
+ }
+
+ // METHOD ADDED BY ASUNIT
+ // This method prevents the LayoutManager from
+ // validating entities for whom tearDown has already been called...
+ public function resetAll():void {
+ invalidatePropertiesQueue = new PriorityQueue();
+ invalidateSizeQueue = new PriorityQueue();
+ invalidateDisplayListQueue = new PriorityQueue();
+
+ invalidatePropertiesFlag = false;
+ invalidateClientSizeFlag = false;
+ invalidateDisplayListFlag = false;
+ }
+}
+
+}
Added: trunk/framework/as3/mx/managers/LayoutManagerTest.as
===================================================================
--- trunk/framework/as3/mx/managers/LayoutManagerTest.as (rev 0)
+++ trunk/framework/as3/mx/managers/LayoutManagerTest.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,34 @@
+package mx.managers {
+ import asunit.framework.TestCase;
+ import mx.core.Container;
+
+ public class LayoutManagerTest extends TestCase {
+ private var container:MockContainer;
+ private var instance:LayoutManager;
+
+ public function LayoutManagerTest(testMethod:String=null) {
+ super(testMethod);
+ }
+
+ override protected function setUp():void {
+ trace("set up");
+ instance = LayoutManager.getInstance();
+ container = new MockContainer();
+ addChild(container);
+ }
+
+ override protected function tearDown():void {
+ trace("tearDown");
+ removeChild(container);
+ container = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue(instance is LayoutManager);
+ }
+
+ public function testContainer():void {
+ assertTrue(container is MockContainer);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/framework/as3/mx/managers/MockContainer.as
===================================================================
--- trunk/framework/as3/mx/managers/MockContainer.as (rev 0)
+++ trunk/framework/as3/mx/managers/MockContainer.as 2006-11-07 00:01:21 UTC (rev 132)
@@ -0,0 +1,16 @@
+package mx.managers {
+ import mx.core.Container;
+
+ public class MockContainer extends Container {
+
+ override protected function commitProperties():void {
+ super.commitProperties();
+ trace("commit props");
+ }
+
+ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
+ super.updateDisplayList(unscaledWidth, unscaledHeight);
+ trace("update display list");
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-23 19:25:14
|
Revision: 131
http://svn.sourceforge.net/asunit/?rev=131&view=rev
Author: lukebayes
Date: 2006-10-23 12:12:48 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Added bug fix to prevent multiple dispacthes to an async method from completing test execution more than once
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-19 18:33:04 UTC (rev 130)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-23 19:12:48 UTC (rev 131)
@@ -174,6 +174,9 @@
* throws Error
*/
public function runBare():void {
+ if(isComplete) {
+ return;
+ }
var name:String;
var itr:Iterator = getMethodIterator();
if(itr.hasNext()) {
@@ -301,6 +304,9 @@
}
protected function runTearDown():void {
+ if(isComplete) {
+ return;
+ }
if(!runSingle) {
tearDown();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-19 18:33:14
|
Revision: 129
http://svn.sourceforge.net/asunit/?rev=129&view=rev
Author: lukebayes
Date: 2006-10-19 11:26:44 -0700 (Thu, 19 Oct 2006)
Log Message:
-----------
Updated links to support sourceforge downloads
Modified Paths:
--------------
trunk/comm/www/html/index.html
Modified: trunk/comm/www/html/index.html
===================================================================
--- trunk/comm/www/html/index.html 2006-10-17 21:41:30 UTC (rev 128)
+++ trunk/comm/www/html/index.html 2006-10-19 18:26:44 UTC (rev 129)
@@ -113,7 +113,7 @@
<table id="badges">
<tr>
<td class="badge">
- <a href="files/releases/XULUI-Win.msi">
+ <a href="http://prdownloads.sourceforge.net/asunit/XULUI-Win.msi?download">
<img class="badgeLabel" src="img/DownloadXULUIText.gif" alt="Download the XULUI" /><br />
<img class="badge" src="img/DownloadXULUI.gif" />
<p class="badge">You use <strong>Eclipse</strong> or some other IDE, you want help building classes, test cases and test suites. You are writing <strong style="white-space:nowrap">ActionScript 2.0 or 3.0</strong>.</p><p class="badge">You are running <strong>Windows</strong>. </p>
@@ -121,7 +121,7 @@
</a>
</td>
<td class="badge">
- <a href="files/releases/FlashUi.mxp">
+ <a href="http://prdownloads.sourceforge.net/asunit/FlashUi.mxp?download">
<img class="badgeLabel" src="img/DownloadMXPText.gif" alt="Download the MXP" /><br />
<img class="badge" src="img/DownloadMXP.gif" />
<p class="badge">You use Flash Authoring. You write <strong>ActionScript 2.0</strong>. You want to get up and running quickly. You are running on <strong>Windows or Macintosh</strong></p>
@@ -129,7 +129,7 @@
</a>
</td>
<td class="badge">
- <a href="files/releases/Framework.zip">
+ <a href="http://prdownloads.sourceforge.net/asunit/Framework.zip?download">
<img id="frameworkDownload" class="badgeLabel" src="img/DownloadFrameworkText.gif" alt="Download the Framework" /><br />
<img class="badge" src="img/DownloadFramework.gif" />
<p class="badge">You use a simple text editor and compiler. You know what a class path is and you don't want to be bothered with all the fluff. You are running on <strong>Windows, Mac, or *nix</strong>.</p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-19 18:33:11
|
Revision: 130
http://svn.sourceforge.net/asunit/?rev=130&view=rev
Author: lukebayes
Date: 2006-10-19 11:33:04 -0700 (Thu, 19 Oct 2006)
Log Message:
-----------
Testing svn mailing list
Modified Paths:
--------------
trunk/comm/www/html/index.html
Modified: trunk/comm/www/html/index.html
===================================================================
--- trunk/comm/www/html/index.html 2006-10-19 18:26:44 UTC (rev 129)
+++ trunk/comm/www/html/index.html 2006-10-19 18:33:04 UTC (rev 130)
@@ -8,6 +8,7 @@
<body>
<center>
<div class="content">
+
<!-- Header -->
<div id="header">
<img src="img/AsUnitLogo.gif" alt="AsUnit Logo" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-17 21:41:33
|
Revision: 128
http://svn.sourceforge.net/asunit/?rev=128&view=rev
Author: lukebayes
Date: 2006-10-17 14:41:30 -0700 (Tue, 17 Oct 2006)
Log Message:
-----------
Working on async methods in TestCase
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-12 06:21:07 UTC (rev 127)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-17 21:41:30 UTC (rev 128)
@@ -103,12 +103,12 @@
var methods:XMLList = description..method.(@name.match("^test"));
if(testMethod != null) {
testMethods = testMethod.split(", ").join(",").split(",");
+ if(testMethods.length == 1) {
+ runSingle = true;
+ }
} else {
setTestMethods(methods);
}
- if(testMethod != null) {
- runSingle = true;
- }
setName(className.toString());
}
@@ -186,28 +186,6 @@
isComplete = true;
dispatchEvent(new Event(Event.COMPLETE));
}
-
-/*
- try {
- while(itr.hasNext()) {
- name = String(itr.next());
- if(!runMethod(name)) {
- runCleanUp = false;
- break;
- }
- }
- }
- finally {
- if(runCleanUp) {
- if(!itr.hasNext()) {
- cleanUp();
- getResult().endTest(this);
- isComplete = true;
- dispatchEvent(new Event(Event.COMPLETE));
- }
- }
- }
-*/
}
private function getMethodIterator():Iterator {
@@ -230,11 +208,11 @@
methodIsAsynchronous = false;
this[methodName]();
}
- catch(e:AssertionFailedError) {
- getResult().addFailure(this, e);
+ catch(assertionFailedError:AssertionFailedError) {
+ getResult().addFailure(this, assertionFailedError);
}
- catch(ioe:Error) {
- getResult().addError(this, ioe);
+ catch(unknownError:Error) {
+ getResult().addError(this, unknownError);
}
finally {
if(!methodIsAsynchronous) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-12 06:21:11
|
Revision: 127
http://svn.sourceforge.net/asunit/?rev=127&view=rev
Author: lukebayes
Date: 2006-10-11 23:21:07 -0700 (Wed, 11 Oct 2006)
Log Message:
-----------
Moved base flex application to textui package
Added Paths:
-----------
trunk/framework/as3/asunit/textui/FlexRunner.as
Removed Paths:
-------------
trunk/framework/as3/AsUnitApplication.as
Deleted: trunk/framework/as3/AsUnitApplication.as
===================================================================
--- trunk/framework/as3/AsUnitApplication.as 2006-10-12 06:13:25 UTC (rev 126)
+++ trunk/framework/as3/AsUnitApplication.as 2006-10-12 06:21:07 UTC (rev 127)
@@ -1,20 +0,0 @@
-package {
- import asunit.framework.TestResult;
- import mx.core.Application;
- import asunit.textui.TestRunner;
- import asunit.textui.FlexTestRunner;
-
- public class AsUnitApplication extends Application {
- protected var runner:TestRunner;
-
- override protected function createChildren():void {
- super.createChildren();
- runner = new FlexTestRunner();
- rawChildren.addChild(runner);
- }
-
- public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
- return runner.start(testCase, testMethod, showTrace);
- }
- }
-}
Added: trunk/framework/as3/asunit/textui/FlexRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/FlexRunner.as (rev 0)
+++ trunk/framework/as3/asunit/textui/FlexRunner.as 2006-10-12 06:21:07 UTC (rev 127)
@@ -0,0 +1,19 @@
+package asunit.textui {
+ import asunit.framework.TestResult;
+
+ import mx.core.Application;
+
+ public class FlexRunner extends Application {
+ protected var runner:TestRunner;
+
+ override protected function createChildren():void {
+ super.createChildren();
+ runner = new FlexTestRunner();
+ rawChildren.addChild(runner);
+ }
+
+ public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
+ return runner.start(testCase, testMethod, showTrace);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-12 06:13:35
|
Revision: 126
http://svn.sourceforge.net/asunit/?rev=126&view=rev
Author: lukebayes
Date: 2006-10-11 23:13:25 -0700 (Wed, 11 Oct 2006)
Log Message:
-----------
Restructured base TestCase so that it now runs completely asynchronously, fully support MXML projects, and addAsync works every time
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestSuite.as
trunk/framework-test/as3/asunit/framework/AllTests.as
trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as
trunk/framework-test/as3/asunit/framework/TestCaseTest.as
Added Paths:
-----------
trunk/framework/as3/AsUnitApplication.as
Removed Paths:
-------------
trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as
Added: trunk/framework/as3/AsUnitApplication.as
===================================================================
--- trunk/framework/as3/AsUnitApplication.as (rev 0)
+++ trunk/framework/as3/AsUnitApplication.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -0,0 +1,20 @@
+package {
+ import asunit.framework.TestResult;
+ import mx.core.Application;
+ import asunit.textui.TestRunner;
+ import asunit.textui.FlexTestRunner;
+
+ public class AsUnitApplication extends Application {
+ protected var runner:TestRunner;
+
+ override protected function createChildren():void {
+ super.createChildren();
+ runner = new FlexTestRunner();
+ rawChildren.addChild(runner);
+ }
+
+ public function start(testCase:Class, testMethod:String = null, showTrace:Boolean = false):TestResult {
+ return runner.start(testCase, testMethod, showTrace);
+ }
+ }
+}
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -1,10 +1,12 @@
package {
import asunit.textui.TestRunner;
+ import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
+// start(TestCaseTest, "testCustomConstructor");
}
}
}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -11,6 +11,8 @@
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
+ import flash.utils.setTimeout;
+ import flash.utils.clearTimeout;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -87,11 +89,10 @@
protected var isComplete:Boolean;
protected var context:DisplayObjectContainer;
protected var methodIsAsynchronous:Boolean;
+ protected var timeout:Timer;
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
- private var timeout:Timer;
- private var lastDuration:Number;
/**
* Constructs a test case with the given name.
@@ -175,7 +176,18 @@
public function runBare():void {
var name:String;
var itr:Iterator = getMethodIterator();
- var runCleanUp:Boolean = true;
+ if(itr.hasNext()) {
+ name = String(itr.next());
+ runMethod(name);
+ }
+ else {
+ cleanUp();
+ getResult().endTest(this);
+ isComplete = true;
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
+
+/*
try {
while(itr.hasNext()) {
name = String(itr.next());
@@ -195,6 +207,7 @@
}
}
}
+*/
}
private function getMethodIterator():Iterator {
@@ -210,10 +223,11 @@
protected function cleanUp():void {
}
- private function runMethod(methodName:String):Boolean {
+ private function runMethod(methodName:String):void {
try {
setUp();
currentMethod = methodName;
+ methodIsAsynchronous = false;
this[methodName]();
}
catch(e:AssertionFailedError) {
@@ -226,7 +240,6 @@
if(!methodIsAsynchronous) {
runTearDown();
}
- return !methodIsAsynchronous;
}
}
@@ -278,16 +291,14 @@
if(handler == null) {
handler = function(args:*):* {};
}
- var context:TestCase = this;
- context.methodIsAsynchronous = true;
- lastDuration = duration;
-
+ methodIsAsynchronous = true;
timeout = new Timer(duration, 1);
- timeout.addEventListener(TimerEvent.TIMER_COMPLETE, timeoutCompleteHandler);
+ timeout.addEventListener(TimerEvent.TIMER_COMPLETE, getTimeoutComplete(duration));
timeout.start();
+ // try ..args
+ var context:TestCase = this;
return function(args:*):* {
context.timeout.stop();
- context.timeout = null;
try {
handler.apply(context, arguments);
}
@@ -295,29 +306,27 @@
context.getResult().addFailure(context, e);
}
catch(ioe:IllegalOperationError) {
- trace('illegaloperation'); // this trace needs to be here?! Why?!
- // without that trace, the app throws an error!!!!
context.getResult().addError(context, ioe);
}
finally {
- context.methodIsAsynchronous = false;
context.runTearDown();
- context.runBare();
}
}
}
- private function timeoutCompleteHandler(event:TimerEvent):void {
- result.addError(this, new IllegalOperationError("TestCase.timeout (" + lastDuration + "ms) exceeded on an asynchronous test method."));
- methodIsAsynchronous = false;
- runTearDown();
- runBare();
+ private function getTimeoutComplete(duration:Number):Function {
+ var context:TestCase = this;
+ return function(event:Event):void {
+ context.getResult().addError(context, new IllegalOperationError("TestCase.timeout (" + duration + "ms) exceeded on an asynchronous test method."));
+ context.runTearDown();
+ }
}
-
+
protected function runTearDown():void {
if(!runSingle) {
tearDown();
}
+ setTimeout(runBare, 5);
}
protected function addChild(child:DisplayObject):DisplayObject {
Modified: trunk/framework/as3/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -62,10 +62,10 @@
test.setResult(result);
test.addEventListener(Event.COMPLETE, testCompleteHandler);
test.run();
-// if(!test.getIsComplete()) {
-// isRunning = false;
-// break;
-// }
+ if(!test.getIsComplete()) {
+ isRunning = false;
+ break;
+ }
}
}
Modified: trunk/framework-test/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AllTests.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework-test/as3/asunit/framework/AllTests.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -1,7 +1,6 @@
package asunit.framework {
import asunit.framework.TestSuite;
import asunit.framework.AssertTest;
- import asunit.framework.AsyncMethod2Test;
import asunit.framework.AsyncMethodTest;
import asunit.framework.TestCaseTest;
import asunit.framework.TestFailureTest;
@@ -11,7 +10,6 @@
public function AllTests() {
addTest(new asunit.framework.AssertTest());
- addTest(new asunit.framework.AsyncMethod2Test());
addTest(new asunit.framework.AsyncMethodTest());
addTest(new asunit.framework.TestCaseTest());
addTest(new asunit.framework.TestFailureTest());
Deleted: trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -1,50 +0,0 @@
-package asunit.framework {
- import asunit.framework.TestCase;
- import flash.display.Sprite;
- import flash.utils.setTimeout;
-
- public class AsyncMethod2Test extends TestCase {
- private var instance:Sprite;
-
- public function AsyncMethod2Test(testMethod:String = null) {
- super(testMethod);
- }
-
- protected override function setUp():void {
- instance = new Sprite();
- addChild(instance);
- }
-
- protected override function tearDown():void {
- removeChild(instance);
- instance = null;
- }
-
- public function testInstantiated():void {
- assertTrue("Sprite instantiated", instance is Sprite);
- }
-
- public function testAsyncMethod():void {
- var handler:Function = addAsync(asyncHandler);
- setTimeout(handler, 100);
- }
-
- private function asyncHandler():void {
- assertTrue(instance is Sprite);
- }
-
- public function testAsyncVisualEntity():void {
- var handler:Function = addAsync(spriteHandler);
- setTimeout(handler, 100);
- }
-
- private function spriteHandler():void {
- assertTrue(instance is Sprite);
- }
-
- public function testAsyncVisualEntity2():void {
- var handler:Function = addAsync(spriteHandler);
- setTimeout(handler, 100);
- }
- }
-}
Modified: trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -1,6 +1,6 @@
package asunit.framework {
- import asunit.framework.TestCase;
import flash.display.Sprite;
+ import flash.events.Event;
import flash.utils.setTimeout;
public class AsyncMethodTest extends TestCase {
Modified: trunk/framework-test/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-10-11 06:51:42 UTC (rev 125)
+++ trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-10-12 06:13:25 UTC (rev 126)
@@ -17,36 +17,64 @@
public function testCustomConstructor():void {
var mock:TestCaseMock = new TestCaseMock("testMethod1");
+ var handler:Function = addAsync(getCustomConstructorCompleteHandler(mock));
+ mock.addEventListener(Event.COMPLETE, handler);
mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertFalse("testMethod3Run", mock.testMethod3Run);
}
+ private function getCustomConstructorCompleteHandler(mock:TestCaseMock):Function {
+ return function():* {
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertFalse("testMethod3Run", mock.testMethod3Run);
+ }
+ }
+
public function testCustomConstructor2():void {
var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod3");
+ var handler:Function = addAsync(getCustomConstructor2CompleteHandler(mock));
+ mock.addEventListener(Event.COMPLETE, handler);
mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
}
+
+ private function getCustomConstructor2CompleteHandler(mock:TestCaseMock):Function {
+ return function():* {
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+ }
public function testCustomConstructor3():void {
var mock:TestCaseMock = new TestCaseMock("testMethod1,testMethod3");
+ var handler:Function = addAsync(getCustomConstructor3CompleteHandler(mock));
+ mock.addEventListener(Event.COMPLETE, handler);
mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertFalse("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
}
+
+ private function getCustomConstructor3CompleteHandler(mock:TestCaseMock):Function {
+ return function():* {
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertFalse("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+ }
public function testCustomConstructor4():void {
var mock:TestCaseMock = new TestCaseMock("testMethod1, testMethod2,testMethod3");
+ var handler:Function = addAsync(getCustomConstructor4CompleteHandler(mock));
+ mock.addEventListener(Event.COMPLETE, handler);
mock.run();
- assertTrue("testMethod1Run", mock.testMethod1Run);
- assertTrue("testMethod2Run", mock.testMethod2Run);
- assertTrue("testMethod3Run", mock.testMethod3Run);
}
+ private function getCustomConstructor4CompleteHandler(mock:TestCaseMock):Function {
+ return function():* {
+ assertTrue("testMethod1Run", mock.testMethod1Run);
+ assertTrue("testMethod2Run", mock.testMethod2Run);
+ assertTrue("testMethod3Run", mock.testMethod3Run);
+ }
+ }
+
public function testAsync():void {
var dispatcher:EventDispatcher = new EventDispatcher();
var handler:Function = addAsync(asyncHandler, 400);
@@ -56,8 +84,6 @@
private function asyncHandler(event:Event):void {
assertEquals(event.type, Event.COMPLETE);
-// assertTrue(false);
-// throw new IllegalOperationError("broken");
}
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-11 06:51:50
|
Revision: 125
http://svn.sourceforge.net/asunit/?rev=125&view=rev
Author: lukebayes
Date: 2006-10-10 23:51:42 -0700 (Tue, 10 Oct 2006)
Log Message:
-----------
Changed setTimeout to Timer object because setTimeout does not work as promised at all
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestSuite.as
trunk/framework/as3/asunit/textui/TestRunner.as
trunk/framework-test/as3/asunit/framework/AllTests.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-11 05:31:17 UTC (rev 124)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-11 06:51:42 UTC (rev 125)
@@ -8,9 +8,9 @@
import asunit.util.Iterator;
import asunit.util.ArrayIterator;
import flash.net.getClassByAlias;
- import flash.utils.setTimeout;
- import flash.utils.clearTimeout;
import flash.events.Event;
+ import flash.utils.Timer;
+ import flash.events.TimerEvent;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -86,11 +86,12 @@
protected var testMethods:Array;
protected var isComplete:Boolean;
protected var context:DisplayObjectContainer;
- private var asyncMethodTimeoutId:Number;
+ protected var methodIsAsynchronous:Boolean;
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
- protected var methodIsAsynchronous:Boolean;
+ private var timeout:Timer;
+ private var lastDuration:Number;
/**
* Constructs a test case with the given name.
@@ -211,10 +212,6 @@
private function runMethod(methodName:String):Boolean {
try {
-// if(!isNaN(asyncMethodTimeoutId)) {
-// clearTimeout(asyncMethodTimeoutId);
-// asyncMethodTimeoutId = NaN;
-// }
setUp();
currentMethod = methodName;
this[methodName]();
@@ -279,13 +276,18 @@
protected function addAsync(handler:Function = null, duration:Number=DEFAULT_TIMEOUT):Function {
if(handler == null) {
- handler = function() {};
+ handler = function(args:*):* {};
}
var context:TestCase = this;
context.methodIsAsynchronous = true;
- asyncMethodTimeoutId = setTimeout(asyncTimeoutHandler, duration, duration);
+ lastDuration = duration;
+
+ timeout = new Timer(duration, 1);
+ timeout.addEventListener(TimerEvent.TIMER_COMPLETE, timeoutCompleteHandler);
+ timeout.start();
return function(args:*):* {
- clearTimeout(context.asyncMethodTimeoutId);
+ context.timeout.stop();
+ context.timeout = null;
try {
handler.apply(context, arguments);
}
@@ -300,14 +302,13 @@
finally {
context.methodIsAsynchronous = false;
context.runTearDown();
- trace("CONTEXT: " + context);
context.runBare();
}
}
}
- private function asyncTimeoutHandler(duration:Number):void {
- result.addError(this, new IllegalOperationError("TestCase.timeout (" + duration + "ms) exceeded on an asynchronous test method."));
+ private function timeoutCompleteHandler(event:TimerEvent):void {
+ result.addError(this, new IllegalOperationError("TestCase.timeout (" + lastDuration + "ms) exceeded on an asynchronous test method."));
methodIsAsynchronous = false;
runTearDown();
runBare();
Modified: trunk/framework/as3/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-11 05:31:17 UTC (rev 124)
+++ trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-11 06:51:42 UTC (rev 125)
@@ -62,13 +62,13 @@
test.setResult(result);
test.addEventListener(Event.COMPLETE, testCompleteHandler);
test.run();
- if(!test.getIsComplete()) {
- isRunning = false;
- break;
- }
+// if(!test.getIsComplete()) {
+// isRunning = false;
+// break;
+// }
}
}
-
+
private function getIterator():ArrayIterator {
if(iterator == null) {
iterator = new ArrayIterator(fTests);
Modified: trunk/framework/as3/asunit/textui/TestRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunner.as 2006-10-11 05:31:17 UTC (rev 124)
+++ trunk/framework/as3/asunit/textui/TestRunner.as 2006-10-11 06:51:42 UTC (rev 125)
@@ -12,6 +12,8 @@
import flash.utils.describeType;
import flash.utils.getTimer;
import flash.utils.setInterval;
+ import flash.utils.Timer;
+ import flash.events.TimerEvent;
/**
* A command line based tool to run tests.
@@ -99,7 +101,7 @@
test.run();
return result;
}
-
+
private function testCompleteHandler(event:Event):void {
var endTime:Number = getTimer();
var runTime:Number = endTime - startTime;
Modified: trunk/framework-test/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AllTests.as 2006-10-11 05:31:17 UTC (rev 124)
+++ trunk/framework-test/as3/asunit/framework/AllTests.as 2006-10-11 06:51:42 UTC (rev 125)
@@ -1,6 +1,7 @@
package asunit.framework {
import asunit.framework.TestSuite;
import asunit.framework.AssertTest;
+ import asunit.framework.AsyncMethod2Test;
import asunit.framework.AsyncMethodTest;
import asunit.framework.TestCaseTest;
import asunit.framework.TestFailureTest;
@@ -10,8 +11,8 @@
public function AllTests() {
addTest(new asunit.framework.AssertTest());
+ addTest(new asunit.framework.AsyncMethod2Test());
addTest(new asunit.framework.AsyncMethodTest());
- addTest(new asunit.framework.AsyncMethod2Test());
addTest(new asunit.framework.TestCaseTest());
addTest(new asunit.framework.TestFailureTest());
addTest(new asunit.framework.VisualTestCaseTest());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-11 05:31:19
|
Revision: 124
http://svn.sourceforge.net/asunit/?rev=124&view=rev
Author: lukebayes
Date: 2006-10-10 22:31:17 -0700 (Tue, 10 Oct 2006)
Log Message:
-----------
Fixed Indenting on FlexTestRunner
Modified Paths:
--------------
trunk/framework/as3/asunit/textui/FlexTestRunner.as
Modified: trunk/framework/as3/asunit/textui/FlexTestRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/FlexTestRunner.as 2006-10-11 05:21:28 UTC (rev 123)
+++ trunk/framework/as3/asunit/textui/FlexTestRunner.as 2006-10-11 05:31:17 UTC (rev 124)
@@ -6,50 +6,50 @@
public class FlexTestRunner extends TestRunner {
- public function FlexTestRunner() {
- setPrinter(new ResultPrinter());
- }
-
- protected override function addedHandler(event:Event):void {
- if(event.target === this) {
- parent.addEventListener(Event.RESIZE, resizeHandler);
- resizeHandler(new Event(Event.RESIZE));
- }
- else {
- event.stopPropagation();
+ public function FlexTestRunner() {
+ setPrinter(new ResultPrinter());
}
- }
-
- public override function set width(w:Number):void {
- fPrinter.width = w;
- }
-
- public override function set height(h:Number):void {
- fPrinter.height = h;
- }
-
- public function resizeHandler(event:Event):void {
- width = parent.width;
- height = parent.height;
- }
-
- public override function addChild(child:DisplayObject):DisplayObject {
- if(parent && child is IUIComponent) {
- // AND check for 'is' UIUComponent...
- return parent.addChild(child);
- }
- else {
- return super.addChild(child);
- }
- }
-
- public override function removeChild(child:DisplayObject):DisplayObject {
- if(child is IUIComponent) {
- return parent.removeChild(child);
- }
- else {
- return super.removeChild(child);
- }
- }
+
+ protected override function addedHandler(event:Event):void {
+ if(event.target === this) {
+ parent.addEventListener(Event.RESIZE, resizeHandler);
+ resizeHandler(new Event(Event.RESIZE));
+ }
+ else {
+ event.stopPropagation();
+ }
+ }
+
+ public override function set width(w:Number):void {
+ fPrinter.width = w;
+ }
+
+ public override function set height(h:Number):void {
+ fPrinter.height = h;
+ }
+
+ public function resizeHandler(event:Event):void {
+ width = parent.width;
+ height = parent.height;
+ }
+
+ public override function addChild(child:DisplayObject):DisplayObject {
+ if(parent && child is IUIComponent) {
+ // AND check for 'is' UIUComponent...
+ return parent.addChild(child);
+ }
+ else {
+ return super.addChild(child);
+ }
+ }
+
+ public override function removeChild(child:DisplayObject):DisplayObject {
+ if(child is IUIComponent) {
+ return parent.removeChild(child);
+ }
+ else {
+ return super.removeChild(child);
+ }
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-11 05:21:32
|
Revision: 123
http://svn.sourceforge.net/asunit/?rev=123&view=rev
Author: lukebayes
Date: 2006-10-10 22:21:28 -0700 (Tue, 10 Oct 2006)
Log Message:
-----------
Added AsyncMethod TestCases to fixture
Modified Paths:
--------------
trunk/framework-test/as3/asunit/framework/TestCaseMock.as
Added Paths:
-----------
trunk/framework-test/as3/asunit/framework/AllTests.as
trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as
trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as
Added: trunk/framework-test/as3/asunit/framework/AllTests.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AllTests.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/AllTests.as 2006-10-11 05:21:28 UTC (rev 123)
@@ -0,0 +1,20 @@
+package asunit.framework {
+ import asunit.framework.TestSuite;
+ import asunit.framework.AssertTest;
+ import asunit.framework.AsyncMethodTest;
+ import asunit.framework.TestCaseTest;
+ import asunit.framework.TestFailureTest;
+ import asunit.framework.VisualTestCaseTest;
+
+ public class AllTests extends TestSuite {
+
+ public function AllTests() {
+ addTest(new asunit.framework.AssertTest());
+ addTest(new asunit.framework.AsyncMethodTest());
+ addTest(new asunit.framework.AsyncMethod2Test());
+ addTest(new asunit.framework.TestCaseTest());
+ addTest(new asunit.framework.TestFailureTest());
+ addTest(new asunit.framework.VisualTestCaseTest());
+ }
+ }
+}
Added: trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/AsyncMethod2Test.as 2006-10-11 05:21:28 UTC (rev 123)
@@ -0,0 +1,50 @@
+package asunit.framework {
+ import asunit.framework.TestCase;
+ import flash.display.Sprite;
+ import flash.utils.setTimeout;
+
+ public class AsyncMethod2Test extends TestCase {
+ private var instance:Sprite;
+
+ public function AsyncMethod2Test(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ instance = new Sprite();
+ addChild(instance);
+ }
+
+ protected override function tearDown():void {
+ removeChild(instance);
+ instance = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue("Sprite instantiated", instance is Sprite);
+ }
+
+ public function testAsyncMethod():void {
+ var handler:Function = addAsync(asyncHandler);
+ setTimeout(handler, 100);
+ }
+
+ private function asyncHandler():void {
+ assertTrue(instance is Sprite);
+ }
+
+ public function testAsyncVisualEntity():void {
+ var handler:Function = addAsync(spriteHandler);
+ setTimeout(handler, 100);
+ }
+
+ private function spriteHandler():void {
+ assertTrue(instance is Sprite);
+ }
+
+ public function testAsyncVisualEntity2():void {
+ var handler:Function = addAsync(spriteHandler);
+ setTimeout(handler, 100);
+ }
+ }
+}
Added: trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as (rev 0)
+++ trunk/framework-test/as3/asunit/framework/AsyncMethodTest.as 2006-10-11 05:21:28 UTC (rev 123)
@@ -0,0 +1,50 @@
+package asunit.framework {
+ import asunit.framework.TestCase;
+ import flash.display.Sprite;
+ import flash.utils.setTimeout;
+
+ public class AsyncMethodTest extends TestCase {
+ private var instance:Sprite;
+
+ public function AsyncMethodTest(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ protected override function setUp():void {
+ instance = new Sprite();
+ addChild(instance);
+ }
+
+ protected override function tearDown():void {
+ removeChild(instance);
+ instance = null;
+ }
+
+ public function testInstantiated():void {
+ assertTrue("Sprite instantiated", instance is Sprite);
+ }
+
+ public function testAsyncMethod():void {
+ var handler:Function = addAsync(asyncHandler);
+ setTimeout(handler, 100);
+ }
+
+ private function asyncHandler():void {
+ assertTrue(instance is Sprite);
+ }
+
+ public function testAsyncVisualEntity():void {
+ var handler:Function = addAsync(spriteHandler);
+ setTimeout(handler, 100);
+ }
+
+ private function spriteHandler():void {
+ assertTrue(instance is Sprite);
+ }
+
+ public function testAsyncVisualEntity2():void {
+ var handler:Function = addAsync(spriteHandler);
+ setTimeout(handler, 100);
+ }
+ }
+}
Modified: trunk/framework-test/as3/asunit/framework/TestCaseMock.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseMock.as 2006-10-11 05:09:04 UTC (rev 122)
+++ trunk/framework-test/as3/asunit/framework/TestCaseMock.as 2006-10-11 05:21:28 UTC (rev 123)
@@ -1,4 +1,7 @@
package asunit.framework {
+ import flash.utils.setTimeout;
+ import flash.display.Sprite;
+
public class TestCaseMock extends TestCase {
public var testMethod1Run:Boolean;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-11 05:09:10
|
Revision: 122
http://svn.sourceforge.net/asunit/?rev=122&view=rev
Author: lukebayes
Date: 2006-10-10 22:09:04 -0700 (Tue, 10 Oct 2006)
Log Message:
-----------
Made TestSuites pause execution for asynchronus TestCases
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestSuite.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-05 20:17:40 UTC (rev 121)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-11 05:09:04 UTC (rev 122)
@@ -300,6 +300,7 @@
finally {
context.methodIsAsynchronous = false;
context.runTearDown();
+ trace("CONTEXT: " + context);
context.runBare();
}
}
Modified: trunk/framework/as3/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-05 20:17:40 UTC (rev 121)
+++ trunk/framework/as3/asunit/framework/TestSuite.as 2006-10-11 05:09:04 UTC (rev 122)
@@ -19,6 +19,8 @@
public class TestSuite extends TestCase implements Test {
private var fTests:Array = new Array();
private var testsCompleteCount:Number = 0;
+ private var iterator:ArrayIterator;
+ private var isRunning:Boolean;
public function TestSuite() {
super();
@@ -53,16 +55,31 @@
public override function run():void {
var result:TestResult = getResult();
var test:Test;
- var itr:Iterator = new ArrayIterator(fTests);
+ var itr:Iterator = getIterator();
while(itr.hasNext()) {
+ isRunning = true;
test = Test(itr.next());
test.setResult(result);
test.addEventListener(Event.COMPLETE, testCompleteHandler);
test.run();
+ if(!test.getIsComplete()) {
+ isRunning = false;
+ break;
+ }
}
}
+ private function getIterator():ArrayIterator {
+ if(iterator == null) {
+ iterator = new ArrayIterator(fTests);
+ }
+ return iterator;
+ }
+
private function testCompleteHandler(event:Event):void {
+ if(!isRunning) {
+ run();
+ }
if(++testsCompleteCount >= testCount()) {
dispatchEvent(new Event(Event.COMPLETE));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-05 20:23:30
|
Revision: 121
http://svn.sourceforge.net/asunit/?rev=121&view=rev
Author: lukebayes
Date: 2006-10-05 13:17:40 -0700 (Thu, 05 Oct 2006)
Log Message:
-----------
updated example
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCaseExample.as
Modified: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-10-05 19:07:54 UTC (rev 120)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-10-05 20:17:40 UTC (rev 121)
@@ -20,17 +20,17 @@
}
// This method will be called before every test method
- protected override function setUp():void {
+ override protected function setUp():void {
date = new Date();
// sprite = new Sprite();
// addChild(sprite);
}
-
+
// This method will be called after every test method
// but only if we're executing the entire TestCase,
- // the tearDown method won't be called if we're
+ // the tearDown method won't be called if we're
// calling start(MyTestCase, "someMethod");
- protected override function tearDown():void {
+ override protected function tearDown():void {
// removeChild(sprite);
// sprite = null;
date = null;
@@ -48,29 +48,26 @@
date.month = 1;
assertEquals(1, date.month);
}
-
- // This is an asynchronous test method
- public function testAsyncFeature():void {
- // create a new object that dispatches events...
- var dispatcher:IEventDispatcher = new EventDispatcher();
- // get a TestCase async event handler reference
- var handler:Function = addAsync(changeHandler);
- // subscribe to your event dispatcher using the returned handler
- dispatcher.addEventListener(Event.CHANGE, handler);
- // cause the event to be dispatched.
-// dispatcher.dispatchEvent(new Event(Event.CHANGE));
- setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
- }
-
- protected function changeHandler(event:Event):void {
- assertEquals(Event.CHANGE, event.type);
- }
-
- public function testAsyncFeatureTimeout():void {
- var dispatcher:IEventDispatcher = new EventDispatcher();
- var handler:Function = addAsync(changeHandler, 100);
- dispatcher.addEventListener(Event.CHANGE, handler);
- dispatcher.dispatchEvent(new Event(Event.CHANGE));
- }
- }
+
+ // This is an asynchronous test method
+ public function testAsyncFeature():void {
+ // create a new object that dispatches events...
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ // get a TestCase async event handler reference
+ // the 2nd arg is an optional timeout in ms. (default=1000ms )
+ var handler:Function = addAsync(changeHandler, 2000);
+ // subscribe to your event dispatcher using the returned handler
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ // cause the event to be dispatched.
+ // either immediately:
+ //dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ // or in the future < your assigned timeout
+ setTimeout( dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
+ }
+
+ protected function changeHandler(event:Event):void {
+ // perform assertions in your handler
+ assertEquals(Event.CHANGE, event.type);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-05 19:07:59
|
Revision: 120
http://svn.sourceforge.net/asunit/?rev=120&view=rev
Author: lukebayes
Date: 2006-10-05 12:07:54 -0700 (Thu, 05 Oct 2006)
Log Message:
-----------
hooked up DEFAULT_TIMEOUT constant to async method timeout duration
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-10-05 19:03:10 UTC (rev 119)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-05 19:07:54 UTC (rev 120)
@@ -80,7 +80,7 @@
/**
* the name of the test case
*/
- protected static var DEFAULT_TIMEOUT:int = 500;
+ protected static const DEFAULT_TIMEOUT:int = 1000;
protected var fName:String;
protected var result:TestResult;
protected var testMethods:Array;
@@ -277,7 +277,7 @@
return context;
}
- protected function addAsync(handler:Function = null, duration:Number=1000):Function {
+ protected function addAsync(handler:Function = null, duration:Number=DEFAULT_TIMEOUT):Function {
if(handler == null) {
handler = function() {};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-10-05 19:03:23
|
Revision: 119
http://svn.sourceforge.net/asunit/?rev=119&view=rev
Author: lukebayes
Date: 2006-10-05 12:03:10 -0700 (Thu, 05 Oct 2006)
Log Message:
-----------
Got async test case working much better within the context of a Flex Framework application
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCase.as
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-21 18:19:08 UTC (rev 118)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-10-05 19:03:10 UTC (rev 119)
@@ -104,10 +104,10 @@
} else {
setTestMethods(methods);
}
- if(testMethods.length == 1) {
+ if(testMethod != null) {
runSingle = true;
}
- setName(className.toString());
+ setName(className.toString());
}
/**
@@ -174,20 +174,24 @@
public function runBare():void {
var name:String;
var itr:Iterator = getMethodIterator();
+ var runCleanUp:Boolean = true;
try {
while(itr.hasNext()) {
name = String(itr.next());
if(!runMethod(name)) {
+ runCleanUp = false;
break;
}
}
}
finally {
- if(!itr.hasNext() && !methodIsAsynchronous) {
- cleanUp();
- getResult().endTest(this);
- isComplete = true;
- dispatchEvent(new Event(Event.COMPLETE));
+ if(runCleanUp) {
+ if(!itr.hasNext()) {
+ cleanUp();
+ getResult().endTest(this);
+ isComplete = true;
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
}
}
}
@@ -207,23 +211,13 @@
private function runMethod(methodName:String):Boolean {
try {
- if(!isNaN(asyncMethodTimeoutId)) {
- clearTimeout(asyncMethodTimeoutId);
- asyncMethodTimeoutId = NaN;
- }
+// if(!isNaN(asyncMethodTimeoutId)) {
+// clearTimeout(asyncMethodTimeoutId);
+// asyncMethodTimeoutId = NaN;
+// }
setUp();
currentMethod = methodName;
- try {
- this[methodName]();
- if(methodIsAsynchronous) {
- return false;
- }
- }
- finally {
- if(!runSingle) {
- tearDown();
- }
- }
+ this[methodName]();
}
catch(e:AssertionFailedError) {
getResult().addFailure(this, e);
@@ -231,7 +225,12 @@
catch(ioe:Error) {
getResult().addError(this, ioe);
}
- return true;
+ finally {
+ if(!methodIsAsynchronous) {
+ runTearDown();
+ }
+ return !methodIsAsynchronous;
+ }
}
/**
@@ -278,10 +277,13 @@
return context;
}
- protected function addAsync(handler:Function, timeout:int=500):Function {
- this.methodIsAsynchronous = true;
+ protected function addAsync(handler:Function = null, duration:Number=1000):Function {
+ if(handler == null) {
+ handler = function() {};
+ }
var context:TestCase = this;
- this.asyncMethodTimeoutId = setTimeout(this.timeoutHandler, timeout, timeout);
+ context.methodIsAsynchronous = true;
+ asyncMethodTimeoutId = setTimeout(asyncTimeoutHandler, duration, duration);
return function(args:*):* {
clearTimeout(context.asyncMethodTimeoutId);
try {
@@ -297,17 +299,25 @@
}
finally {
context.methodIsAsynchronous = false;
+ context.runTearDown();
context.runBare();
}
}
}
- protected function timeoutHandler(timeout:Number):void {
- result.addError(this, new IllegalOperationError("TestCase.timeout (" + timeout + "ms) exceeded on an asynchronous test method."));
+ private function asyncTimeoutHandler(duration:Number):void {
+ result.addError(this, new IllegalOperationError("TestCase.timeout (" + duration + "ms) exceeded on an asynchronous test method."));
methodIsAsynchronous = false;
+ runTearDown();
runBare();
}
+ protected function runTearDown():void {
+ if(!runSingle) {
+ tearDown();
+ }
+ }
+
protected function addChild(child:DisplayObject):DisplayObject {
return getContext().addChild(child);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-21 18:19:16
|
Revision: 118
http://svn.sourceforge.net/asunit/?rev=118&view=rev
Author: lukebayes
Date: 2006-09-21 11:19:08 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
added asynchronous execution of test suites to avoid script timeouts on large projects
Modified Paths:
--------------
trunk/framework/as25/asunit/framework/TestSuite.as
trunk/framework/as25/asunit/runner/BaseTestRunner.as
Added Paths:
-----------
trunk/framework/as25/asunit/util/
trunk/framework/as25/asunit/util/ArrayIterator.as
trunk/framework/as25/asunit/util/ArrayIteratorTest.as
trunk/framework/as25/asunit/util/Iterator.as
Modified: trunk/framework/as25/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as25/asunit/framework/TestSuite.as 2006-09-21 01:35:18 UTC (rev 117)
+++ trunk/framework/as25/asunit/framework/TestSuite.as 2006-09-21 18:19:08 UTC (rev 118)
@@ -1,6 +1,8 @@
import asunit.framework.TestCase;
import asunit.framework.Test;
import asunit.framework.TestResult;
+import asunit.util.Iterator;
+import asunit.util.ArrayIterator;
class asunit.framework.TestSuite extends TestCase {
private var fTests:Array = new Array();
@@ -49,14 +51,25 @@
*/
public function run():Void {
var result:TestResult = getResult();
+ runTests(fTests, result);
+ }
+
+ public function runTests(tests:Array, result:TestResult):Void {
+ var itr:Iterator = new ArrayIterator(tests);
var test:TestCase;
- var len:Number = fTests.length;
- for(var i:Number = 0; i < len; i++) {
- test = TestCase(fTests[i]);
- test.setResult(result);
- test.run();
+ if(itr.hasNext()) {
+ test = TestCase(itr.next());
+ runTest(itr, test, result);
}
}
+
+ public function runTest(itr:Iterator, test:TestCase, result:TestResult):Void {
+ test.setResult(result);
+ test.run();
+ if(itr.hasNext()) {
+ _global.setTimeout(this, "runTest", 10, itr, itr.next(), result);
+ }
+ }
/**
* Returns the number of tests in this suite
Modified: trunk/framework/as25/asunit/runner/BaseTestRunner.as
===================================================================
--- trunk/framework/as25/asunit/runner/BaseTestRunner.as 2006-09-21 01:35:18 UTC (rev 117)
+++ trunk/framework/as25/asunit/runner/BaseTestRunner.as 2006-09-21 18:19:08 UTC (rev 118)
@@ -2,6 +2,7 @@
import asunit.framework.Test;
import asunit.framework.TestResult;
import asunit.framework.Assert;
+import asunit.textui.ResultPrinter;
class asunit.runner.BaseTestRunner {
private static var instance:BaseTestRunner;
@@ -59,9 +60,16 @@
}
public static function trace(msg:String):Void {
- instance.getPrinter().trace(msg);
+ getInstance().getPrinter().trace(msg);
}
+ public static function getInstance():BaseTestRunner {
+ if(instance == undefined) {
+ return instance = new BaseTestRunner(ResultPrinter);
+ }
+ return instance;
+ }
+
public function setPrinter(printer:IResultPrinter):Void {
this.printer = printer;
}
Added: trunk/framework/as25/asunit/util/ArrayIterator.as
===================================================================
--- trunk/framework/as25/asunit/util/ArrayIterator.as (rev 0)
+++ trunk/framework/as25/asunit/util/ArrayIterator.as 2006-09-21 18:19:08 UTC (rev 118)
@@ -0,0 +1,24 @@
+
+import asunit.util.Iterator;
+import asunit.errors.IllegalOperationError;
+
+class asunit.util.ArrayIterator implements Iterator {
+
+ private var list:Array;
+ private var index:Number = 0;
+
+ public function ArrayIterator(list:Array) {
+ if(list == null) {
+ throw new IllegalOperationError("ArrayIterator needs an array in it's constructor");
+ }
+ this.list = list;
+ }
+
+ public function hasNext():Boolean {
+ return (list[index] != null);
+ }
+
+ public function next():Object {
+ return list[index++];
+ }
+}
\ No newline at end of file
Added: trunk/framework/as25/asunit/util/ArrayIteratorTest.as
===================================================================
--- trunk/framework/as25/asunit/util/ArrayIteratorTest.as (rev 0)
+++ trunk/framework/as25/asunit/util/ArrayIteratorTest.as 2006-09-21 18:19:08 UTC (rev 118)
@@ -0,0 +1,52 @@
+
+import asunit.util.ArrayIterator;
+import asunit.framework.TestCase;
+
+class asunit.util.ArrayIteratorTest extends TestCase {
+ private var className:String = "asunit.util.ArrayIteratorTest";
+ private var instance:ArrayIterator;
+
+ public function ArrayIteratorTest(testMethod:String) {
+ super(testMethod);
+ }
+
+ public function setUp():Void {
+ var arr:Array = new Array("one", "two", "three", "four", "five");
+ instance = new ArrayIterator(arr);
+ }
+
+ public function tearDown():Void {
+ delete instance;
+ }
+
+ public function testInstantiated():Void {
+ assertTrue("ArrayIterator instantiated", instance instanceof ArrayIterator);
+ }
+
+ public function testIterate():Void {
+ assertTrue("1", instance.hasNext());
+ assertEquals("2", "one", instance.next());
+ assertTrue("3", instance.hasNext());
+ assertEquals("4", "two", instance.next());
+ assertTrue("5", instance.hasNext());
+ assertEquals("6", "three", instance.next());
+ assertTrue("7", instance.hasNext());
+ assertEquals("8", "four", instance.next());
+ assertTrue("9", instance.hasNext());
+ assertEquals("10", "five", instance.next());
+ assertFalse("11", instance.hasNext());
+ }
+
+ public function testEmpty():Void {
+ var itr:ArrayIterator = new ArrayIterator(new Array());
+ assertFalse("1", itr.hasNext());
+ }
+
+ public function testSingleItem():Void {
+ var itr:ArrayIterator = new ArrayIterator(new Array("one"));
+ assertTrue(itr.hasNext());
+ assertEquals("2", "one", itr.next());
+ assertFalse("3", itr.hasNext());
+
+ }
+}
Added: trunk/framework/as25/asunit/util/Iterator.as
===================================================================
--- trunk/framework/as25/asunit/util/Iterator.as (rev 0)
+++ trunk/framework/as25/asunit/util/Iterator.as 2006-09-21 18:19:08 UTC (rev 118)
@@ -0,0 +1,5 @@
+
+interface asunit.util.Iterator {
+ public function hasNext():Boolean;
+ public function next():Object;
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-21 01:35:28
|
Revision: 117
http://svn.sourceforge.net/asunit/?rev=117&view=rev
Author: lukebayes
Date: 2006-09-20 18:35:18 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
Cleaned up traces and whatnot from async feature
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework-test/as3/asunit/framework/TestCaseTest.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-21 01:33:07 UTC (rev 116)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-21 01:35:18 UTC (rev 117)
@@ -1,12 +1,10 @@
package {
import asunit.textui.TestRunner;
- import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestCaseTest, "testAsync");
}
}
}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-21 01:33:07 UTC (rev 116)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-21 01:35:18 UTC (rev 117)
@@ -296,7 +296,6 @@
context.getResult().addError(context, ioe);
}
finally {
- trace("ASYNC METHOD FINALLY BLOCK CALLED!");
context.methodIsAsynchronous = false;
context.runBare();
}
Modified: trunk/framework-test/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-09-21 01:33:07 UTC (rev 116)
+++ trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-09-21 01:35:18 UTC (rev 117)
@@ -48,10 +48,8 @@
}
public function testAsync():void {
- trace("TEST ASYNC");
var dispatcher:EventDispatcher = new EventDispatcher();
var handler:Function = addAsync(asyncHandler, 400);
- trace("METHOD IS ASYNC? : " + methodIsAsynchronous);
dispatcher.addEventListener(Event.COMPLETE, handler);
setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.COMPLETE));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-21 01:33:12
|
Revision: 116
http://svn.sourceforge.net/asunit/?rev=116&view=rev
Author: lukebayes
Date: 2006-09-20 18:33:07 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
Async test cases and suites seem to be working properly
Modified Paths:
--------------
trunk/framework-test/as3/asunit/framework/TestCaseTest.as
trunk/framework-test/as3/asunit/textui/TestRunnerTest.as
Modified: trunk/framework-test/as3/asunit/framework/TestCaseTest.as
===================================================================
--- trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-09-21 01:32:40 UTC (rev 115)
+++ trunk/framework-test/as3/asunit/framework/TestCaseTest.as 2006-09-21 01:33:07 UTC (rev 116)
@@ -1,5 +1,10 @@
package asunit.framework {
+ import flash.events.EventDispatcher;
+ import flash.events.Event;
+ import flash.utils.setTimeout;
+ import flash.errors.IllegalOperationError;
+
public class TestCaseTest extends TestCase {
public function TestCaseTest(testMethod:String = null) {
@@ -41,5 +46,20 @@
assertTrue("testMethod2Run", mock.testMethod2Run);
assertTrue("testMethod3Run", mock.testMethod3Run);
}
+
+ public function testAsync():void {
+ trace("TEST ASYNC");
+ var dispatcher:EventDispatcher = new EventDispatcher();
+ var handler:Function = addAsync(asyncHandler, 400);
+ trace("METHOD IS ASYNC? : " + methodIsAsynchronous);
+ dispatcher.addEventListener(Event.COMPLETE, handler);
+ setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.COMPLETE));
+ }
+
+ private function asyncHandler(event:Event):void {
+ assertEquals(event.type, Event.COMPLETE);
+// assertTrue(false);
+// throw new IllegalOperationError("broken");
+ }
}
}
\ No newline at end of file
Modified: trunk/framework-test/as3/asunit/textui/TestRunnerTest.as
===================================================================
--- trunk/framework-test/as3/asunit/textui/TestRunnerTest.as 2006-09-21 01:32:40 UTC (rev 115)
+++ trunk/framework-test/as3/asunit/textui/TestRunnerTest.as 2006-09-21 01:33:07 UTC (rev 116)
@@ -24,32 +24,5 @@
public function testInstantiated():void {
assertTrue("TestRunner instantiated with: " + instance, instance is TestRunner);
}
-
- public function testAsync():void {
- var handler:Function = addAsync(asyncCompleteHandler);
- setTimeout(handler, 400, new Event(Event.ACTIVATE));
- }
-
- public function asyncCompleteHandler(event:Event):void {
-// throw new IllegalOperationError("what the heck?");
- }
-
- public function testAsync2():void {
- var handler:Function = addAsync(async2CompleteHandler);
- setTimeout(handler, 40);
- }
-
- public function async2CompleteHandler():void {
-// fail("test async complete failed");
- }
-
- public function testSomethingComplete():void {
- }
-
- public function testSomethingElse():void {
- }
-
- public function testAnotherThing():void {
- }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-21 01:32:49
|
Revision: 115
http://svn.sourceforge.net/asunit/?rev=115&view=rev
Author: lukebayes
Date: 2006-09-20 18:32:40 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
Async test cases and suites seem to be working properly
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/Assert.as
trunk/framework/as3/asunit/framework/Test.as
trunk/framework/as3/asunit/framework/TestCase.as
trunk/framework/as3/asunit/framework/TestSuite.as
trunk/framework/as3/asunit/textui/TestRunner.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,10 +1,12 @@
package {
import asunit.textui.TestRunner;
+ import asunit.framework.TestCaseTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
start(AllTests, null, TestRunner.SHOW_TRACE);
+// start(TestCaseTest, "testAsync");
}
}
}
Modified: trunk/framework/as3/asunit/framework/Assert.as
===================================================================
--- trunk/framework/as3/asunit/framework/Assert.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/Assert.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,14 +1,15 @@
package asunit.framework {
-
+ import asunit.errors.AssertionFailedError;
+
import flash.errors.IllegalOperationError;
- import asunit.errors.AssertionFailedError;
+ import flash.events.EventDispatcher;
import flash.utils.Proxy;
/**
* A set of assert methods. Messages are only displayed when an assert fails.
*/
- public class Assert {
+ public class Assert extends EventDispatcher {
/**
* Protect constructor since it is a static only class
*/
Modified: trunk/framework/as3/asunit/framework/Test.as
===================================================================
--- trunk/framework/as3/asunit/framework/Test.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/Test.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,7 +1,8 @@
package asunit.framework {
import flash.display.DisplayObjectContainer;
+ import flash.events.IEventDispatcher;
- public interface Test {
+ public interface Test extends IEventDispatcher {
function countTestCases():int;
function toString():String;
function setResult(result:TestResult):void;
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -10,6 +10,7 @@
import flash.net.getClassByAlias;
import flash.utils.setTimeout;
import flash.utils.clearTimeout;
+ import flash.events.Event;
/**
* A test case defines the fixture to run multiple tests. To define a test case<br>
@@ -89,7 +90,7 @@
private var currentMethod:String;
private var runSingle:Boolean;
private var methodIterator:Iterator;
- private var methodIsAsynchronous:Boolean;
+ protected var methodIsAsynchronous:Boolean;
/**
* Constructs a test case with the given name.
@@ -99,12 +100,14 @@
var className:Object = description.@name;
var methods:XMLList = description..method.(@name.match("^test"));
if(testMethod != null) {
- runSingle = true;
testMethods = testMethod.split(", ").join(",").split(",");
} else {
setTestMethods(methods);
}
- setName(className.toString());
+ if(testMethods.length == 1) {
+ runSingle = true;
+ }
+ setName(className.toString());
}
/**
@@ -152,8 +155,7 @@
* @see TestResult
*/
public function run():void {
- var result:TestResult = getResult();
- result.run(this);
+ getResult().run(this);
}
public function setResult(result:TestResult):void {
@@ -181,12 +183,11 @@
}
}
finally {
- if(!runSingle) {
- if(!itr.hasNext() && !methodIsAsynchronous) {
- cleanUp();
- result.endTest(this);
- isComplete = true;
- }
+ if(!itr.hasNext() && !methodIsAsynchronous) {
+ cleanUp();
+ getResult().endTest(this);
+ isComplete = true;
+ dispatchEvent(new Event(Event.COMPLETE));
}
}
}
@@ -225,10 +226,10 @@
}
}
catch(e:AssertionFailedError) {
- result.addFailure(this, e);
+ getResult().addFailure(this, e);
}
catch(ioe:Error) {
- result.addError(this, ioe);
+ getResult().addError(this, ioe);
}
return true;
}
@@ -250,7 +251,7 @@
/**
* Returns a string representation of the test case
*/
- public function toString():String {
+ override public function toString():String {
return getName() + "." + getCurrentMethod() + "()";
}
/**
@@ -278,29 +279,32 @@
}
protected function addAsync(handler:Function, timeout:int=500):Function {
- methodIsAsynchronous = true;
+ this.methodIsAsynchronous = true;
var context:TestCase = this;
- asyncMethodTimeoutId = setTimeout(timeoutHandler, timeout);
+ this.asyncMethodTimeoutId = setTimeout(this.timeoutHandler, timeout, timeout);
return function(args:*):* {
+ clearTimeout(context.asyncMethodTimeoutId);
try {
handler.apply(context, arguments);
}
catch(e:AssertionFailedError) {
- context.result.addFailure(context, e);
+ context.getResult().addFailure(context, e);
}
catch(ioe:IllegalOperationError) {
- trace('foo'); // this trace needs to be here?! Why?!
- context.result.addError(context, ioe);
+ trace('illegaloperation'); // this trace needs to be here?! Why?!
+ // without that trace, the app throws an error!!!!
+ context.getResult().addError(context, ioe);
}
finally {
+ trace("ASYNC METHOD FINALLY BLOCK CALLED!");
context.methodIsAsynchronous = false;
context.runBare();
}
}
}
- protected function timeoutHandler():void {
- result.addError(this, new IllegalOperationError("TestCase.DEFAULT_TIMEOUT (" + DEFAULT_TIMEOUT + "ms) exceeded on an asynchronous test method."));
+ protected function timeoutHandler(timeout:Number):void {
+ result.addError(this, new IllegalOperationError("TestCase.timeout (" + timeout + "ms) exceeded on an asynchronous test method."));
methodIsAsynchronous = false;
runBare();
}
Modified: trunk/framework/as3/asunit/framework/TestSuite.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestSuite.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/framework/TestSuite.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -1,5 +1,8 @@
package asunit.framework {
import flash.display.DisplayObjectContainer;
+ import flash.events.Event;
+ import asunit.util.Iterator;
+ import asunit.util.ArrayIterator;
/**
* A <code>TestSuite</code> is a <code>Composite</code> of Tests.
@@ -15,6 +18,7 @@
*/
public class TestSuite extends TestCase implements Test {
private var fTests:Array = new Array();
+ private var testsCompleteCount:Number = 0;
public function TestSuite() {
super();
@@ -48,12 +52,22 @@
*/
public override function run():void {
var result:TestResult = getResult();
- for each(var test:TestCase in fTests) {
+ var test:Test;
+ var itr:Iterator = new ArrayIterator(fTests);
+ while(itr.hasNext()) {
+ test = Test(itr.next());
test.setResult(result);
+ test.addEventListener(Event.COMPLETE, testCompleteHandler);
test.run();
}
}
-
+
+ private function testCompleteHandler(event:Event):void {
+ if(++testsCompleteCount >= testCount()) {
+ dispatchEvent(new Event(Event.COMPLETE));
+ }
+ }
+
/**
* Returns the number of tests in this suite
*/
Modified: trunk/framework/as3/asunit/textui/TestRunner.as
===================================================================
--- trunk/framework/as3/asunit/textui/TestRunner.as 2006-09-20 21:23:53 UTC (rev 114)
+++ trunk/framework/as3/asunit/textui/TestRunner.as 2006-09-21 01:32:40 UTC (rev 115)
@@ -32,6 +32,8 @@
public static const EXCEPTION_EXIT:int = 2;
public static const SHOW_TRACE:Boolean = true;
protected var fPrinter:ResultPrinter;
+ protected var startTime:Number;
+ protected var result:TestResult;
public function TestRunner() {
configureListeners();
@@ -66,14 +68,14 @@
// fscommand("showmenu", "false");
try {
- var suite:Test;
+ var instance:Test;
if(testMethod != null) {
- suite = new testCase(testMethod);
+ instance = new testCase(testMethod);
}
else {
- suite = new testCase();
+ instance = new testCase();
}
- return doRun(suite, showTrace);
+ return doRun(instance, showTrace);
}
catch(e:Error) {
throw new Error("Could not create and run test suite: " + e.getStackTrace());
@@ -81,8 +83,8 @@
return null;
}
- public function doRun(suite:Test, showTrace:Boolean = false):TestResult {
- var result:TestResult = new TestResult();
+ public function doRun(test:Test, showTrace:Boolean = false):TestResult {
+ result = new TestResult();
if(fPrinter == null) {
setPrinter(new ResultPrinter(showTrace));
}
@@ -90,39 +92,18 @@
fPrinter.setShowTrace(showTrace);
}
result.addListener(getPrinter());
- var startTime:Number = getTimer();
- suite.setResult(result);
- suite.setContext(this);
- suite.run();
-
- // Wait for all tests to be completed before finishing
- // the output.
- // This is how we are going to support asynchronous
- // TestCases.
- var intervalObj:Object = new Object();
- intervalObj.startTime = startTime;
- intervalObj.result = result;
- intervalObj.suite = suite;
- intervalObj.runOnce = false;
- // If you have no asynchronous TestCases, this will complete
- // in one millisecond
- intervalObj.intervalId = setInterval(onTestCompleted, 1, intervalObj);
-
+ startTime = getTimer();
+ test.setResult(result);
+ test.setContext(this);
+ test.addEventListener(Event.COMPLETE, testCompleteHandler);
+ test.run();
return result;
}
- private function onTestCompleted(intervalObj:Object):void {
- if(intervalObj.suite.getIsComplete()) {
- var endTime:Number = getTimer();
- var runTime:Number = endTime - intervalObj.startTime;
- getPrinter().printResult(intervalObj.result, runTime);
- clearInterval(intervalObj.intervalId);
- } else if(!intervalObj.runOnce) {
- // If you have an asynchronous TestCase, poll at less frequent intervals
- clearInterval(intervalObj.intervalId);
- intervalObj.runOnce = true;
- intervalObj.intervalId = setInterval(onTestCompleted, 20, intervalObj);
- }
+ private function testCompleteHandler(event:Event):void {
+ var endTime:Number = getTimer();
+ var runTime:Number = endTime - startTime;
+ getPrinter().printResult(result, runTime);
}
public function setPrinter(printer:ResultPrinter):void {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 21:23:57
|
Revision: 114
http://svn.sourceforge.net/asunit/?rev=114&view=rev
Author: lukebayes
Date: 2006-09-20 14:23:53 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
updating comments in TestCase
Modified Paths:
--------------
trunk/framework/as3/asunit/framework/TestCaseExample.as
Modified: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-09-20 21:22:59 UTC (rev 113)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-09-20 21:23:53 UTC (rev 114)
@@ -6,9 +6,8 @@
import flash.events.EventDispatcher;
import flash.utils.setTimeout;
- // These should always end with Test, the example
- // doesn't because we don't want TestSuites in this
- // directory.
+ // TestCase subclasses should always end with 'Test', the example
+ // doesn't because we don't want TestSuites in this directory.
public class TestCaseExample extends TestCase {
private var date:Date;
private var sprite:Sprite;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 21:23:08
|
Revision: 113
http://svn.sourceforge.net/asunit/?rev=113&view=rev
Author: lukebayes
Date: 2006-09-20 14:22:59 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
updated runner to execute all tests
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:21:37 UTC (rev 112)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:22:59 UTC (rev 113)
@@ -1,13 +1,10 @@
package {
- import asunit.framework.TestCaseExample;
import asunit.textui.TestRunner;
- import asunit.textui.TestRunnerTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
-// start(AllTests, null, TestRunner.SHOW_TRACE);
- start(TestCaseExample);
+ start(AllTests, null, TestRunner.SHOW_TRACE);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 21:21:44
|
Revision: 112
http://svn.sourceforge.net/asunit/?rev=112&view=rev
Author: lukebayes
Date: 2006-09-20 14:21:37 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
got async method working better
Modified Paths:
--------------
trunk/framework/as3/AsUnitTestRunner.as
trunk/framework/as3/asunit/framework/TestCase.as
Added Paths:
-----------
trunk/framework/as3/asunit/framework/TestCaseExample.as
Removed Paths:
-------------
trunk/framework/as3/asunit/AllTests.as
Modified: trunk/framework/as3/AsUnitTestRunner.as
===================================================================
--- trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/AsUnitTestRunner.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -1,13 +1,13 @@
package {
+ import asunit.framework.TestCaseExample;
import asunit.textui.TestRunner;
- import asunit.framework.TestCaseTest;
import asunit.textui.TestRunnerTest;
public class AsUnitTestRunner extends TestRunner {
public function AsUnitTestRunner() {
- start(AllTests, null, TestRunner.SHOW_TRACE);
-// start(TestRunnerTest);
+// start(AllTests, null, TestRunner.SHOW_TRACE);
+ start(TestCaseExample);
}
}
}
Deleted: trunk/framework/as3/asunit/AllTests.as
===================================================================
--- trunk/framework/as3/asunit/AllTests.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/asunit/AllTests.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -1,15 +0,0 @@
-package asunit {
- import asunit.framework.TestSuite;
- import asunit.framework.AllTests;
- import asunit.textui.AllTests;
- import asunit.util.AllTests;
-
- public class AllTests extends TestSuite {
-
- public function AllTests() {
- addTest(new asunit.framework.AllTests());
- addTest(new asunit.textui.AllTests());
- addTest(new asunit.util.AllTests());
- }
- }
-}
Modified: trunk/framework/as3/asunit/framework/TestCase.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 18:50:50 UTC (rev 111)
+++ trunk/framework/as3/asunit/framework/TestCase.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -79,7 +79,7 @@
/**
* the name of the test case
*/
- protected var DEFAULT_TIMEOUT:int = 500;
+ protected static var DEFAULT_TIMEOUT:int = 500;
protected var fName:String;
protected var result:TestResult;
protected var testMethods:Array;
@@ -277,10 +277,10 @@
return context;
}
- protected function addAsync(handler:Function):Function {
+ protected function addAsync(handler:Function, timeout:int=500):Function {
methodIsAsynchronous = true;
- var context:Object = this;
- asyncMethodTimeoutId = setTimeout(timeoutHandler, DEFAULT_TIMEOUT);
+ var context:TestCase = this;
+ asyncMethodTimeoutId = setTimeout(timeoutHandler, timeout);
return function(args:*):* {
try {
handler.apply(context, arguments);
@@ -289,10 +289,13 @@
context.result.addFailure(context, e);
}
catch(ioe:IllegalOperationError) {
+ trace('foo'); // this trace needs to be here?! Why?!
context.result.addError(context, ioe);
}
- context.methodIsAsynchronous = false;
- context.runBare();
+ finally {
+ context.methodIsAsynchronous = false;
+ context.runBare();
+ }
}
}
Added: trunk/framework/as3/asunit/framework/TestCaseExample.as
===================================================================
--- trunk/framework/as3/asunit/framework/TestCaseExample.as (rev 0)
+++ trunk/framework/as3/asunit/framework/TestCaseExample.as 2006-09-20 21:21:37 UTC (rev 112)
@@ -0,0 +1,77 @@
+package asunit.framework {
+ import asunit.framework.TestCase;
+ import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.events.IEventDispatcher;
+ import flash.events.EventDispatcher;
+ import flash.utils.setTimeout;
+
+ // These should always end with Test, the example
+ // doesn't because we don't want TestSuites in this
+ // directory.
+ public class TestCaseExample extends TestCase {
+ private var date:Date;
+ private var sprite:Sprite;
+
+ // TestCase constructors must be implemented as follows
+ // so that we can execute a single method on them from
+ // the TestRunner
+ public function TestCaseExample(testMethod:String = null) {
+ super(testMethod);
+ }
+
+ // This method will be called before every test method
+ protected override function setUp():void {
+ date = new Date();
+// sprite = new Sprite();
+// addChild(sprite);
+ }
+
+ // This method will be called after every test method
+ // but only if we're executing the entire TestCase,
+ // the tearDown method won't be called if we're
+ // calling start(MyTestCase, "someMethod");
+ protected override function tearDown():void {
+// removeChild(sprite);
+// sprite = null;
+ date = null;
+ }
+
+ // This is auto-created by the XULUI and ensures that
+ // our objects are actually created as we expect.
+ public function testInstantiated():void {
+ assertTrue("Date instantiated", date is Date);
+// assertTrue("Sprite instantiated", sprite is Sprite);
+ }
+
+ // This is an example of a typical test method
+ public function testMonthGetterSetter():void {
+ date.month = 1;
+ assertEquals(1, date.month);
+ }
+
+ // This is an asynchronous test method
+ public function testAsyncFeature():void {
+ // create a new object that dispatches events...
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ // get a TestCase async event handler reference
+ var handler:Function = addAsync(changeHandler);
+ // subscribe to your event dispatcher using the returned handler
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ // cause the event to be dispatched.
+// dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ setTimeout(dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
+ }
+
+ protected function changeHandler(event:Event):void {
+ assertEquals(Event.CHANGE, event.type);
+ }
+
+ public function testAsyncFeatureTimeout():void {
+ var dispatcher:IEventDispatcher = new EventDispatcher();
+ var handler:Function = addAsync(changeHandler, 100);
+ dispatcher.addEventListener(Event.CHANGE, handler);
+ dispatcher.dispatchEvent(new Event(Event.CHANGE));
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 18:50:53
|
Revision: 111
http://svn.sourceforge.net/asunit/?rev=111&view=rev
Author: lukebayes
Date: 2006-09-20 11:50:50 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
added ignore props
Property Changed:
----------------
trunk/framework/
Property changes on: trunk/framework
___________________________________________________________________
Name: svn:ignore
+ .settings
.project
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 18:49:41
|
Revision: 110
http://svn.sourceforge.net/asunit/?rev=110&view=rev
Author: lukebayes
Date: 2006-09-20 11:49:37 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
working on a rakefile for building the xului, not working yet
Added Paths:
-----------
trunk/xului/rakefile.rb
Added: trunk/xului/rakefile.rb
===================================================================
--- trunk/xului/rakefile.rb (rev 0)
+++ trunk/xului/rakefile.rb 2006-09-20 18:49:37 UTC (rev 110)
@@ -0,0 +1,21 @@
+require 'fileutils'
+
+desc "get rid of previously built files"
+task :clean do
+end
+
+desc "full project build"
+task :complete => [:clean, :default] do
+end
+
+desc "incremental project build"
+task :default do
+end
+
+task :move do
+
+end
+
+desc "publish build to the web"
+task :publish => :complete do
+end
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luk...@us...> - 2006-09-20 18:48:58
|
Revision: 109
http://svn.sourceforge.net/asunit/?rev=109&view=rev
Author: lukebayes
Date: 2006-09-20 11:48:51 -0700 (Wed, 20 Sep 2006)
Log Message:
-----------
removed ignore props from this folder
Property Changed:
----------------
trunk/ruby/
Property changes on: trunk/ruby
___________________________________________________________________
Name: svn:ignore
- .settings
html-template
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|