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/10/18 13:02:05 UTC

[1/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35362 Added unit test to reproduce the bug. As expected, it currently fails.

Repository: flex-sdk
Updated Branches:
  refs/heads/develop 243507a73 -> 4c6018325


FLEX-35362 Added unit test to reproduce the bug. As expected, it currently 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/23a306cc
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/23a306cc
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/23a306cc

Branch: refs/heads/develop
Commit: 23a306cc8a08bfb21165aed7647a4f1ba6edbc4b
Parents: 243507a
Author: Mihai Chira <mi...@apache.org>
Authored: Wed Oct 18 14:41:02 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Wed Oct 18 14:41:02 2017 +0200

----------------------------------------------------------------------
 .../DropDownListBase_FLEX_35362_Tests.as        | 60 ++++++++++++++++++++
 1 file changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/23a306cc/frameworks/projects/spark/tests/spark/components/DropDownListBase_FLEX_35362_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/tests/spark/components/DropDownListBase_FLEX_35362_Tests.as b/frameworks/projects/spark/tests/spark/components/DropDownListBase_FLEX_35362_Tests.as
new file mode 100644
index 0000000..1c081df
--- /dev/null
+++ b/frameworks/projects/spark/tests/spark/components/DropDownListBase_FLEX_35362_Tests.as
@@ -0,0 +1,60 @@
+package spark.components {
+    import flash.events.Event;
+    import flash.events.EventDispatcher;
+    import flash.events.KeyboardEvent;
+    import flash.ui.Keyboard;
+
+    import org.flexunit.asserts.assertTrue;
+    import org.flexunit.async.Async;
+    import org.fluint.uiImpersonation.UIImpersonator;
+
+    public class DropDownListBase_FLEX_35362_Tests {
+        private var _sut:DropDownList;
+        private static const NO_ENTER_FRAMES_TO_ALLOW:int = 2;
+        private static var noEnterFramesRemaining:int = NaN;
+        private static const _finishNotifier:EventDispatcher = new EventDispatcher();
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = new DropDownList();
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+            UIImpersonator.removeAllChildren();
+        }
+
+        [Test(async, timeout=1000)]
+        public function test_pressing_END_right_after_opening_doesnt_trigger_fatal():void
+        {
+            //given
+            UIImpersonator.addChild(_sut);
+
+            noEnterFramesRemaining = NO_ENTER_FRAMES_TO_ALLOW;
+            UIImpersonator.testDisplay.addEventListener(Event.ENTER_FRAME, onEnterFrame);
+            Async.handleEvent(this, _finishNotifier, Event.COMPLETE, then_open_drop_down_and_press_key, 300);
+        }
+
+        private function then_open_drop_down_and_press_key(event:Event, passThroughData:Object):void
+        {
+            //when
+            _sut.openDropDown();
+            _sut.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, Keyboard.END, 0, true, false, false, true, false));
+
+            //then - no fatal thrown
+            assertTrue(true);
+        }
+
+        private static function onEnterFrame(event:Event):void
+        {
+            if(!--noEnterFramesRemaining)
+            {
+                UIImpersonator.testDisplay.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+                _finishNotifier.dispatchEvent(new Event(Event.COMPLETE));
+            }
+        }
+    }
+}


[2/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35362 CAUSE: the DropDownController signals that the DropDownListBase is open immediately, even before the latter has actually made that change on stage. Since the opening takes one or two frames,

Posted by mi...@apache.org.
FLEX-35362 CAUSE: the DropDownController signals that the DropDownListBase is open immediately, even before the latter has actually made that change on stage. Since the opening takes one or two frames, it leaves a few milliseconds in which code which relies on that open/closed state erroneously assumes that it can use elements that should be on stage or initialized. In this case it's the layout property, which, due to the skin of the DropDownList, is only initialized once the drop down is actually open.

SOLUTION: we check whether the layout is not-null, and if it is, we select items in the list as if it were closed.

NOTES:
-also edited some comments, simplified Array instantiation, and removed an empty constructor.
-now the unit test will 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/4c601832
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/4c601832
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/4c601832

Branch: refs/heads/develop
Commit: 4c60183258caf23020d7398f6d2ffdab747d0e56
Parents: 23a306c
Author: Mihai Chira <mi...@apache.org>
Authored: Wed Oct 18 14:56:22 2017 +0200
Committer: Mihai Chira <mi...@apache.org>
Committed: Wed Oct 18 14:56:22 2017 +0200

----------------------------------------------------------------------
 .../flatspark/src/flatspark/utils/ColorUtils.as     | 16 ++++------------
 .../components/supportClasses/DropDownListBase.as   |  3 +--
 .../src/spark/components/supportClasses/ListBase.as |  6 +++---
 3 files changed, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4c601832/frameworks/projects/flatspark/src/flatspark/utils/ColorUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/flatspark/src/flatspark/utils/ColorUtils.as b/frameworks/projects/flatspark/src/flatspark/utils/ColorUtils.as
index 09f9cb2..e9007c3 100644
--- a/frameworks/projects/flatspark/src/flatspark/utils/ColorUtils.as
+++ b/frameworks/projects/flatspark/src/flatspark/utils/ColorUtils.as
@@ -45,15 +45,10 @@ package flatspark.utils
 		public static const Concrete:uint = 0x95A5A6;
 		public static const Asbestos:uint = 0x7F8C8D;
 		
-		public function ColorUtils()
-		{
-			
-		}		
-		
 		public static function ButtonColor(brand:int, estado:State):uint
 		{
 			// All the possible colors
-			var cores:Array = new Array(
+			var cores:Array = [
 				ButtonColorEnum.PrimaryUp, ButtonColorEnum.PrimaryHover, ButtonColorEnum.PrimaryDown, ButtonColorEnum.PrimaryDisabled,
 				ButtonColorEnum.SuccessUp, ButtonColorEnum.SuccessHover, ButtonColorEnum.SuccessDown, ButtonColorEnum.SuccessDisabled,
 				ButtonColorEnum.WarningUp, ButtonColorEnum.WarningHover, ButtonColorEnum.WarningDown, ButtonColorEnum.WarningDisabled,
@@ -61,7 +56,7 @@ package flatspark.utils
 				ButtonColorEnum.DefaultUp, ButtonColorEnum.DefaultHover, ButtonColorEnum.DefaultDown, ButtonColorEnum.DefaultDisabled,
 				ButtonColorEnum.InfoUp, ButtonColorEnum.InfoHover, ButtonColorEnum.InfoDown, ButtonColorEnum.InfoDisabled,
 				ButtonColorEnum.DangerUp, ButtonColorEnum.DangerHover, ButtonColorEnum.DangerDown, ButtonColorEnum.DangerDisabled
-				);
+				];
 			
 			// Map all the allowed states
 			var numeroEstado:int = 1;
@@ -80,11 +75,8 @@ package flatspark.utils
 					numeroEstado = 3;
 					break;
 			}
-			
-			var posicao:int = 1;
-			posicao = 4 * (brand - 1) + (numeroEstado - 1); 
-			
-			return cores[posicao];
+
+			return cores[4 * (brand - 1) + (numeroEstado - 1)];
 		}
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4c601832/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as b/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as
index aaba442..c80c2b4 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/DropDownListBase.as
@@ -900,7 +900,7 @@ public class DropDownListBase extends List
             var proposedNewIndex:int = NO_SELECTION;
             var currentIndex:int;
                         
-            if (isDropDownOpen)
+            if (isDropDownOpen && layout)
             {   
                 // Normalize the proposed index for getNavigationDestinationIndex
                 currentIndex = userProposedSelectedIndex < NO_SELECTION ? NO_SELECTION : userProposedSelectedIndex;
@@ -992,7 +992,6 @@ public class DropDownListBase extends List
         {
             event.preventDefault();
         }
-        
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4c601832/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as b/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
index e700d0d..fbe1050 100644
--- a/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
+++ b/frameworks/projects/spark/src/spark/components/supportClasses/ListBase.as
@@ -1877,9 +1877,9 @@ public class ListBase extends SkinnableDataContainer implements IDataProviderEnh
         
         // We want to wait one frame after validation has occured before turning off 
         // selection transitions again.  We tried using dataGroup's updateComplete event listener, 
-        // but because some validateNows() occur (before all of the event handling code has finished), 
-        // this was occuring too early.  We also tried just using callLater or ENTER_FRAME, but that 
-        // occurs before the LayoutManager has run, so we add an ENTER_FRAME handler with a 
+        // but because some validateNow() calls occur (before all of the event handling code has
+        // finished), this was occurring too early.  We also tried just using callLater or ENTER_FRAME,
+        // but that occurs before the LayoutManager has run, so we add an ENTER_FRAME handler with a
         // low priority to make sure it occurs after the LayoutManager pass.
         systemManager.addEventListener(Event.ENTER_FRAME, allowSelectionTransitions_enterFrameHandler, false, -100);
     }