You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by mi...@apache.org on 2017/08/14 17:56:41 UTC
[1/7] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35321
LayoutManager.validateNow() doesn't use phased instantiation,
so it wasn't the best idea to test it with that,
at least the test where we fake a user request for the removal of the
component
Repository: flex-sdk
Updated Branches:
refs/heads/develop bb7447f5e -> f804380f1
FLEX-35321 LayoutManager.validateNow() doesn't use phased instantiation, so it wasn't the best idea to test it with that, at least the test where we fake a user request for the removal of the component in the next frame. Also added a test that tries to make sure that objects removed from stage and then readded are indeed validated and initialized.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/f475aed9
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/f475aed9
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/f475aed9
Branch: refs/heads/develop
Commit: f475aed995adc5206a27ad6fc8cf80224ed425fb
Parents: 5ea79a2
Author: Mihai Chira <mi...@apache.org>
Authored: Sat Jun 10 10:33:28 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Sat Jun 10 10:33:28 2017 +0200
----------------------------------------------------------------------
.../managers/LayoutManager_FLEX_35321_Tests.as | 104 ++++++++++++++++---
1 file changed, 88 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f475aed9/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
index 47d5f14..a23d002 100644
--- a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
+++ b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
@@ -6,7 +6,8 @@ package mx.managers {
import mx.core.mx_internal;
import mx.events.FlexEvent;
- import org.flexunit.asserts.assertFalse;
+ import org.flexunit.asserts.assertEquals;
+ import org.flexunit.asserts.assertNotNull;
import org.flexunit.asserts.assertNull;
import org.flexunit.async.Async;
import org.fluint.uiImpersonation.UIImpersonator;
@@ -19,14 +20,15 @@ package mx.managers {
private static const _finishNotifier:EventDispatcher = new EventDispatcher();
private var _objectWhichIsRemovedOnSizeValidation:SomeComponent;
- private var _creationCompleteCalled:Boolean;
+ private var _creationCompleteCalls:int;
[Before]
public function setUp():void
{
- _creationCompleteCalled = false;
+ _creationCompleteCalls = 0;
_objectWhichIsRemovedOnSizeValidation = new SomeComponent();
- UIImpersonator.addChild(_objectWhichIsRemovedOnSizeValidation);
+ _objectWhichIsRemovedOnSizeValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
+ UIImpersonator.addElement(_objectWhichIsRemovedOnSizeValidation);
}
[After]
@@ -41,14 +43,14 @@ package mx.managers {
{
//given
UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = false;
- _objectWhichIsRemovedOnSizeValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
+ _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = true;
//when
_objectWhichIsRemovedOnSizeValidation.validateNow();
//then
assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
- assertFalse("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", _creationCompleteCalled);
+ assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
}
[Test(async, timeout=500)]
@@ -56,25 +58,79 @@ package mx.managers {
{
//given
UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = true;
- _objectWhichIsRemovedOnSizeValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
+ _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = false;
//when
- _objectWhichIsRemovedOnSizeValidation.validateNow();
- _objectWhichIsRemovedOnSizeValidation.pretendUserAskedForComponentRemoval();
+ _objectWhichIsRemovedOnSizeValidation.invalidateDisplayList();
+ _objectWhichIsRemovedOnSizeValidation.invalidateProperties();
+ _objectWhichIsRemovedOnSizeValidation.invalidateSize();
+
+ //then wait 1 frame
+ noEnterFramesRemaining = 1;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_in_next_frame, 300);
+ }
+
+ private function then_remove_from_stage_in_next_frame(event:Event, passThroughData:Object):void
+ {
+ //when
+ _objectWhichIsRemovedOnSizeValidation.pretendUserAskedForComponentRemovalInNextFrame();
//then wait 2 frames
noEnterFramesRemaining = 2;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_assert, 300);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_assert_not_initialized, 300);
+ }
+
+ private function then_assert_not_initialized(event:Event, passThroughData:Object):void
+ {
+ //then
+ assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
+ assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
+ }
+
+
+ [Test(async, timeout=750)]
+ public function test_object_removed_from_stage_then_readded_is_initialized_once():void
+ {
+ //given
+ UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = true;
+ _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = false;
+
+ //when
+ _objectWhichIsRemovedOnSizeValidation.validateNow();
+ _objectWhichIsRemovedOnSizeValidation.pretendUserAskedForComponentRemovalInNextFrame();
+
+ //then wait 1 frame
+ noEnterFramesRemaining = 1;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_readd_object, 200);
}
- private function then_assert(event:Event, passThroughData:Object):void
+ private function then_readd_object(event:Event, passThroughData:Object):void
{
//then
assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
- assertFalse("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", _creationCompleteCalled);
+
+ //when
+ UIImpersonator.addElement(_objectWhichIsRemovedOnSizeValidation);
+
+ //then wait 4 frames, to make sure validation is done
+ noEnterFramesRemaining = 4;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_assert_one_initialization_only, 400);
+ }
+
+ private function then_assert_one_initialization_only(event:Event, passThroughData:Object):void
+ {
+ //then
+ assertNotNull("The object should be on stage...", _objectWhichIsRemovedOnSizeValidation.parent);
+ assertEquals("When validation is interrupted half-way it should be complete once the object is re-added to stage", 1, _creationCompleteCalls);
}
+
+
+
private static function onEnterFrame(event:Event):void
{
if(!--noEnterFramesRemaining)
@@ -86,7 +142,7 @@ package mx.managers {
private function onCreationComplete(event:FlexEvent):void
{
- _creationCompleteCalled = true;
+ _creationCompleteCalls++;
}
}
}
@@ -99,12 +155,23 @@ import mx.core.UIComponent;
class SomeComponent extends UIComponent
{
- private var _timer:Timer = new Timer(1, 1);
+ private var _removeFromStageOnValidateProperties:Boolean = false;
+
+ override public function validateProperties():void
+ {
+ super.validateProperties();
+ if(_removeFromStageOnValidateProperties)
+ removeFromStage();
+ }
override public function validateSize(recursive:Boolean = false):void
{
super.validateSize(recursive);
- removeFromStage();
+ }
+
+ override public function validateDisplayList():void
+ {
+ super.validateDisplayList();
}
private function removeFromStage():void
@@ -118,8 +185,13 @@ class SomeComponent extends UIComponent
}
}
- public function pretendUserAskedForComponentRemoval():void
+ public function pretendUserAskedForComponentRemovalInNextFrame():void
{
callLater(removeFromStage);
}
+
+ public function set removeFromStageOnValidateProperties(value:Boolean):void
+ {
+ _removeFromStageOnValidateProperties = value;
+ }
}
\ No newline at end of file
[4/7] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35321 CAUSE:
If a component is removed from stage during a validation cycle,
the LayoutManager nevertheless sets its initialized flag to true,
even if it's not on stage anymore. That's because it d
Posted by mi...@apache.org.
FLEX-35321 CAUSE: If a component is removed from stage during a validation cycle, the LayoutManager nevertheless sets its initialized flag to true, even if it's not on stage anymore. That's because it doesn't check at the end whether the component is still on stage.
SOLUTION: Now the LayoutManager verifies that the component is still on stage before initializing it.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/9c5cbbe5
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/9c5cbbe5
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/9c5cbbe5
Branch: refs/heads/develop
Commit: 9c5cbbe553c9d8afe7982f3ba4bf178ee563bf35
Parents: 442b5f8
Author: Mihai Chira <mi...@apache.org>
Authored: Sat Jun 10 13:36:47 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Sat Jun 10 13:36:47 2017 +0200
----------------------------------------------------------------------
.../framework/src/mx/managers/LayoutManager.as | 28 ++++++++++++--------
1 file changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9c5cbbe5/frameworks/projects/framework/src/mx/managers/LayoutManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/managers/LayoutManager.as b/frameworks/projects/framework/src/mx/managers/LayoutManager.as
index feebeff..d070203 100644
--- a/frameworks/projects/framework/src/mx/managers/LayoutManager.as
+++ b/frameworks/projects/framework/src/mx/managers/LayoutManager.as
@@ -846,11 +846,14 @@ public class LayoutManager extends EventDispatcher implements ILayoutManager
var obj:ILayoutManagerClient = ILayoutManagerClient(updateCompleteQueue.removeLargest());
while (obj)
{
- if (!obj.initialized && obj.processedDescriptors)
- obj.initialized = true;
- if (obj.hasEventListener(FlexEvent.UPDATE_COMPLETE))
- obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
- obj.updateCompletePendingFlag = false;
+ if(obj.nestLevel)
+ {
+ if (!obj.initialized && obj.processedDescriptors)
+ obj.initialized = true;
+ if (obj.hasEventListener(FlexEvent.UPDATE_COMPLETE))
+ obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
+ obj.updateCompletePendingFlag = false;
+ }
obj = ILayoutManagerClient(updateCompleteQueue.removeLargest());
}
@@ -1094,12 +1097,15 @@ public class LayoutManager extends EventDispatcher implements ILayoutManager
obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
while (obj)
{
- if (!obj.initialized)
- obj.initialized = true;
-
- if (obj.hasEventListener(FlexEvent.UPDATE_COMPLETE))
- obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
- obj.updateCompletePendingFlag = false;
+ if(obj.nestLevel)
+ {
+ if (!obj.initialized)
+ obj.initialized = true;
+
+ if (obj.hasEventListener(FlexEvent.UPDATE_COMPLETE))
+ obj.dispatchEvent(new FlexEvent(FlexEvent.UPDATE_COMPLETE));
+ obj.updateCompletePendingFlag = false;
+ }
obj = ILayoutManagerClient(updateCompleteQueue.removeLargestChild(target));
}
}
[2/7] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35321
test_object_removed_from_stage_via_user_action_is_not_initialized() needed
one more frame to complete (made sure it fails without the proposed fix,
and passes with it). Also made some variabl
Posted by mi...@apache.org.
FLEX-35321 test_object_removed_from_stage_via_user_action_is_not_initialized() needed one more frame to complete (made sure it fails without the proposed fix, and passes with it). Also made some variable and function renames, plus now we can also test how many times each validation function has been called.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/75b4d39d
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/75b4d39d
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/75b4d39d
Branch: refs/heads/develop
Commit: 75b4d39d806d6a3bef3cd123493fe4b718f9b2c3
Parents: f475aed
Author: Mihai Chira <mi...@apache.org>
Authored: Sat Jun 10 11:52:14 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Sat Jun 10 11:52:14 2017 +0200
----------------------------------------------------------------------
.../managers/LayoutManager_FLEX_35321_Tests.as | 135 +++++++++++++------
1 file changed, 96 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/75b4d39d/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
index a23d002..1fef434 100644
--- a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
+++ b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
@@ -19,101 +19,108 @@ package mx.managers {
private static var noEnterFramesRemaining:int = NaN;
private static const _finishNotifier:EventDispatcher = new EventDispatcher();
- private var _objectWhichIsRemovedOnSizeValidation:SomeComponent;
+ private var _objectWhichIsRemovedAtValidation:SomeComponent;
private var _creationCompleteCalls:int;
[Before]
public function setUp():void
{
_creationCompleteCalls = 0;
- _objectWhichIsRemovedOnSizeValidation = new SomeComponent();
- _objectWhichIsRemovedOnSizeValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
- UIImpersonator.addElement(_objectWhichIsRemovedOnSizeValidation);
+ _objectWhichIsRemovedAtValidation = new SomeComponent();
+ _objectWhichIsRemovedAtValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
+ UIImpersonator.addChild(_objectWhichIsRemovedAtValidation);
}
[After]
public function tearDown():void
{
UIImpersonator.removeAllChildren();
- _objectWhichIsRemovedOnSizeValidation = null;
+ _objectWhichIsRemovedAtValidation = null;
}
+
+ //--------------------------------------------------------------------------
+ //
+ // Test method
+ //
+ //--------------------------------------------------------------------------
+
+
[Test]
public function test_object_removed_from_stage_via_code_is_not_initialized():void
{
//given
UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = false;
- _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = true;
+ _objectWhichIsRemovedAtValidation.removeFromStageOnValidateProperties = true;
//when
- _objectWhichIsRemovedOnSizeValidation.validateNow();
+ _objectWhichIsRemovedAtValidation.validateNow();
//then
- assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
- assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
+ then_assert_not_initialized();
}
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Test method
+ //
+ //--------------------------------------------------------------------------
+
+
[Test(async, timeout=500)]
public function test_object_removed_from_stage_via_user_action_is_not_initialized():void
{
//given
UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = true;
- _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = false;
+ _objectWhichIsRemovedAtValidation.removeFromStageOnValidateProperties = false;
//when
- _objectWhichIsRemovedOnSizeValidation.invalidateDisplayList();
- _objectWhichIsRemovedOnSizeValidation.invalidateProperties();
- _objectWhichIsRemovedOnSizeValidation.invalidateSize();
+ _objectWhichIsRemovedAtValidation.invalidateDisplayList();
+ _objectWhichIsRemovedAtValidation.invalidateProperties();
+ _objectWhichIsRemovedAtValidation.invalidateSize();
//then wait 1 frame
noEnterFramesRemaining = 1;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_in_next_frame, 300);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, then_assert_not_initialized);
}
- private function then_remove_from_stage_in_next_frame(event:Event, passThroughData:Object):void
- {
- //when
- _objectWhichIsRemovedOnSizeValidation.pretendUserAskedForComponentRemovalInNextFrame();
- //then wait 2 frames
- noEnterFramesRemaining = 2;
- UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_assert_not_initialized, 300);
- }
- private function then_assert_not_initialized(event:Event, passThroughData:Object):void
- {
- //then
- assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
- assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
- }
+ //--------------------------------------------------------------------------
+ //
+ // Test method
+ //
+ //--------------------------------------------------------------------------
[Test(async, timeout=750)]
public function test_object_removed_from_stage_then_readded_is_initialized_once():void
{
//given
UIComponentGlobals.mx_internal::layoutManager.usePhasedInstantiation = true;
- _objectWhichIsRemovedOnSizeValidation.removeFromStageOnValidateProperties = false;
+ _objectWhichIsRemovedAtValidation.removeFromStageOnValidateProperties = false;
//when
- _objectWhichIsRemovedOnSizeValidation.validateNow();
- _objectWhichIsRemovedOnSizeValidation.pretendUserAskedForComponentRemovalInNextFrame();
+ _objectWhichIsRemovedAtValidation.invalidateDisplayList();
+ _objectWhichIsRemovedAtValidation.invalidateProperties();
+ _objectWhichIsRemovedAtValidation.invalidateSize();
//then wait 1 frame
noEnterFramesRemaining = 1;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_readd_object, 200);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, then_readd_object);
}
private function then_readd_object(event:Event, passThroughData:Object):void
{
//then
- assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedOnSizeValidation.parent);
+ assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedAtValidation.parent);
//when
- UIImpersonator.addElement(_objectWhichIsRemovedOnSizeValidation);
+ UIImpersonator.addElement(_objectWhichIsRemovedAtValidation);
//then wait 4 frames, to make sure validation is done
noEnterFramesRemaining = 4;
@@ -124,11 +131,43 @@ package mx.managers {
private function then_assert_one_initialization_only(event:Event, passThroughData:Object):void
{
//then
- assertNotNull("The object should be on stage...", _objectWhichIsRemovedOnSizeValidation.parent);
+ assertNotNull("The object should be on stage...", _objectWhichIsRemovedAtValidation.parent);
assertEquals("When validation is interrupted half-way it should be complete once the object is re-added to stage", 1, _creationCompleteCalls);
}
+ //--------------------------------------------------------------------------
+ //
+ // Shared test methods
+ //
+ //--------------------------------------------------------------------------
+
+ private function then_remove_from_stage_via_callLater(event:Event, passThroughData:Object):void
+ {
+ //then
+ assertEquals("The first validation step should have completed by now", 1, _objectWhichIsRemovedAtValidation.numValidatePropertiesCalls);
+ assertEquals("But not validateSize()", 0, _objectWhichIsRemovedAtValidation.numValidateSizeCalls);
+ assertEquals("Nor validateDisplayList()", 0, _objectWhichIsRemovedAtValidation.numValidateDisplayListCalls);
+
+ //given
+ const whereToGoNext:Function = passThroughData as Function;
+
+ //when
+ _objectWhichIsRemovedAtValidation.pretendUserAskedForComponentRemovalInNextFrame();
+
+ //then wait 2 frames
+ noEnterFramesRemaining = 3;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, whereToGoNext, 300);
+ }
+
+ private function then_assert_not_initialized(event:Event = null, passThroughData:Object = null):void
+ {
+ //then
+ assertNull("The object was actually not removed from stage. Huh?", _objectWhichIsRemovedAtValidation.parent);
+ assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
+ }
+
private static function onEnterFrame(event:Event):void
@@ -147,19 +186,20 @@ package mx.managers {
}
}
-import flash.events.TimerEvent;
-import flash.utils.Timer;
-
import mx.core.IVisualElementContainer;
import mx.core.UIComponent;
class SomeComponent extends UIComponent
{
private var _removeFromStageOnValidateProperties:Boolean = false;
+ private var _numValidatePropertiesCalls:int = 0;
+ private var _numValidateSizeCalls:int = 0;
+ private var _numValidateDisplayListCalls:int = 0;
override public function validateProperties():void
{
super.validateProperties();
+ _numValidatePropertiesCalls++;
if(_removeFromStageOnValidateProperties)
removeFromStage();
}
@@ -167,11 +207,13 @@ class SomeComponent extends UIComponent
override public function validateSize(recursive:Boolean = false):void
{
super.validateSize(recursive);
+ _numValidateSizeCalls++;
}
override public function validateDisplayList():void
{
super.validateDisplayList();
+ _numValidateDisplayListCalls++;
}
private function removeFromStage():void
@@ -194,4 +236,19 @@ class SomeComponent extends UIComponent
{
_removeFromStageOnValidateProperties = value;
}
+
+ public function get numValidateDisplayListCalls():int
+ {
+ return _numValidateDisplayListCalls;
+ }
+
+ public function get numValidateSizeCalls():int
+ {
+ return _numValidateSizeCalls;
+ }
+
+ public function get numValidatePropertiesCalls():int
+ {
+ return _numValidatePropertiesCalls;
+ }
}
\ No newline at end of file
[5/7] git commit: [flex-sdk] [refs/heads/develop] - Merge
remote-tracking branch 'origin/develop' into develop
Posted by mi...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/0226437e
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/0226437e
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/0226437e
Branch: refs/heads/develop
Commit: 0226437edfef900f9135b3fd97b8b82af10b2ae0
Parents: 9c5cbbe e66554e
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Jun 20 11:50:06 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Jun 20 11:50:06 2017 +0200
----------------------------------------------------------------------
KEYS | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 116 insertions(+)
----------------------------------------------------------------------
[7/7] git commit: [flex-sdk] [refs/heads/develop] - FLEX-18746 Added
unit test (current fails).
Posted by mi...@apache.org.
FLEX-18746 Added unit test (current fails).
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/f804380f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/f804380f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/f804380f
Branch: refs/heads/develop
Commit: f804380f10e725aa90fee6c2ab998b3db30fe705
Parents: fea9be9
Author: Mihai Chira <mi...@apache.org>
Authored: Mon Aug 14 19:56:14 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Mon Aug 14 19:56:14 2017 +0200
----------------------------------------------------------------------
.../tests/mx/controls/Tree_FLEX_18746_Tests.as | 112 +++++++++++++++++++
1 file changed, 112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f804380f/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as b/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as
new file mode 100644
index 0000000..5d64b06
--- /dev/null
+++ b/frameworks/projects/mx/tests/mx/controls/Tree_FLEX_18746_Tests.as
@@ -0,0 +1,112 @@
+package mx.controls {
+ import flash.events.Event;
+ import flash.events.EventDispatcher;
+
+ import mx.collections.ArrayCollection;
+ import mx.core.mx_internal;
+
+ import org.flexunit.assertThat;
+ import org.flexunit.async.Async;
+ import org.fluint.uiImpersonation.UIImpersonator;
+
+ use namespace mx_internal;
+
+ public class Tree_FLEX_18746_Tests
+ {
+ private static var noEnterFramesToWait:int = NaN;
+ private static const _finishNotifier:EventDispatcher = new EventDispatcher();
+
+ private static var _sut:Tree;
+ private static var child:Object = {label: "Item"};
+ private static var parent0:Object = {label: "Folder 0", children: new ArrayCollection()};
+ private static var parent1:Object = {label: "Folder 1", children: new ArrayCollection([child])};
+
+
+ [Before]
+ public function setUp():void
+ {
+ _sut = new Tree();
+ _sut.width = 200;
+ _sut.height = 200;
+ UIImpersonator.addChild(_sut);
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ UIImpersonator.removeAllChildren();
+ _sut = null;
+ }
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Test method
+ //
+ //--------------------------------------------------------------------------
+
+ [Test(async, timeout=1000)]
+ public function test_object_removed_from_stage_via_code_is_not_initialized():void
+ {
+ //given
+ const dataProvider:ArrayCollection = new ArrayCollection();
+ dataProvider.addItem(parent0);
+ dataProvider.addItem(parent1);
+
+ //when
+ _sut.dataProvider = dataProvider;
+
+ //then wait a few frames
+ noEnterFramesToWait = 2;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_expand_second_folder, 200);
+ }
+
+
+ private function then_expand_second_folder(event:Event, passThroughData:Object):void
+ {
+ //when
+ _sut.expandItem(parent1, true, true, true);
+
+ //then wait a bit
+ noEnterFramesToWait = 5;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_move_child_to_first_parent_and_expand_it, 500);
+ }
+
+ private function then_move_child_to_first_parent_and_expand_it(event:Event, passThroughData:Object):void
+ {
+ //then
+ assertThat(_sut.isItemOpen(parent1));
+
+ //when
+ ArrayCollection(parent1.children).removeItemAt(0);
+ _sut.expandItem(parent0, true, true, true);
+ ArrayCollection(parent0.children).addItem(child);
+
+ //then wait a bit
+ noEnterFramesToWait = 1;
+ UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_contract_second_folder, 200);
+ }
+
+ private static function then_contract_second_folder(event:Event, passThroughData:Object):void
+ {
+ //when
+ _sut.expandItem(parent1, false, true, true);
+
+ //then no error was thrown
+ assertThat(true);
+ }
+
+
+ private static function onEnterFrame(event:Event):void
+ {
+ if(!--noEnterFramesToWait)
+ {
+ UIImpersonator.testDisplay.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ _finishNotifier.dispatchEvent(new Event(Event.COMPLETE));
+ }
+ }
+ }
+}
\ No newline at end of file
[6/7] git commit: [flex-sdk] [refs/heads/develop] - Merge
remote-tracking branch 'origin/develop' into develop
Posted by mi...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/fea9be98
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/fea9be98
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/fea9be98
Branch: refs/heads/develop
Commit: fea9be98df7c60b75b1d1141e568012c5622e2c5
Parents: 0226437 bb7447f
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Jun 27 09:21:18 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Jun 27 09:21:18 2017 +0200
----------------------------------------------------------------------
RELEASE_NOTES | 42 ++++++++++++++++++++
.../macromedia/asc/embedding/LintEvaluator.java | 8 +++-
2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[3/7] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35321
Refined tests,
including checking for how many validation steps happen for size,
properties and display list. Without the fix all those expected to fail fail
(the last one is not expected to
Posted by mi...@apache.org.
FLEX-35321 Refined tests, including checking for how many validation steps happen for size, properties and display list. Without the fix all those expected to fail fail (the last one is not expected to fail without the fix, because it's there just to make sure no regression is introduced by the fix), while with the fix all of them pass.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/442b5f8e
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/442b5f8e
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/442b5f8e
Branch: refs/heads/develop
Commit: 442b5f8ea4fe08dc8e5f7d48df7dc36b101c99fe
Parents: 75b4d39
Author: Mihai Chira <mi...@apache.org>
Authored: Sat Jun 10 13:28:05 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Sat Jun 10 13:28:05 2017 +0200
----------------------------------------------------------------------
.../managers/LayoutManager_FLEX_35321_Tests.as | 42 +++++++++++++++-----
1 file changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/442b5f8e/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
index 1fef434..9b0b38c 100644
--- a/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
+++ b/frameworks/projects/framework/tests/mx/managers/LayoutManager_FLEX_35321_Tests.as
@@ -6,6 +6,8 @@ package mx.managers {
import mx.core.mx_internal;
import mx.events.FlexEvent;
+ import org.flexunit.assertThat;
+
import org.flexunit.asserts.assertEquals;
import org.flexunit.asserts.assertNotNull;
import org.flexunit.asserts.assertNull;
@@ -28,7 +30,7 @@ package mx.managers {
_creationCompleteCalls = 0;
_objectWhichIsRemovedAtValidation = new SomeComponent();
_objectWhichIsRemovedAtValidation.addEventListener(FlexEvent.CREATION_COMPLETE, onCreationComplete);
- UIImpersonator.addChild(_objectWhichIsRemovedAtValidation);
+ UIImpersonator.addElement(_objectWhichIsRemovedAtValidation);
}
[After]
@@ -45,7 +47,6 @@ package mx.managers {
//
//--------------------------------------------------------------------------
-
[Test]
public function test_object_removed_from_stage_via_code_is_not_initialized():void
{
@@ -54,10 +55,14 @@ package mx.managers {
_objectWhichIsRemovedAtValidation.removeFromStageOnValidateProperties = true;
//when
+ _objectWhichIsRemovedAtValidation.invalidateProperties();
+ _objectWhichIsRemovedAtValidation.invalidateSize();
+ _objectWhichIsRemovedAtValidation.invalidateDisplayList();
_objectWhichIsRemovedAtValidation.validateNow();
//then
then_assert_not_initialized();
+ assert_validation_count(1, 0, 0);
}
@@ -68,7 +73,6 @@ package mx.managers {
//
//--------------------------------------------------------------------------
-
[Test(async, timeout=500)]
public function test_object_removed_from_stage_via_user_action_is_not_initialized():void
{
@@ -84,7 +88,7 @@ package mx.managers {
//then wait 1 frame
noEnterFramesRemaining = 1;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, then_assert_not_initialized);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, {nextStep:then_assert_not_initialized_but_partially_validated, afterNumFrames:3});
}
@@ -111,7 +115,7 @@ package mx.managers {
//then wait 1 frame
noEnterFramesRemaining = 1;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
- Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, then_readd_object);
+ Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_remove_from_stage_via_callLater, 300, {nextStep:then_readd_object, afterNumFrames:1});
}
private function then_readd_object(event:Event, passThroughData:Object):void
@@ -122,8 +126,8 @@ package mx.managers {
//when
UIImpersonator.addElement(_objectWhichIsRemovedAtValidation);
- //then wait 4 frames, to make sure validation is done
- noEnterFramesRemaining = 4;
+ //then wait 3 frames, to make sure validation is done
+ noEnterFramesRemaining = 3;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_assert_one_initialization_only, 400);
}
@@ -132,7 +136,9 @@ package mx.managers {
{
//then
assertNotNull("The object should be on stage...", _objectWhichIsRemovedAtValidation.parent);
+ assertThat("If it's on stage, the nestLevel should be positive", _objectWhichIsRemovedAtValidation.nestLevel > 0);
assertEquals("When validation is interrupted half-way it should be complete once the object is re-added to stage", 1, _creationCompleteCalls);
+ assert_validation_count(2, 2, 1);
}
@@ -150,13 +156,14 @@ package mx.managers {
assertEquals("Nor validateDisplayList()", 0, _objectWhichIsRemovedAtValidation.numValidateDisplayListCalls);
//given
- const whereToGoNext:Function = passThroughData as Function;
+ const whereToGoNext:Function = passThroughData.nextStep as Function;
+ const afterHowManyFrames:int = passThroughData.afterNumFrames as int;
//when
_objectWhichIsRemovedAtValidation.pretendUserAskedForComponentRemovalInNextFrame();
- //then wait 2 frames
- noEnterFramesRemaining = 3;
+ //then wait
+ noEnterFramesRemaining = afterHowManyFrames;
UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
Async.handleEvent(this, _finishNotifier, Event.COMPLETE, whereToGoNext, 300);
}
@@ -168,6 +175,21 @@ package mx.managers {
assertEquals("Yep, this is the bug. Why call initialized=true on an object that's not on stage?", 0, _creationCompleteCalls);
}
+ private function then_assert_not_initialized_but_partially_validated(event:Event = null, passThroughData:Object = null):void
+ {
+ //then
+ then_assert_not_initialized(event, passThroughData);
+ assert_validation_count(1, 1, 0);
+ }
+
+ private function assert_validation_count(numPropertiesValidations:int = 1, numSizeValidations:int = 1, numDisplayListValidations:int = 1):void
+ {
+ //then
+ assertEquals("Properties should have been validated", numPropertiesValidations, _objectWhichIsRemovedAtValidation.numValidatePropertiesCalls);
+ assertEquals("Size should have been validated", numSizeValidations, _objectWhichIsRemovedAtValidation.numValidateSizeCalls);
+ assertEquals("Display list should have been validated", numDisplayListValidations, _objectWhichIsRemovedAtValidation.numValidateDisplayListCalls);
+ }
+
private static function onEnterFrame(event:Event):void