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 2015/03/10 17:43:58 UTC

[01/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 Adding a unit test which verifies that replacements in the HierarchicalCollectionView work as expected in various circumstances, so that a fix for this bug can be made knowing that we're no

Repository: flex-sdk
Updated Branches:
  refs/heads/develop 7cef57b72 -> 410945f0f


FLEX-34778 Adding a unit test which verifies that replacements in the HierarchicalCollectionView work as expected in various circumstances, so that a fix for this bug can be made knowing that we're not breaking something else.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/ab0943c8
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/ab0943c8
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/ab0943c8

Branch: refs/heads/develop
Commit: ab0943c8a61e3ea9a5bdd0bc7a47d846ea7b3705
Parents: 7cef57b
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 12:37:59 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 12:37:59 2015 +0100

----------------------------------------------------------------------
 .../tests/unitTests/mx/collections/DataNode.as  | 107 +++---
 .../HierarchicalCollectionViewTestUtils.as      |   1 +
 ...erarchicalCollectionView_FLEX_34778_Tests.as |  15 +-
 .../HierarchicalCollectionView_REPLACE_Tests.as | 325 +++++++++++++++++++
 4 files changed, 402 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ab0943c8/frameworks/tests/unitTests/mx/collections/DataNode.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/DataNode.as b/frameworks/tests/unitTests/mx/collections/DataNode.as
index aef1829..730825a 100644
--- a/frameworks/tests/unitTests/mx/collections/DataNode.as
+++ b/frameworks/tests/unitTests/mx/collections/DataNode.as
@@ -18,64 +18,83 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 package mx.collections {
-import mx.collections.ArrayCollection;
+    import mx.collections.ArrayCollection;
 
-public class DataNode {
-    private var _label:String;
-    private var _children:ArrayCollection;
-    private var _isSelected:Boolean = false;
-    private var _isPreviousSiblingRemoved:Boolean = false;
+    public class DataNode {
+        private var _label:String;
+        private var _children:ArrayCollection;
+        private var _isSelected:Boolean = false;
+        private var _isPreviousSiblingRemoved:Boolean = false;
+        private var _parent:DataNode;
 
-    public function DataNode(label:String)
-    {
-        _label = label;
-    }
+        public function DataNode(label:String)
+        {
+            _label = label;
+        }
 
-    public function get children():ArrayCollection {
-        return _children;
-    }
+        public function get children():ArrayCollection
+        {
+            return _children;
+        }
 
-    public function set children(value:ArrayCollection):void {
-        _children = value;
-    }
+        public function set children(value:ArrayCollection):void
+        {
+            _children = value;
+        }
 
-    public function get label():String {
-        return _label + (_isSelected ? " [SEL]" : "") + (_isPreviousSiblingRemoved ? " [PREV ITEM REMOVED]" : "");
-    }
+        public function get label():String
+        {
+            return _label + (_isSelected ? " [SEL]" : "") + (_isPreviousSiblingRemoved ? " [PREV ITEM REMOVED]" : "");
+        }
 
-    public function toString():String
-    {
-        return label;
-    }
+        public function toString():String
+        {
+            return label;
+        }
 
-    public function addChild(node:DataNode):void {
-        if(!_children)
-            _children = new ArrayCollection();
+        public function addChild(node:DataNode):void
+        {
+            if(!_children)
+                _children = new ArrayCollection();
 
-        _children.addItem(node);
-    }
+            _children.addItem(node);
+            node.parent = this;
+        }
 
-    public function set isSelected(value:Boolean):void {
-        _isSelected = value;
-    }
+        public function set isSelected(value:Boolean):void
+        {
+            _isSelected = value;
+        }
 
-    public function get isSelected():Boolean {
-        return _isSelected;
-    }
+        public function get isSelected():Boolean
+        {
+            return _isSelected;
+        }
 
-    public function clone():DataNode
-    {
-        var newNode:DataNode = new DataNode(_label);
-        for each(var childNode:DataNode in children)
+        public function clone():DataNode
         {
-            newNode.addChild(childNode.clone());
+            var newNode:DataNode = new DataNode(_label);
+            for each(var childNode:DataNode in children)
+            {
+                newNode.addChild(childNode.clone());
+            }
+
+            return newNode;
         }
 
-        return newNode;
-    }
+        public function set isPreviousSiblingRemoved(value:Boolean):void
+        {
+            _isPreviousSiblingRemoved = value;
+        }
+
+        public function get parent():DataNode
+        {
+            return _parent;
+        }
 
-    public function set isPreviousSiblingRemoved(value:Boolean):void {
-        _isPreviousSiblingRemoved = value;
+        public function set parent(value:DataNode):void
+        {
+            _parent = value;
+        }
     }
 }
-}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ab0943c8/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
index bc1ca36..94b094b 100644
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
@@ -19,6 +19,7 @@
 
 package mx.collections
 {
+    import mx.collections.*;
     import mx.utils.StringUtil;
 	import mx.collections.ArrayCollection;
 	import mx.collections.CursorBookmark;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ab0943c8/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
index 9a85102..f436538 100644
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
@@ -17,8 +17,7 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 
-package mx.collections
-{
+package mx.collections {
     import mx.collections.ArrayCollection;
     import mx.collections.HierarchicalCollectionView;
 
@@ -60,6 +59,18 @@ package mx.collections
             assertEquals(1, _sut.length);
         }
 
+        //this did NOT reproduce it, but it's good to test, because the code is in a different function
+        //(collectionChangeHandler) than the previous case (nestedCollectionChangeHandler).
+        [Test]
+        public function test_replacing_inaccessible_root_node():void
+        {
+            //when
+            _level0.setItemAt(new DataNode("Microsoft"), 0);
+
+            //then
+            assertEquals(1, _sut.length);
+        }
+
         private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
         {
             return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ab0943c8/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
new file mode 100644
index 0000000..c4d49a6
--- /dev/null
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
@@ -0,0 +1,325 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections {
+    import mx.collections.HierarchicalCollectionView;
+    import mx.collections.IList;
+    import mx.events.CollectionEvent;
+    import mx.events.CollectionEventKind;
+    import mx.utils.StringUtil;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertFalse;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertNull;
+    import org.flexunit.asserts.assertTrue;
+
+    public class HierarchicalCollectionView_REPLACE_Tests {
+
+        private static var _sut:HierarchicalCollectionView;
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private var _root:IList;
+        private static var noItemsInHierarchy:int = NaN;
+
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+            const hierarchyLines:Array = HIERARCHY_STRING.split("\n");
+            for(var i:int = 0; i < hierarchyLines.length; i++)
+            {
+                if(StringUtil.trim(hierarchyLines[i]))
+                    noItemsInHierarchy++;
+            }
+        }
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+            _root = _utils.getRoot(_sut) as IList;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+            _root = null;
+        }
+
+        [Test]
+        public function test_make_sure_we_count_nodes_correctly():void
+        {
+            //when
+            var noChildren:int = 0;
+            for(var i:int = 0; i < _root.length; i++)
+            {
+                noChildren += countAllChildrenOf(_root.getItemAt(i) as DataNode);
+            }
+
+            //then
+            assertEquals(noItemsInHierarchy, noChildren);
+        }
+
+        [Test]
+        public function test_make_sure_isDescendantOf_works_correctly():void
+        {
+            //when
+            var region1:DataNode = _root.getItemAt(0) as DataNode;
+            var region2:DataNode = _root.getItemAt(1) as DataNode;
+            var city2:DataNode = region2.children.getItemAt(1) as DataNode;
+            var company2:DataNode = city2.children.getItemAt(1) as DataNode;
+            var department2:DataNode = company2.children.getItemAt(1) as DataNode;
+
+            //then
+            assertTrue(isDescendantOf(department2, company2));
+            assertTrue(isDescendantOf(department2, city2));
+            assertTrue(isDescendantOf(department2, region2));
+            assertFalse(isDescendantOf(department2, region1));
+        }
+
+        [Test]
+        public function test_replacing_a_childless_node_does_not_dispatch_REMOVED_collection_event_but_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                    removeEvent = event;
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
+
+            //WHEN
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 0);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNull(removeEvent); //because the replaced node had no children
+            assertNull(_sut.getParentItem(firstDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+            assertEquals(noItemsInHierarchy, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_a_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                {
+                    removeEvent = event;
+
+                    if(event.items && event.items.length == noChildrenOfSecondDepartment)
+                    {
+                        for(var i:int = 0; i < noChildrenOfSecondDepartment; i++)
+                        {
+                            if(event.items.indexOf(secondDepartment.children.getItemAt(i)) == -1)
+                                REMOVEDEventHasChildrenOfSecondDepartment = false;
+                        }
+                    }
+                }
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+            var REMOVEDEventHasChildrenOfSecondDepartment:Boolean = true;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var secondDepartment:DataNode = departmentsOfCompany2.getItemAt(1) as DataNode;
+            const noChildrenOfSecondDepartment:int = secondDepartment.children.length;
+
+            //WHEN
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 1);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNotNull(removeEvent); //because the replaced node had children
+            assertTrue(REMOVEDEventHasChildrenOfSecondDepartment);
+            assertEquals(-1, removeEvent.items.indexOf(secondDepartment));
+            assertNull(_sut.getParentItem(secondDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+            assertEquals(noItemsInHierarchy - noChildrenOfSecondDepartment, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_a_root_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                {
+                    removeEvent = event;
+                    if(event.items && event.items.length == noChildrenOfSecondRegion)
+                    {
+                        for(var i:int = 0; i < noChildrenOfSecondRegion; i++)
+                        {
+                            if(!isDescendantOf(event.items[1] as DataNode, region2))
+                                REMOVEDEventHasAllChildrenOfSecondRegion = false;
+                        }
+                    }
+                }
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+            var REMOVEDEventHasAllChildrenOfSecondRegion:Boolean = true;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var region2:DataNode = _root.getItemAt(1) as DataNode;
+            var noChildrenOfSecondRegion:int = countAllChildrenOf(region2);
+
+            //WHEN
+            const newRegion:DataNode = new DataNode("Region(X)");
+            _root.setItemAt(newRegion, 1);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNotNull(removeEvent); //because the replaced node had children
+            assertTrue(REMOVEDEventHasAllChildrenOfSecondRegion);
+            assertEquals(-1, removeEvent.items.indexOf(region2));
+            assertNull(_sut.getParentItem(region2));
+            assertEquals(null, _sut.getParentItem(newRegion));
+            assertEquals(noItemsInHierarchy - noChildrenOfSecondRegion + 1, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_inaccessible_node_does_not_dispatch_REMOVED_collection_event_nor_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                    removeEvent = event;
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
+
+            //WHEN
+            _sut.closeNode(_root.getItemAt(1)); //close second region
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 0);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNull(removeEvent); //because the replaced node had no children
+            assertNull(_sut.getParentItem(firstDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+
+            var secondRegion:DataNode = DataNode(_root.getItemAt(1));
+            assertEquals(noItemsInHierarchy - countAllChildrenOf(secondRegion) + 1, _sut.length);
+        }
+
+
+        private function getDirectChildrenOf(...indexesOfSubsequentParents):IList
+        {
+            var currentLevel:IList = _root;
+            var i:int = -1;
+            while(currentLevel && ++i < indexesOfSubsequentParents.length)
+            {
+                var currentParent:DataNode = currentLevel.getItemAt(indexesOfSubsequentParents[i]) as DataNode;
+                currentLevel = currentParent ? currentParent.children : null;
+            }
+
+            return currentLevel;
+        }
+
+        private function isDescendantOf(node:DataNode, potentialAncestor:DataNode):Boolean
+        {
+            if(!potentialAncestor || !node)
+                return false;
+
+            var currentParent:DataNode = node.parent;
+            while(currentParent && currentParent != potentialAncestor)
+            {
+                currentParent = currentParent.parent;
+            }
+
+            return currentParent == potentialAncestor;
+        }
+
+        private function countAllChildrenOf(parent:DataNode):int
+        {
+            if(!parent.children || !parent.children.length)
+                return 1;
+            else
+            {
+                var noChildren:int = 0;
+                for(var i:int = 0; i < parent.children.length; i++)
+                {
+                    noChildren += countAllChildrenOf(parent.children.getItemAt(i) as DataNode);
+                }
+
+                return noChildren + 1;
+            }
+
+            return NaN;
+        }
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+        Region(1)
+        Region(2)
+        Region(2)->City(0)
+        Region(2)->City(1)
+        Region(2)->City(1)->Company(1)
+        Region(2)->City(1)->Company(2)
+        Region(2)->City(1)->Company(2)->Department(1)
+        Region(2)->City(1)->Company(2)->Department(2)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
+        Region(2)->City(1)->Company(2)->Department(3)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
+        Region(2)->City(1)->Company(3)
+        Region(2)->City(1)->Company(3)->Department(1)
+        Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
+        Region(2)->City(1)->Company(3)->Department(2)
+    ]]>).
+        toString();
+    }
+}


[10/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34440 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured

Posted by mi...@apache.org.
FLEX-34440 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured to reflect this.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/5cb1e947
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/5cb1e947
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/5cb1e947

Branch: refs/heads/develop
Commit: 5cb1e947402a44634f4624928f0cb238c3e88b7f
Parents: 01894ff
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 16:53:31 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 16:53:31 2015 +0100

----------------------------------------------------------------------
 ...icalCollectionViewCursor_FLEX_34440_Tests.as | 141 ++++++++++++++++++
 ...hicalCollectionViewCursor_FLEX_34440_Test.as | 146 -------------------
 2 files changed, 141 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/5cb1e947/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Tests.as
new file mode 100644
index 0000000..31ca0d8
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Tests.as
@@ -0,0 +1,141 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+    import mx.core.FlexGlobals;
+
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertTrue;
+
+    import spark.components.Application;
+
+    public class HierarchicalCollectionViewCursor_FLEX_34440_Tests
+	{
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _noErrorsThrown:Boolean = true;
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _sut:HierarchicalCollectionViewCursor;
+        private static var _operationCursor:HierarchicalCollectionViewCursor;
+
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+        }
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+			_currentHierarchy = null;
+			_operationCursor = null;
+		}
+
+       	[Test]
+        public function testReproduce_FLEX_34440():void
+        {
+			//GIVEN
+			var selectedItemIndex:int = 10, operationIndex:int = 5;
+			
+			//WHEN
+			//1. Select a specific node
+			_sut.seek(new CursorBookmark(selectedItemIndex));
+			
+            var selectedNode:DataNode = DataNode(_sut.current);
+            assertNotNull(selectedNode);
+		    selectedNode.isSelected = true;
+
+            //2. Perform setItemAt operation
+			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+			_operationCursor.seek(new CursorBookmark(operationIndex));
+		    performReplacement(_operationCursor);
+
+            //THEN
+            assertTrue(_noErrorsThrown);
+        }
+		
+        private static function performReplacement(where:HierarchicalCollectionViewCursor):void
+        {
+            var itemToBeReplaced:DataNode = where.current as DataNode;
+            assertNotNull(itemToBeReplaced);
+
+            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeReplaced) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var replacedItemIndex:int = collectionToChange.getItemIndex(itemToBeReplaced);
+
+            collectionToChange.setItemAt(_utils.createSimpleNode(itemToBeReplaced.label + " [REPLACED NODE]"), replacedItemIndex);
+        }
+
+
+
+		
+		
+		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n FAIL: " + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+         Region(1)
+         Region(2)
+		 Region(2)->City(0)
+         Region(2)->City(1)
+         Region(2)->City(1)->Company(1)
+         Region(2)->City(1)->Company(2)TBR
+         Region(2)->City(1)->Company(2)TBR->Department(1)
+         Region(2)->City(1)->Company(2)TBR->Department(2)
+         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(1)
+         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(2)
+         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(3)SEL
+         Region(2)->City(1)->Company(2)TBR->Department(3)
+         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(1)
+         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(2)
+         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(3)
+         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(4)
+         Region(2)->City(1)->Company(3)
+         Region(2)->City(1)->Company(3)->Department(1)
+         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(2)
+       ]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/5cb1e947/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Test.as
deleted file mode 100644
index a530195..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34440_Test.as
+++ /dev/null
@@ -1,146 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-import flash.events.UncaughtErrorEvent;
-
-import mx.collections.ArrayCollection;
-import mx.collections.CursorBookmark;
-import mx.collections.HierarchicalCollectionView;
-import mx.collections.HierarchicalCollectionViewCursor;
-import mx.core.FlexGlobals;
-
-import org.flexunit.asserts.assertNotNull;
-import org.flexunit.asserts.assertTrue;
-import org.flexunit.runners.Parameterized;
-
-import spark.components.WindowedApplication;
-
-public class HierarchicalCollectionViewCursor_FLEX_34440_Test
-	{
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _noErrorsThrown:Boolean = true;
-        private static var _currentHierarchy:HierarchicalCollectionView;
-        private static var _sut:HierarchicalCollectionViewCursor;
-        private static var _operationCursor:HierarchicalCollectionViewCursor;
-
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-        }
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-			_currentHierarchy = null;
-			_operationCursor = null;
-		}
-
-       	[Test]
-        public function testReproduce_FLEX_34440():void
-        {
-			//GIVEN
-			var selectedItemIndex:int = 10, operationIndex:int = 5;
-			
-			//WHEN
-			//1. Select a specific node
-			_sut.seek(new CursorBookmark(selectedItemIndex));
-			
-            var selectedNode:DataNode = DataNode(_sut.current);
-            assertNotNull(selectedNode);
-		    selectedNode.isSelected = true;
-
-            //2. Perform setItemAt operation
-			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-			_operationCursor.seek(new CursorBookmark(operationIndex));
-		    performReplacement(_operationCursor);
-
-            //THEN
-            assertTrue(_noErrorsThrown);
-        }
-		
-        private static function performReplacement(where:HierarchicalCollectionViewCursor):void
-        {
-            var itemToBeReplaced:DataNode = where.current as DataNode;
-            assertNotNull(itemToBeReplaced);
-
-            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeReplaced) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var replacedItemIndex:int = collectionToChange.getItemIndex(itemToBeReplaced);
-
-            collectionToChange.setItemAt(_utils.createSimpleNode(itemToBeReplaced.label + " [REPLACED NODE]"), replacedItemIndex);
-        }
-
-
-
-		
-		
-		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n FAIL: " + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-         Region(1)
-         Region(2)
-		 Region(2)->City(0)
-         Region(2)->City(1)
-         Region(2)->City(1)->Company(1)
-         Region(2)->City(1)->Company(2)TBR
-         Region(2)->City(1)->Company(2)TBR->Department(1)
-         Region(2)->City(1)->Company(2)TBR->Department(2)
-         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(1)
-         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(2)
-         Region(2)->City(1)->Company(2)TBR->Department(2)->Employee(3)SEL
-         Region(2)->City(1)->Company(2)TBR->Department(3)
-         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(1)
-         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(2)
-         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(3)
-         Region(2)->City(1)->Company(2)TBR->Department(3)->Employee(4)
-         Region(2)->City(1)->Company(3)
-         Region(2)->City(1)->Company(3)->Department(1)
-         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(2)
-       ]]>).toString();
-	}
-}
\ No newline at end of file


[13/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34775 moved the unit test where it can be run by 'ant test'.

Posted by mi...@apache.org.
FLEX-34775 moved the unit test where it can be run by 'ant test'.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/f7fcf121
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/f7fcf121
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/f7fcf121

Branch: refs/heads/develop
Commit: f7fcf121fc2acebaca725bb5cd28aece8df45a49
Parents: 143a23c
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 17:04:13 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 17:04:13 2015 +0100

----------------------------------------------------------------------
 ...erarchicalCollectionView_FLEX_34775_Tests.as | 149 ++++++++++++++++++
 ...erarchicalCollectionView_FLEX_34775_Tests.as | 150 -------------------
 2 files changed, 149 insertions(+), 150 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f7fcf121/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
new file mode 100644
index 0000000..14bc2a3
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
@@ -0,0 +1,149 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import mx.utils.StringUtil;
+
+    import org.flexunit.asserts.assertEquals;
+
+    public class HierarchicalCollectionView_FLEX_34775_Tests
+    {
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _sut:HierarchicalCollectionView;
+        private var _level0:ArrayCollection;
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = generateHierarchyViewWithClosedNodes();
+            _level0 = _utils.getRoot(_sut) as ArrayCollection;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+            _level0 = null;
+        }
+
+
+
+        [Test]
+        public function test_navigation_after_trying_to_open_inaccessible_node():void
+        {
+            //given
+            var company:DataNode = _level0.getItemAt(0) as DataNode;
+            var location:DataNode = company.children.getItemAt(0) as DataNode;
+
+            //when
+            _sut.openNode(location);
+
+            //then
+            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
+            assertEquals(1, stepsRequiredToNavigateStructure);
+            assertEquals(1, _sut.length);
+        }
+
+        [Test]
+        public function test_navigation_after_trying_to_open_accessible_node():void
+        {
+            //given
+            var company:DataNode = _level0.getItemAt(0) as DataNode;
+            var location:DataNode = company.children.getItemAt(0) as DataNode;
+
+            //when
+            _sut.openNode(company);
+            _sut.openNode(location);
+
+            //then
+            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
+            assertEquals(3, stepsRequiredToNavigateStructure);
+            assertEquals(3, _sut.length);
+        }
+
+        [Test]
+        public function test_navigation_after_trying_to_open_previously_closed_node():void
+        {
+            //given
+            var company:DataNode = _level0.getItemAt(0) as DataNode;
+            var location:DataNode = company.children.getItemAt(0) as DataNode;
+
+            //when
+            _sut.openNode(company);
+            _sut.openNode(location);
+            _sut.closeNode(location);
+
+            //then
+            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
+            assertEquals(2, stepsRequiredToNavigateStructure);
+            assertEquals(2, _sut.length);
+        }
+
+        [Test]
+        public function test_navigation_after_trying_to_open_filtered_out_node():void
+        {
+            function filterOutLocationNode(node:DataNode):Boolean {
+                return node && node.label != locationNodeName;
+            };
+
+            const locationNodeName:String = StringUtil.trim(HIERARCHY_STRING.split("\n")[2]);
+
+            //given
+            var company:DataNode = _level0.getItemAt(0) as DataNode;
+            var location:DataNode = company.children.getItemAt(0) as DataNode;
+            _sut.openNode(company);
+            _sut.openNode(location);
+
+            //when
+            _sut.filterFunction = filterOutLocationNode;
+            _sut.refresh();
+
+            _sut.openNode(location);
+
+            //then
+            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
+            assertEquals(1, stepsRequiredToNavigateStructure);
+            assertEquals(1, _sut.length);
+        }
+
+        private function attemptNavigation(into:HierarchicalCollectionView):int
+        {
+            var cursor:IViewCursor = into.createCursor();
+            var i:int = 0;
+            while(!cursor.afterLast && i++ < 100)
+            {
+                cursor.moveNext();
+            }
+
+            return i;
+        }
+
+        private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
+        {
+            return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+        }
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+        Adobe
+        Adobe->London
+        Adobe->London->FlexDept
+    ]]>).toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f7fcf121/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
deleted file mode 100644
index 2b07605..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
+++ /dev/null
@@ -1,150 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-    import mx.collections.*;
-    import mx.utils.StringUtil;
-
-    import org.flexunit.asserts.assertEquals;
-
-    public class HierarchicalCollectionView_FLEX_34775_Test
-    {
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _sut:HierarchicalCollectionView;
-        private var _level0:ArrayCollection;
-
-        [Before]
-        public function setUp():void
-        {
-            _sut = generateHierarchyViewWithClosedNodes();
-            _level0 = _utils.getRoot(_sut) as ArrayCollection;
-        }
-
-        [After]
-        public function tearDown():void
-        {
-            _sut = null;
-            _level0 = null;
-        }
-
-
-
-        [Test]
-        public function test_navigation_after_trying_to_open_inaccessible_node():void
-        {
-            //given
-            var company:DataNode = _level0.getItemAt(0) as DataNode;
-            var location:DataNode = company.children.getItemAt(0) as DataNode;
-
-            //when
-            _sut.openNode(location);
-
-            //then
-            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
-            assertEquals(1, stepsRequiredToNavigateStructure);
-            assertEquals(1, _sut.length);
-        }
-
-        [Test]
-        public function test_navigation_after_trying_to_open_accessible_node():void
-        {
-            //given
-            var company:DataNode = _level0.getItemAt(0) as DataNode;
-            var location:DataNode = company.children.getItemAt(0) as DataNode;
-
-            //when
-            _sut.openNode(company);
-            _sut.openNode(location);
-
-            //then
-            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
-            assertEquals(3, stepsRequiredToNavigateStructure);
-            assertEquals(3, _sut.length);
-        }
-
-        [Test]
-        public function test_navigation_after_trying_to_open_previously_closed_node():void
-        {
-            //given
-            var company:DataNode = _level0.getItemAt(0) as DataNode;
-            var location:DataNode = company.children.getItemAt(0) as DataNode;
-
-            //when
-            _sut.openNode(company);
-            _sut.openNode(location);
-            _sut.closeNode(location);
-
-            //then
-            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
-            assertEquals(2, stepsRequiredToNavigateStructure);
-            assertEquals(2, _sut.length);
-        }
-
-        [Test]
-        public function test_navigation_after_trying_to_open_filtered_out_node():void
-        {
-            function filterOutLocationNode(node:DataNode):Boolean {
-                return node && node.label != locationNodeName;
-            };
-
-            const locationNodeName:String = StringUtil.trim(HIERARCHY_STRING.split("\n")[2]);
-
-            //given
-            var company:DataNode = _level0.getItemAt(0) as DataNode;
-            var location:DataNode = company.children.getItemAt(0) as DataNode;
-            _sut.openNode(company);
-            _sut.openNode(location);
-
-            //when
-            _sut.filterFunction = filterOutLocationNode;
-            _sut.refresh();
-
-            _sut.openNode(location);
-
-            //then
-            var stepsRequiredToNavigateStructure:int = attemptNavigation(_sut);
-            assertEquals(1, stepsRequiredToNavigateStructure);
-            assertEquals(1, _sut.length);
-        }
-
-        private function attemptNavigation(into:HierarchicalCollectionView):int
-        {
-            var cursor:IViewCursor = into.createCursor();
-            var i:int = 0;
-            while(!cursor.afterLast && i++ < 100)
-            {
-                cursor.moveNext();
-            }
-
-            return i;
-        }
-
-        private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
-        {
-            return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-        }
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-                Adobe
-        Adobe->London
-        Adobe->London->FlexDept
-    ]]>).toString();
-    }
-}
\ No newline at end of file


[03/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 running the unit tests as part of 'ant test' now, which implied moving them to frameworks/projects/advancedgrids/tests and changing the build scripts to allow test execution in the advanced

Posted by mi...@apache.org.
FLEX-34778 running the unit tests as part of 'ant test' now, which implied moving them to frameworks/projects/advancedgrids/tests and changing the build scripts to allow test execution in the advancedgrids project.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/a60c03e6
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/a60c03e6
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/a60c03e6

Branch: refs/heads/develop
Commit: a60c03e69fdd6cd5717c20d999ad7b872ad6db3d
Parents: 32f3950
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 13:17:53 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 13:17:53 2015 +0100

----------------------------------------------------------------------
 frameworks/build.xml                            |   4 +
 frameworks/projects/advancedgrids/build.xml     |   6 +
 .../tests/mx/collections/DataNode.as            | 100 +++++++++
 .../HierarchicalCollectionViewTestUtils.as      | 203 +++++++++++++++++++
 ...erarchicalCollectionView_FLEX_34778_Tests.as |  85 ++++++++
 .../tests/unitTests/mx/collections/DataNode.as  | 100 ---------
 .../HierarchicalCollectionViewTestUtils.as      | 203 -------------------
 ...erarchicalCollectionView_FLEX_34778_Tests.as |  85 --------
 8 files changed, 398 insertions(+), 388 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/build.xml b/frameworks/build.xml
index 14f5628..4df80d8 100644
--- a/frameworks/build.xml
+++ b/frameworks/build.xml
@@ -140,6 +140,7 @@
 
         <antcall target="apache-test"/>
         <antcall target="spark-test"/>
+        <antcall target="advancedgrids-test"/>
     </target>
 
 	<target name="flex-config" depends="playerglobal-setswfversion" description="Copy the flex/air/airmobile config templates to flex/air/airmobile-config.xml and inject version numbers">
@@ -519,6 +520,9 @@
     <target name="spark-test" description="Tests for 'spark' project">
         <ant dir="${basedir}/projects/spark" target="test"/>
     </target>
+    <target name="advancedgrids-test" description="Tests for 'advancedgrids' project">
+        <ant dir="${basedir}/projects/advancedgrids" target="test"/>
+    </target>
 
     <target name="experimental" description="Clean build of experimental.swc">
         <ant dir="${basedir}/projects/experimental"/>

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/projects/advancedgrids/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/build.xml b/frameworks/projects/advancedgrids/build.xml
index e730bc8..f9fa5c0 100644
--- a/frameworks/projects/advancedgrids/build.xml
+++ b/frameworks/projects/advancedgrids/build.xml
@@ -235,4 +235,10 @@
 		<delete dir="${FLEX_HOME}/tempDoc" failonerror="false" includeEmptyDirs="true"/>
 		<delete file="${basedir}/bundles/en_US/packages.dita" failonerror="false"/>
 	</target>
+
+    <target name="test" description="Runs the FlexUnit tests for this project">
+        <ant antfile="${FLEX_HOME}/flexunit-tests.xml">
+            <property name="project.root" value="${basedir}"/>
+        </ant>
+    </target>
 </project>

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/projects/advancedgrids/tests/mx/collections/DataNode.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/DataNode.as b/frameworks/projects/advancedgrids/tests/mx/collections/DataNode.as
new file mode 100644
index 0000000..730825a
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/DataNode.as
@@ -0,0 +1,100 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections {
+    import mx.collections.ArrayCollection;
+
+    public class DataNode {
+        private var _label:String;
+        private var _children:ArrayCollection;
+        private var _isSelected:Boolean = false;
+        private var _isPreviousSiblingRemoved:Boolean = false;
+        private var _parent:DataNode;
+
+        public function DataNode(label:String)
+        {
+            _label = label;
+        }
+
+        public function get children():ArrayCollection
+        {
+            return _children;
+        }
+
+        public function set children(value:ArrayCollection):void
+        {
+            _children = value;
+        }
+
+        public function get label():String
+        {
+            return _label + (_isSelected ? " [SEL]" : "") + (_isPreviousSiblingRemoved ? " [PREV ITEM REMOVED]" : "");
+        }
+
+        public function toString():String
+        {
+            return label;
+        }
+
+        public function addChild(node:DataNode):void
+        {
+            if(!_children)
+                _children = new ArrayCollection();
+
+            _children.addItem(node);
+            node.parent = this;
+        }
+
+        public function set isSelected(value:Boolean):void
+        {
+            _isSelected = value;
+        }
+
+        public function get isSelected():Boolean
+        {
+            return _isSelected;
+        }
+
+        public function clone():DataNode
+        {
+            var newNode:DataNode = new DataNode(_label);
+            for each(var childNode:DataNode in children)
+            {
+                newNode.addChild(childNode.clone());
+            }
+
+            return newNode;
+        }
+
+        public function set isPreviousSiblingRemoved(value:Boolean):void
+        {
+            _isPreviousSiblingRemoved = value;
+        }
+
+        public function get parent():DataNode
+        {
+            return _parent;
+        }
+
+        public function set parent(value:DataNode):void
+        {
+            _parent = value;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewTestUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewTestUtils.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewTestUtils.as
new file mode 100644
index 0000000..94b094b
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewTestUtils.as
@@ -0,0 +1,203 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import mx.collections.*;
+    import mx.utils.StringUtil;
+	import mx.collections.ArrayCollection;
+	import mx.collections.CursorBookmark;
+	import mx.collections.HierarchicalCollectionView;
+	import mx.collections.HierarchicalCollectionViewCursor;
+	import mx.collections.HierarchicalData;
+	import mx.collections.IViewCursor;
+	import mx.utils.UIDUtil;
+
+	public class HierarchicalCollectionViewTestUtils
+	{
+		//assumes the root is an ArrayCollection of DataNodes
+		private var _allNodes:Object = {};
+		
+		public function clone(hcv:HierarchicalCollectionView):HierarchicalCollectionView
+		{
+			var oldRoot:ArrayCollection = ArrayCollection(getRoot(hcv));
+			var newRoot:ArrayCollection = new ArrayCollection();
+			
+			for each(var rootNode:DataNode in oldRoot)
+			{
+				newRoot.addItem(rootNode.clone());
+			}
+			
+			return generateHCV(newRoot);
+		}
+		
+		public function createNodes(level:String, no:int):ArrayCollection
+		{
+			var nodes:ArrayCollection = new ArrayCollection();
+			for(var i:int = 0; i < no; i++)
+			{
+				nodes.addItem(createSimpleNode(level));
+			}
+			
+			return nodes;
+		}
+		
+		public function generateOpenHierarchyFromRootList(root:ArrayCollection):HierarchicalCollectionView
+		{
+			var hcv:HierarchicalCollectionView = generateHCV(root, false);
+			openAllNodes(hcv);
+			return hcv;
+		}
+
+        public function generateOpenHierarchyFromRootListWithAllNodesMethod(root:ArrayCollection):HierarchicalCollectionView
+        {
+            var hcv:HierarchicalCollectionView = generateHCV(root, true);
+            return hcv;
+        }
+		
+		public function generateHCV(rootCollection:ArrayCollection, useAllNodes:Boolean = false):HierarchicalCollectionView
+		{
+			return new HierarchicalCollectionView(new HierarchicalData(rootCollection), useAllNodes ? _allNodes : null);
+		}
+		
+		public function openAllNodes(hcv:HierarchicalCollectionView):void
+		{
+			var cursor:HierarchicalCollectionViewCursor = hcv.createCursor() as HierarchicalCollectionViewCursor;
+			while(!cursor.afterLast)
+			{
+				hcv.openNode(cursor.current);
+				cursor.moveNext();
+			}
+		}
+		
+		public function getRoot(hcv:HierarchicalCollectionView):Object
+		{
+			return hcv.source.getRoot();
+		}
+		
+		public function printHCollectionView(hcv:HierarchicalCollectionView):void
+		{
+			trace("");
+			var cursor:HierarchicalCollectionViewCursor = hcv.createCursor() as HierarchicalCollectionViewCursor;
+			while(!cursor.afterLast)
+			{
+				trace(DataNode(cursor.current).label);
+				cursor.moveNext();
+			}
+		}
+
+        public function createSimpleNode(label:String):DataNode
+		{
+			var node:DataNode = new DataNode(label);
+			_allNodes[UIDUtil.getUID(node)] = node;
+            return node;
+        }
+
+        public function isAncestor(node:DataNode, forNode:DataNode, hcv:HierarchicalCollectionView):Boolean
+        {
+            do
+            {
+                forNode = hcv.getParentItem(forNode) as DataNode;
+            } while(forNode && forNode != node)
+
+            return forNode == node;
+        }
+		
+		public function nodesHaveCommonAncestor(node:DataNode, withNode:DataNode, hcv:HierarchicalCollectionView):Boolean
+		{
+			var nodeAndAncestors:Array = [node].concat(getNodeAncestors(node, hcv));
+			var otherNodeAndAncestors:Array = [withNode].concat(getNodeAncestors(withNode, hcv));
+			for each(var ancestor:DataNode in nodeAndAncestors)
+				if(otherNodeAndAncestors.indexOf(ancestor) != -1)
+					return true;
+				
+			return false;
+		}
+		
+		public function getNodeAncestors(node:DataNode, hcv:HierarchicalCollectionView):Array
+		{
+			var nodeParents:Array = [];
+			
+			// Make a list of parents of the node.
+			var parent:Object = hcv.getParentItem(node);
+			while (parent)
+			{
+				nodeParents.push(parent);
+				parent = hcv.getParentItem(parent);
+			}
+			
+			return nodeParents;
+		}
+		
+		public function navigateToItem(cursor:IViewCursor, item:DataNode):IViewCursor
+		{
+			while(!cursor.afterLast && cursor.current != item)
+			{
+				cursor.moveNext();
+			}
+			
+			return cursor;
+		}
+		
+		public function generateHierarchySourceFromString(source:String):ArrayCollection
+		{
+			var rootCollection:ArrayCollection = new ArrayCollection();
+			var alreadyCreatedNodes:Array = [];
+			var node:DataNode;
+			
+			var lines:Array = source.split("\n");
+			for each(var line:String in lines)
+			{
+				if(!line)
+					continue;
+				
+				var currentLabel:String = "";
+				var previousNode:DataNode = null;
+				var nodesOnThisLine:Array = StringUtil.trim(line).split("->");
+				for each(var nodeName:String in nodesOnThisLine)
+				{
+					if(!nodeName)
+						continue;
+					
+					currentLabel += currentLabel ? "->" + nodeName : nodeName;
+					
+					var nodeAlreadyCreated:Boolean = alreadyCreatedNodes[currentLabel] != undefined;
+					
+					if(nodeAlreadyCreated)
+						node = alreadyCreatedNodes[currentLabel];
+					else {
+						node = createSimpleNode(currentLabel);
+						alreadyCreatedNodes[currentLabel] = node;
+					}
+					
+					if(!nodeAlreadyCreated) {
+						if (previousNode)
+							previousNode.addChild(node);
+						else
+							rootCollection.addItem(node);
+					}
+					
+					previousNode = node;
+				}
+			}
+			
+			return rootCollection;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
new file mode 100644
index 0000000..f436538
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
@@ -0,0 +1,85 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections {
+    import mx.collections.ArrayCollection;
+    import mx.collections.HierarchicalCollectionView;
+
+    import org.flexunit.asserts.assertEquals;
+
+    public class HierarchicalCollectionView_FLEX_34778_Tests
+    {
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _sut:HierarchicalCollectionView;
+        private var _level0:ArrayCollection;
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = generateHierarchyViewWithClosedNodes();
+            _level0 = _utils.getRoot(_sut) as ArrayCollection;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+            _level0 = null;
+        }
+
+
+        [Test]
+        public function test_replacing_inaccessible_node():void
+        {
+            //given
+            var company:DataNode = _level0.getItemAt(0) as DataNode;
+
+            //when
+            _sut.openNode(company); //so that it starts listening to collection change events on its children
+            _sut.closeNode(company);
+            company.children.setItemAt(new DataNode("Adobe->Brussels"), 0); //makes the app hang here
+
+            //then
+            assertEquals(1, _sut.length);
+        }
+
+        //this did NOT reproduce it, but it's good to test, because the code is in a different function
+        //(collectionChangeHandler) than the previous case (nestedCollectionChangeHandler).
+        [Test]
+        public function test_replacing_inaccessible_root_node():void
+        {
+            //when
+            _level0.setItemAt(new DataNode("Microsoft"), 0);
+
+            //then
+            assertEquals(1, _sut.length);
+        }
+
+        private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
+        {
+            return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+        }
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+        Adobe
+        Adobe->London
+        Adobe->London->FlexDept
+    ]]>).toString();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/tests/unitTests/mx/collections/DataNode.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/DataNode.as b/frameworks/tests/unitTests/mx/collections/DataNode.as
deleted file mode 100644
index 730825a..0000000
--- a/frameworks/tests/unitTests/mx/collections/DataNode.as
+++ /dev/null
@@ -1,100 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections {
-    import mx.collections.ArrayCollection;
-
-    public class DataNode {
-        private var _label:String;
-        private var _children:ArrayCollection;
-        private var _isSelected:Boolean = false;
-        private var _isPreviousSiblingRemoved:Boolean = false;
-        private var _parent:DataNode;
-
-        public function DataNode(label:String)
-        {
-            _label = label;
-        }
-
-        public function get children():ArrayCollection
-        {
-            return _children;
-        }
-
-        public function set children(value:ArrayCollection):void
-        {
-            _children = value;
-        }
-
-        public function get label():String
-        {
-            return _label + (_isSelected ? " [SEL]" : "") + (_isPreviousSiblingRemoved ? " [PREV ITEM REMOVED]" : "");
-        }
-
-        public function toString():String
-        {
-            return label;
-        }
-
-        public function addChild(node:DataNode):void
-        {
-            if(!_children)
-                _children = new ArrayCollection();
-
-            _children.addItem(node);
-            node.parent = this;
-        }
-
-        public function set isSelected(value:Boolean):void
-        {
-            _isSelected = value;
-        }
-
-        public function get isSelected():Boolean
-        {
-            return _isSelected;
-        }
-
-        public function clone():DataNode
-        {
-            var newNode:DataNode = new DataNode(_label);
-            for each(var childNode:DataNode in children)
-            {
-                newNode.addChild(childNode.clone());
-            }
-
-            return newNode;
-        }
-
-        public function set isPreviousSiblingRemoved(value:Boolean):void
-        {
-            _isPreviousSiblingRemoved = value;
-        }
-
-        public function get parent():DataNode
-        {
-            return _parent;
-        }
-
-        public function set parent(value:DataNode):void
-        {
-            _parent = value;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
deleted file mode 100644
index 94b094b..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewTestUtils.as
+++ /dev/null
@@ -1,203 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-    import mx.collections.*;
-    import mx.utils.StringUtil;
-	import mx.collections.ArrayCollection;
-	import mx.collections.CursorBookmark;
-	import mx.collections.HierarchicalCollectionView;
-	import mx.collections.HierarchicalCollectionViewCursor;
-	import mx.collections.HierarchicalData;
-	import mx.collections.IViewCursor;
-	import mx.utils.UIDUtil;
-
-	public class HierarchicalCollectionViewTestUtils
-	{
-		//assumes the root is an ArrayCollection of DataNodes
-		private var _allNodes:Object = {};
-		
-		public function clone(hcv:HierarchicalCollectionView):HierarchicalCollectionView
-		{
-			var oldRoot:ArrayCollection = ArrayCollection(getRoot(hcv));
-			var newRoot:ArrayCollection = new ArrayCollection();
-			
-			for each(var rootNode:DataNode in oldRoot)
-			{
-				newRoot.addItem(rootNode.clone());
-			}
-			
-			return generateHCV(newRoot);
-		}
-		
-		public function createNodes(level:String, no:int):ArrayCollection
-		{
-			var nodes:ArrayCollection = new ArrayCollection();
-			for(var i:int = 0; i < no; i++)
-			{
-				nodes.addItem(createSimpleNode(level));
-			}
-			
-			return nodes;
-		}
-		
-		public function generateOpenHierarchyFromRootList(root:ArrayCollection):HierarchicalCollectionView
-		{
-			var hcv:HierarchicalCollectionView = generateHCV(root, false);
-			openAllNodes(hcv);
-			return hcv;
-		}
-
-        public function generateOpenHierarchyFromRootListWithAllNodesMethod(root:ArrayCollection):HierarchicalCollectionView
-        {
-            var hcv:HierarchicalCollectionView = generateHCV(root, true);
-            return hcv;
-        }
-		
-		public function generateHCV(rootCollection:ArrayCollection, useAllNodes:Boolean = false):HierarchicalCollectionView
-		{
-			return new HierarchicalCollectionView(new HierarchicalData(rootCollection), useAllNodes ? _allNodes : null);
-		}
-		
-		public function openAllNodes(hcv:HierarchicalCollectionView):void
-		{
-			var cursor:HierarchicalCollectionViewCursor = hcv.createCursor() as HierarchicalCollectionViewCursor;
-			while(!cursor.afterLast)
-			{
-				hcv.openNode(cursor.current);
-				cursor.moveNext();
-			}
-		}
-		
-		public function getRoot(hcv:HierarchicalCollectionView):Object
-		{
-			return hcv.source.getRoot();
-		}
-		
-		public function printHCollectionView(hcv:HierarchicalCollectionView):void
-		{
-			trace("");
-			var cursor:HierarchicalCollectionViewCursor = hcv.createCursor() as HierarchicalCollectionViewCursor;
-			while(!cursor.afterLast)
-			{
-				trace(DataNode(cursor.current).label);
-				cursor.moveNext();
-			}
-		}
-
-        public function createSimpleNode(label:String):DataNode
-		{
-			var node:DataNode = new DataNode(label);
-			_allNodes[UIDUtil.getUID(node)] = node;
-            return node;
-        }
-
-        public function isAncestor(node:DataNode, forNode:DataNode, hcv:HierarchicalCollectionView):Boolean
-        {
-            do
-            {
-                forNode = hcv.getParentItem(forNode) as DataNode;
-            } while(forNode && forNode != node)
-
-            return forNode == node;
-        }
-		
-		public function nodesHaveCommonAncestor(node:DataNode, withNode:DataNode, hcv:HierarchicalCollectionView):Boolean
-		{
-			var nodeAndAncestors:Array = [node].concat(getNodeAncestors(node, hcv));
-			var otherNodeAndAncestors:Array = [withNode].concat(getNodeAncestors(withNode, hcv));
-			for each(var ancestor:DataNode in nodeAndAncestors)
-				if(otherNodeAndAncestors.indexOf(ancestor) != -1)
-					return true;
-				
-			return false;
-		}
-		
-		public function getNodeAncestors(node:DataNode, hcv:HierarchicalCollectionView):Array
-		{
-			var nodeParents:Array = [];
-			
-			// Make a list of parents of the node.
-			var parent:Object = hcv.getParentItem(node);
-			while (parent)
-			{
-				nodeParents.push(parent);
-				parent = hcv.getParentItem(parent);
-			}
-			
-			return nodeParents;
-		}
-		
-		public function navigateToItem(cursor:IViewCursor, item:DataNode):IViewCursor
-		{
-			while(!cursor.afterLast && cursor.current != item)
-			{
-				cursor.moveNext();
-			}
-			
-			return cursor;
-		}
-		
-		public function generateHierarchySourceFromString(source:String):ArrayCollection
-		{
-			var rootCollection:ArrayCollection = new ArrayCollection();
-			var alreadyCreatedNodes:Array = [];
-			var node:DataNode;
-			
-			var lines:Array = source.split("\n");
-			for each(var line:String in lines)
-			{
-				if(!line)
-					continue;
-				
-				var currentLabel:String = "";
-				var previousNode:DataNode = null;
-				var nodesOnThisLine:Array = StringUtil.trim(line).split("->");
-				for each(var nodeName:String in nodesOnThisLine)
-				{
-					if(!nodeName)
-						continue;
-					
-					currentLabel += currentLabel ? "->" + nodeName : nodeName;
-					
-					var nodeAlreadyCreated:Boolean = alreadyCreatedNodes[currentLabel] != undefined;
-					
-					if(nodeAlreadyCreated)
-						node = alreadyCreatedNodes[currentLabel];
-					else {
-						node = createSimpleNode(currentLabel);
-						alreadyCreatedNodes[currentLabel] = node;
-					}
-					
-					if(!nodeAlreadyCreated) {
-						if (previousNode)
-							previousNode.addChild(node);
-						else
-							rootCollection.addItem(node);
-					}
-					
-					previousNode = node;
-				}
-			}
-			
-			return rootCollection;
-		}
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/a60c03e6/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
deleted file mode 100644
index f436538..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34778_Tests.as
+++ /dev/null
@@ -1,85 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections {
-    import mx.collections.ArrayCollection;
-    import mx.collections.HierarchicalCollectionView;
-
-    import org.flexunit.asserts.assertEquals;
-
-    public class HierarchicalCollectionView_FLEX_34778_Tests
-    {
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _sut:HierarchicalCollectionView;
-        private var _level0:ArrayCollection;
-
-        [Before]
-        public function setUp():void
-        {
-            _sut = generateHierarchyViewWithClosedNodes();
-            _level0 = _utils.getRoot(_sut) as ArrayCollection;
-        }
-
-        [After]
-        public function tearDown():void
-        {
-            _sut = null;
-            _level0 = null;
-        }
-
-
-        [Test]
-        public function test_replacing_inaccessible_node():void
-        {
-            //given
-            var company:DataNode = _level0.getItemAt(0) as DataNode;
-
-            //when
-            _sut.openNode(company); //so that it starts listening to collection change events on its children
-            _sut.closeNode(company);
-            company.children.setItemAt(new DataNode("Adobe->Brussels"), 0); //makes the app hang here
-
-            //then
-            assertEquals(1, _sut.length);
-        }
-
-        //this did NOT reproduce it, but it's good to test, because the code is in a different function
-        //(collectionChangeHandler) than the previous case (nestedCollectionChangeHandler).
-        [Test]
-        public function test_replacing_inaccessible_root_node():void
-        {
-            //when
-            _level0.setItemAt(new DataNode("Microsoft"), 0);
-
-            //then
-            assertEquals(1, _sut.length);
-        }
-
-        private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
-        {
-            return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-        }
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-        Adobe
-        Adobe->London
-        Adobe->London->FlexDept
-    ]]>).toString();
-    }
-}
\ No newline at end of file


[04/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34119 moving the unit test to where it can be executed part of 'ant test'

Posted by mi...@apache.org.
FLEX-34119 moving the unit test to where it can be executed part of 'ant test'


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/4cb597a0
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/4cb597a0
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/4cb597a0

Branch: refs/heads/develop
Commit: 4cb597a07025bd5b028e1e718f9e60c14f370abc
Parents: a60c03e
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 13:22:56 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 13:22:56 2015 +0100

----------------------------------------------------------------------
 ...rarchicalCollectionViewCursor_Basics_Test.as | 262 +++++++++++++++++++
 ...rarchicalCollectionViewCursor_Basics_Test.as | 262 -------------------
 2 files changed, 262 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4cb597a0/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
new file mode 100644
index 0000000..c2bd0cb
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
@@ -0,0 +1,262 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+import flashx.textLayout.debug.assert;
+
+import mx.collections.ArrayCollection;
+    import mx.collections.CursorBookmark;
+    import mx.collections.HierarchicalCollectionView;
+    import mx.collections.HierarchicalCollectionViewCursor;
+    import mx.core.FlexGlobals;
+    
+    import spark.components.WindowedApplication;
+    
+    import org.flexunit.asserts.assertEquals;
+
+    public class HierarchicalCollectionViewCursor_Basics_Test
+	{
+		private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+		private static var _currentHierarchy:HierarchicalCollectionView;
+		private static var _noErrorsThrown:Boolean = true;
+		private var _level0:ArrayCollection;
+		
+		private var _sut:HierarchicalCollectionViewCursor;
+		
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is WindowedApplication)
+			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+		}
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is WindowedApplication)
+			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+            _currentHierarchy = generateHierarchyViewWithOpenNodes();
+            _level0 = _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            _sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+
+			_noErrorsThrown = true;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+            _currentHierarchy = null;
+            _level0 = null;
+		}
+
+
+
+        [Test]
+        public function testMovingAround():void
+        {
+            //given
+            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var firstDepartment:DataNode = firstLocation.children.getItemAt(0) as DataNode;
+            var secondDepartment:DataNode = firstLocation.children.getItemAt(1) as DataNode;
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(firstDepartment, _sut.current);
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(secondDepartment, _sut.current);
+
+            //when
+            _sut.movePrevious();
+
+            //then
+            assertEquals(firstDepartment, _sut.current);
+
+            //when
+            _sut.moveToLast();
+
+            //then
+            assertEquals(lastCompany, _sut.current);
+
+            //when
+            _sut.seek(new CursorBookmark(4));
+
+            //then
+            assertEquals(secondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testCollectionChangeInRootDoesNotChangeCurrent():void
+        {
+            //given
+            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
+
+            //when
+            _sut.moveToLast();
+
+            var newFirstCompany:DataNode = _utils.createSimpleNode("[INS] Company");
+            _level0.addItemAt(newFirstCompany, 0);
+
+            var newLastCompany:DataNode = _utils.createSimpleNode("[INS] Company");
+            _level0.addItemAt(newLastCompany, _level0.length);
+
+            //then
+            assertEquals(lastCompany, _sut.current);
+
+            //when
+            _sut.moveToLast();
+
+            //then
+            assertEquals(newLastCompany, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingCurrentMiddleItemChangesCurrentToNextItem():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var thirdDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(2) as DataNode;
+
+            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
+
+            //when
+            secondLocation.children.removeItemAt(1);
+
+            //then
+            assertEquals(thirdDepartmentOfSecondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingPreviousSiblingOfCurrentMiddleItemDoesNotChangeCurrent():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var secondDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(1) as DataNode;
+
+            //when
+            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
+
+            //then
+            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
+
+            //when
+            secondLocation.children.removeItemAt(0);
+
+            //then
+            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingCurrentFirstItemChangesCurrentToNextItem():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondCompany:DataNode = _level0.getItemAt(1) as DataNode;
+
+            //initial assumption
+            assertEquals(firstCompany, _sut.current);
+
+            //when
+            _level0.removeItemAt(0);
+
+            //then
+            assertEquals(secondCompany, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingSiblingOfCurrentFirstItemDoesNotChangeCurrent():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
+
+            //when
+            _sut.seek(new CursorBookmark(1)); //Company(1)->Location(1)
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+
+            //when
+            firstCompany.children.removeItemAt(1);
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+        }
+		
+		
+		private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n" + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+		
+		private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
+		{
+			return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+		}
+
+		private static const HIERARCHY_STRING:String = (<![CDATA[
+			Company(1)
+			Company(1)->Location(1)
+			Company(1)->Location(1)->Department(1)
+			Company(1)->Location(1)->Department(2)
+			Company(1)->Location(2)
+			Company(1)->Location(2)->Department(1)
+			Company(1)->Location(2)->Department(2)
+			Company(1)->Location(2)->Department(3)
+			Company(1)->Location(3)
+			Company(2)
+			Company(2)->Location(1)
+			Company(2)->Location(2)
+			Company(2)->Location(2)->Department(1)
+			Company(2)->Location(3)
+			Company(3)
+		]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4cb597a0/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
deleted file mode 100644
index c2bd0cb..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
+++ /dev/null
@@ -1,262 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-    import flash.events.UncaughtErrorEvent;
-
-import flashx.textLayout.debug.assert;
-
-import mx.collections.ArrayCollection;
-    import mx.collections.CursorBookmark;
-    import mx.collections.HierarchicalCollectionView;
-    import mx.collections.HierarchicalCollectionViewCursor;
-    import mx.core.FlexGlobals;
-    
-    import spark.components.WindowedApplication;
-    
-    import org.flexunit.asserts.assertEquals;
-
-    public class HierarchicalCollectionViewCursor_Basics_Test
-	{
-		private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-		private static var _currentHierarchy:HierarchicalCollectionView;
-		private static var _noErrorsThrown:Boolean = true;
-		private var _level0:ArrayCollection;
-		
-		private var _sut:HierarchicalCollectionViewCursor;
-		
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-            _currentHierarchy = generateHierarchyViewWithOpenNodes();
-            _level0 = _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            _sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-
-			_noErrorsThrown = true;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-            _currentHierarchy = null;
-            _level0 = null;
-		}
-
-
-
-        [Test]
-        public function testMovingAround():void
-        {
-            //given
-            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var firstDepartment:DataNode = firstLocation.children.getItemAt(0) as DataNode;
-            var secondDepartment:DataNode = firstLocation.children.getItemAt(1) as DataNode;
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(firstDepartment, _sut.current);
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(secondDepartment, _sut.current);
-
-            //when
-            _sut.movePrevious();
-
-            //then
-            assertEquals(firstDepartment, _sut.current);
-
-            //when
-            _sut.moveToLast();
-
-            //then
-            assertEquals(lastCompany, _sut.current);
-
-            //when
-            _sut.seek(new CursorBookmark(4));
-
-            //then
-            assertEquals(secondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testCollectionChangeInRootDoesNotChangeCurrent():void
-        {
-            //given
-            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
-
-            //when
-            _sut.moveToLast();
-
-            var newFirstCompany:DataNode = _utils.createSimpleNode("[INS] Company");
-            _level0.addItemAt(newFirstCompany, 0);
-
-            var newLastCompany:DataNode = _utils.createSimpleNode("[INS] Company");
-            _level0.addItemAt(newLastCompany, _level0.length);
-
-            //then
-            assertEquals(lastCompany, _sut.current);
-
-            //when
-            _sut.moveToLast();
-
-            //then
-            assertEquals(newLastCompany, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingCurrentMiddleItemChangesCurrentToNextItem():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var thirdDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(2) as DataNode;
-
-            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
-
-            //when
-            secondLocation.children.removeItemAt(1);
-
-            //then
-            assertEquals(thirdDepartmentOfSecondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingPreviousSiblingOfCurrentMiddleItemDoesNotChangeCurrent():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var secondDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(1) as DataNode;
-
-            //when
-            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
-
-            //then
-            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
-
-            //when
-            secondLocation.children.removeItemAt(0);
-
-            //then
-            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingCurrentFirstItemChangesCurrentToNextItem():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondCompany:DataNode = _level0.getItemAt(1) as DataNode;
-
-            //initial assumption
-            assertEquals(firstCompany, _sut.current);
-
-            //when
-            _level0.removeItemAt(0);
-
-            //then
-            assertEquals(secondCompany, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingSiblingOfCurrentFirstItemDoesNotChangeCurrent():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
-
-            //when
-            _sut.seek(new CursorBookmark(1)); //Company(1)->Location(1)
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-
-            //when
-            firstCompany.children.removeItemAt(1);
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-        }
-		
-		
-		private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n" + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-		
-		private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
-		{
-			return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-		}
-
-		private static const HIERARCHY_STRING:String = (<![CDATA[
-			Company(1)
-			Company(1)->Location(1)
-			Company(1)->Location(1)->Department(1)
-			Company(1)->Location(1)->Department(2)
-			Company(1)->Location(2)
-			Company(1)->Location(2)->Department(1)
-			Company(1)->Location(2)->Department(2)
-			Company(1)->Location(2)->Department(3)
-			Company(1)->Location(3)
-			Company(2)
-			Company(2)->Location(1)
-			Company(2)->Location(2)
-			Company(2)->Location(2)->Department(1)
-			Company(2)->Location(3)
-			Company(3)
-		]]>).toString();
-	}
-}
\ No newline at end of file


[07/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 moved the test to where it can be executed via 'ant test'

Posted by mi...@apache.org.
FLEX-34778 moved the test to where it can be executed via 'ant test'


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/6ffb7ff3
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/6ffb7ff3
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/6ffb7ff3

Branch: refs/heads/develop
Commit: 6ffb7ff36479d428cb2aa314200e2c270b318c0c
Parents: 3e27fad
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 15:56:27 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 15:56:27 2015 +0100

----------------------------------------------------------------------
 .../HierarchicalCollectionView_REPLACE_Tests.as | 325 +++++++++++++++++++
 .../HierarchicalCollectionView_REPLACE_Tests.as | 325 -------------------
 2 files changed, 325 insertions(+), 325 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6ffb7ff3/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
new file mode 100644
index 0000000..c4d49a6
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
@@ -0,0 +1,325 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections {
+    import mx.collections.HierarchicalCollectionView;
+    import mx.collections.IList;
+    import mx.events.CollectionEvent;
+    import mx.events.CollectionEventKind;
+    import mx.utils.StringUtil;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertFalse;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertNull;
+    import org.flexunit.asserts.assertTrue;
+
+    public class HierarchicalCollectionView_REPLACE_Tests {
+
+        private static var _sut:HierarchicalCollectionView;
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private var _root:IList;
+        private static var noItemsInHierarchy:int = NaN;
+
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+            const hierarchyLines:Array = HIERARCHY_STRING.split("\n");
+            for(var i:int = 0; i < hierarchyLines.length; i++)
+            {
+                if(StringUtil.trim(hierarchyLines[i]))
+                    noItemsInHierarchy++;
+            }
+        }
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+            _root = _utils.getRoot(_sut) as IList;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+            _root = null;
+        }
+
+        [Test]
+        public function test_make_sure_we_count_nodes_correctly():void
+        {
+            //when
+            var noChildren:int = 0;
+            for(var i:int = 0; i < _root.length; i++)
+            {
+                noChildren += countAllChildrenOf(_root.getItemAt(i) as DataNode);
+            }
+
+            //then
+            assertEquals(noItemsInHierarchy, noChildren);
+        }
+
+        [Test]
+        public function test_make_sure_isDescendantOf_works_correctly():void
+        {
+            //when
+            var region1:DataNode = _root.getItemAt(0) as DataNode;
+            var region2:DataNode = _root.getItemAt(1) as DataNode;
+            var city2:DataNode = region2.children.getItemAt(1) as DataNode;
+            var company2:DataNode = city2.children.getItemAt(1) as DataNode;
+            var department2:DataNode = company2.children.getItemAt(1) as DataNode;
+
+            //then
+            assertTrue(isDescendantOf(department2, company2));
+            assertTrue(isDescendantOf(department2, city2));
+            assertTrue(isDescendantOf(department2, region2));
+            assertFalse(isDescendantOf(department2, region1));
+        }
+
+        [Test]
+        public function test_replacing_a_childless_node_does_not_dispatch_REMOVED_collection_event_but_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                    removeEvent = event;
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
+
+            //WHEN
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 0);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNull(removeEvent); //because the replaced node had no children
+            assertNull(_sut.getParentItem(firstDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+            assertEquals(noItemsInHierarchy, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_a_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                {
+                    removeEvent = event;
+
+                    if(event.items && event.items.length == noChildrenOfSecondDepartment)
+                    {
+                        for(var i:int = 0; i < noChildrenOfSecondDepartment; i++)
+                        {
+                            if(event.items.indexOf(secondDepartment.children.getItemAt(i)) == -1)
+                                REMOVEDEventHasChildrenOfSecondDepartment = false;
+                        }
+                    }
+                }
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+            var REMOVEDEventHasChildrenOfSecondDepartment:Boolean = true;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var secondDepartment:DataNode = departmentsOfCompany2.getItemAt(1) as DataNode;
+            const noChildrenOfSecondDepartment:int = secondDepartment.children.length;
+
+            //WHEN
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 1);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNotNull(removeEvent); //because the replaced node had children
+            assertTrue(REMOVEDEventHasChildrenOfSecondDepartment);
+            assertEquals(-1, removeEvent.items.indexOf(secondDepartment));
+            assertNull(_sut.getParentItem(secondDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+            assertEquals(noItemsInHierarchy - noChildrenOfSecondDepartment, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_a_root_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                {
+                    removeEvent = event;
+                    if(event.items && event.items.length == noChildrenOfSecondRegion)
+                    {
+                        for(var i:int = 0; i < noChildrenOfSecondRegion; i++)
+                        {
+                            if(!isDescendantOf(event.items[1] as DataNode, region2))
+                                REMOVEDEventHasAllChildrenOfSecondRegion = false;
+                        }
+                    }
+                }
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+            var REMOVEDEventHasAllChildrenOfSecondRegion:Boolean = true;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var region2:DataNode = _root.getItemAt(1) as DataNode;
+            var noChildrenOfSecondRegion:int = countAllChildrenOf(region2);
+
+            //WHEN
+            const newRegion:DataNode = new DataNode("Region(X)");
+            _root.setItemAt(newRegion, 1);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNotNull(removeEvent); //because the replaced node had children
+            assertTrue(REMOVEDEventHasAllChildrenOfSecondRegion);
+            assertEquals(-1, removeEvent.items.indexOf(region2));
+            assertNull(_sut.getParentItem(region2));
+            assertEquals(null, _sut.getParentItem(newRegion));
+            assertEquals(noItemsInHierarchy - noChildrenOfSecondRegion + 1, _sut.length);
+        }
+
+        [Test]
+        public function test_replacing_inaccessible_node_does_not_dispatch_REMOVED_collection_event_nor_changes_parent_references():void
+        {
+            function onCollectionChanged(event:CollectionEvent):void
+            {
+                if(event.kind == CollectionEventKind.REMOVE)
+                    removeEvent = event;
+                else if(event.kind == CollectionEventKind.REPLACE)
+                    replaceEvent = event;
+            }
+
+            var removeEvent:CollectionEvent = null;
+            var replaceEvent:CollectionEvent = null;
+
+            //GIVEN
+            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
+            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
+            var departmentsOfCompany2:IList = company2.children;
+            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
+
+            //WHEN
+            _sut.closeNode(_root.getItemAt(1)); //close second region
+            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
+            departmentsOfCompany2.setItemAt(newDepartment, 0);
+
+            //THEN
+            assertNotNull(replaceEvent);
+            assertNull(removeEvent); //because the replaced node had no children
+            assertNull(_sut.getParentItem(firstDepartment));
+            assertEquals(company2, _sut.getParentItem(newDepartment));
+
+            var secondRegion:DataNode = DataNode(_root.getItemAt(1));
+            assertEquals(noItemsInHierarchy - countAllChildrenOf(secondRegion) + 1, _sut.length);
+        }
+
+
+        private function getDirectChildrenOf(...indexesOfSubsequentParents):IList
+        {
+            var currentLevel:IList = _root;
+            var i:int = -1;
+            while(currentLevel && ++i < indexesOfSubsequentParents.length)
+            {
+                var currentParent:DataNode = currentLevel.getItemAt(indexesOfSubsequentParents[i]) as DataNode;
+                currentLevel = currentParent ? currentParent.children : null;
+            }
+
+            return currentLevel;
+        }
+
+        private function isDescendantOf(node:DataNode, potentialAncestor:DataNode):Boolean
+        {
+            if(!potentialAncestor || !node)
+                return false;
+
+            var currentParent:DataNode = node.parent;
+            while(currentParent && currentParent != potentialAncestor)
+            {
+                currentParent = currentParent.parent;
+            }
+
+            return currentParent == potentialAncestor;
+        }
+
+        private function countAllChildrenOf(parent:DataNode):int
+        {
+            if(!parent.children || !parent.children.length)
+                return 1;
+            else
+            {
+                var noChildren:int = 0;
+                for(var i:int = 0; i < parent.children.length; i++)
+                {
+                    noChildren += countAllChildrenOf(parent.children.getItemAt(i) as DataNode);
+                }
+
+                return noChildren + 1;
+            }
+
+            return NaN;
+        }
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+        Region(1)
+        Region(2)
+        Region(2)->City(0)
+        Region(2)->City(1)
+        Region(2)->City(1)->Company(1)
+        Region(2)->City(1)->Company(2)
+        Region(2)->City(1)->Company(2)->Department(1)
+        Region(2)->City(1)->Company(2)->Department(2)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
+        Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
+        Region(2)->City(1)->Company(2)->Department(3)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
+        Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
+        Region(2)->City(1)->Company(3)
+        Region(2)->City(1)->Company(3)->Department(1)
+        Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
+        Region(2)->City(1)->Company(3)->Department(2)
+    ]]>).
+        toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6ffb7ff3/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
deleted file mode 100644
index c4d49a6..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_REPLACE_Tests.as
+++ /dev/null
@@ -1,325 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections {
-    import mx.collections.HierarchicalCollectionView;
-    import mx.collections.IList;
-    import mx.events.CollectionEvent;
-    import mx.events.CollectionEventKind;
-    import mx.utils.StringUtil;
-
-    import org.flexunit.asserts.assertEquals;
-    import org.flexunit.asserts.assertFalse;
-    import org.flexunit.asserts.assertNotNull;
-    import org.flexunit.asserts.assertNull;
-    import org.flexunit.asserts.assertTrue;
-
-    public class HierarchicalCollectionView_REPLACE_Tests {
-
-        private static var _sut:HierarchicalCollectionView;
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private var _root:IList;
-        private static var noItemsInHierarchy:int = NaN;
-
-        [BeforeClass]
-        public static function setUpBeforeClass():void
-        {
-            const hierarchyLines:Array = HIERARCHY_STRING.split("\n");
-            for(var i:int = 0; i < hierarchyLines.length; i++)
-            {
-                if(StringUtil.trim(hierarchyLines[i]))
-                    noItemsInHierarchy++;
-            }
-        }
-
-        [Before]
-        public function setUp():void
-        {
-            _sut = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-            _root = _utils.getRoot(_sut) as IList;
-        }
-
-        [After]
-        public function tearDown():void
-        {
-            _sut = null;
-            _root = null;
-        }
-
-        [Test]
-        public function test_make_sure_we_count_nodes_correctly():void
-        {
-            //when
-            var noChildren:int = 0;
-            for(var i:int = 0; i < _root.length; i++)
-            {
-                noChildren += countAllChildrenOf(_root.getItemAt(i) as DataNode);
-            }
-
-            //then
-            assertEquals(noItemsInHierarchy, noChildren);
-        }
-
-        [Test]
-        public function test_make_sure_isDescendantOf_works_correctly():void
-        {
-            //when
-            var region1:DataNode = _root.getItemAt(0) as DataNode;
-            var region2:DataNode = _root.getItemAt(1) as DataNode;
-            var city2:DataNode = region2.children.getItemAt(1) as DataNode;
-            var company2:DataNode = city2.children.getItemAt(1) as DataNode;
-            var department2:DataNode = company2.children.getItemAt(1) as DataNode;
-
-            //then
-            assertTrue(isDescendantOf(department2, company2));
-            assertTrue(isDescendantOf(department2, city2));
-            assertTrue(isDescendantOf(department2, region2));
-            assertFalse(isDescendantOf(department2, region1));
-        }
-
-        [Test]
-        public function test_replacing_a_childless_node_does_not_dispatch_REMOVED_collection_event_but_changes_parent_references():void
-        {
-            function onCollectionChanged(event:CollectionEvent):void
-            {
-                if(event.kind == CollectionEventKind.REMOVE)
-                    removeEvent = event;
-                else if(event.kind == CollectionEventKind.REPLACE)
-                    replaceEvent = event;
-            }
-
-            var removeEvent:CollectionEvent = null;
-            var replaceEvent:CollectionEvent = null;
-
-            //GIVEN
-            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
-            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
-            var departmentsOfCompany2:IList = company2.children;
-            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
-
-            //WHEN
-            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
-            departmentsOfCompany2.setItemAt(newDepartment, 0);
-
-            //THEN
-            assertNotNull(replaceEvent);
-            assertNull(removeEvent); //because the replaced node had no children
-            assertNull(_sut.getParentItem(firstDepartment));
-            assertEquals(company2, _sut.getParentItem(newDepartment));
-            assertEquals(noItemsInHierarchy, _sut.length);
-        }
-
-        [Test]
-        public function test_replacing_a_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
-        {
-            function onCollectionChanged(event:CollectionEvent):void
-            {
-                if(event.kind == CollectionEventKind.REMOVE)
-                {
-                    removeEvent = event;
-
-                    if(event.items && event.items.length == noChildrenOfSecondDepartment)
-                    {
-                        for(var i:int = 0; i < noChildrenOfSecondDepartment; i++)
-                        {
-                            if(event.items.indexOf(secondDepartment.children.getItemAt(i)) == -1)
-                                REMOVEDEventHasChildrenOfSecondDepartment = false;
-                        }
-                    }
-                }
-                else if(event.kind == CollectionEventKind.REPLACE)
-                    replaceEvent = event;
-            }
-
-            var removeEvent:CollectionEvent = null;
-            var replaceEvent:CollectionEvent = null;
-            var REMOVEDEventHasChildrenOfSecondDepartment:Boolean = true;
-
-            //GIVEN
-            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
-            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
-            var departmentsOfCompany2:IList = company2.children;
-            var secondDepartment:DataNode = departmentsOfCompany2.getItemAt(1) as DataNode;
-            const noChildrenOfSecondDepartment:int = secondDepartment.children.length;
-
-            //WHEN
-            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
-            departmentsOfCompany2.setItemAt(newDepartment, 1);
-
-            //THEN
-            assertNotNull(replaceEvent);
-            assertNotNull(removeEvent); //because the replaced node had children
-            assertTrue(REMOVEDEventHasChildrenOfSecondDepartment);
-            assertEquals(-1, removeEvent.items.indexOf(secondDepartment));
-            assertNull(_sut.getParentItem(secondDepartment));
-            assertEquals(company2, _sut.getParentItem(newDepartment));
-            assertEquals(noItemsInHierarchy - noChildrenOfSecondDepartment, _sut.length);
-        }
-
-        [Test]
-        public function test_replacing_a_root_node_with_children_dispatches_REMOVED_collection_event_and_changes_parent_references():void
-        {
-            function onCollectionChanged(event:CollectionEvent):void
-            {
-                if(event.kind == CollectionEventKind.REMOVE)
-                {
-                    removeEvent = event;
-                    if(event.items && event.items.length == noChildrenOfSecondRegion)
-                    {
-                        for(var i:int = 0; i < noChildrenOfSecondRegion; i++)
-                        {
-                            if(!isDescendantOf(event.items[1] as DataNode, region2))
-                                REMOVEDEventHasAllChildrenOfSecondRegion = false;
-                        }
-                    }
-                }
-                else if(event.kind == CollectionEventKind.REPLACE)
-                    replaceEvent = event;
-            }
-
-            var removeEvent:CollectionEvent = null;
-            var replaceEvent:CollectionEvent = null;
-            var REMOVEDEventHasAllChildrenOfSecondRegion:Boolean = true;
-
-            //GIVEN
-            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
-            var region2:DataNode = _root.getItemAt(1) as DataNode;
-            var noChildrenOfSecondRegion:int = countAllChildrenOf(region2);
-
-            //WHEN
-            const newRegion:DataNode = new DataNode("Region(X)");
-            _root.setItemAt(newRegion, 1);
-
-            //THEN
-            assertNotNull(replaceEvent);
-            assertNotNull(removeEvent); //because the replaced node had children
-            assertTrue(REMOVEDEventHasAllChildrenOfSecondRegion);
-            assertEquals(-1, removeEvent.items.indexOf(region2));
-            assertNull(_sut.getParentItem(region2));
-            assertEquals(null, _sut.getParentItem(newRegion));
-            assertEquals(noItemsInHierarchy - noChildrenOfSecondRegion + 1, _sut.length);
-        }
-
-        [Test]
-        public function test_replacing_inaccessible_node_does_not_dispatch_REMOVED_collection_event_nor_changes_parent_references():void
-        {
-            function onCollectionChanged(event:CollectionEvent):void
-            {
-                if(event.kind == CollectionEventKind.REMOVE)
-                    removeEvent = event;
-                else if(event.kind == CollectionEventKind.REPLACE)
-                    replaceEvent = event;
-            }
-
-            var removeEvent:CollectionEvent = null;
-            var replaceEvent:CollectionEvent = null;
-
-            //GIVEN
-            _sut.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged);
-            var company2:DataNode = getDirectChildrenOf(1, 1).getItemAt(1) as DataNode;
-            var departmentsOfCompany2:IList = company2.children;
-            var firstDepartment:DataNode = departmentsOfCompany2.getItemAt(0) as DataNode;
-
-            //WHEN
-            _sut.closeNode(_root.getItemAt(1)); //close second region
-            const newDepartment:DataNode = new DataNode("Region(2)->City(1)->Company(2)->DepartmentX");
-            departmentsOfCompany2.setItemAt(newDepartment, 0);
-
-            //THEN
-            assertNotNull(replaceEvent);
-            assertNull(removeEvent); //because the replaced node had no children
-            assertNull(_sut.getParentItem(firstDepartment));
-            assertEquals(company2, _sut.getParentItem(newDepartment));
-
-            var secondRegion:DataNode = DataNode(_root.getItemAt(1));
-            assertEquals(noItemsInHierarchy - countAllChildrenOf(secondRegion) + 1, _sut.length);
-        }
-
-
-        private function getDirectChildrenOf(...indexesOfSubsequentParents):IList
-        {
-            var currentLevel:IList = _root;
-            var i:int = -1;
-            while(currentLevel && ++i < indexesOfSubsequentParents.length)
-            {
-                var currentParent:DataNode = currentLevel.getItemAt(indexesOfSubsequentParents[i]) as DataNode;
-                currentLevel = currentParent ? currentParent.children : null;
-            }
-
-            return currentLevel;
-        }
-
-        private function isDescendantOf(node:DataNode, potentialAncestor:DataNode):Boolean
-        {
-            if(!potentialAncestor || !node)
-                return false;
-
-            var currentParent:DataNode = node.parent;
-            while(currentParent && currentParent != potentialAncestor)
-            {
-                currentParent = currentParent.parent;
-            }
-
-            return currentParent == potentialAncestor;
-        }
-
-        private function countAllChildrenOf(parent:DataNode):int
-        {
-            if(!parent.children || !parent.children.length)
-                return 1;
-            else
-            {
-                var noChildren:int = 0;
-                for(var i:int = 0; i < parent.children.length; i++)
-                {
-                    noChildren += countAllChildrenOf(parent.children.getItemAt(i) as DataNode);
-                }
-
-                return noChildren + 1;
-            }
-
-            return NaN;
-        }
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-        Region(1)
-        Region(2)
-        Region(2)->City(0)
-        Region(2)->City(1)
-        Region(2)->City(1)->Company(1)
-        Region(2)->City(1)->Company(2)
-        Region(2)->City(1)->Company(2)->Department(1)
-        Region(2)->City(1)->Company(2)->Department(2)
-        Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
-        Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
-        Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
-        Region(2)->City(1)->Company(2)->Department(3)
-        Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
-        Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
-        Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
-        Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
-        Region(2)->City(1)->Company(3)
-        Region(2)->City(1)->Company(3)->Department(1)
-        Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
-        Region(2)->City(1)->Company(3)->Department(2)
-    ]]>).
-        toString();
-    }
-}


[08/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-43119 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than WindowedApplication, so I changed how uncaught client errors are captured.

Posted by mi...@apache.org.
FLEX-43119 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than WindowedApplication, so I changed how uncaught client errors are captured.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/49c3d683
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/49c3d683
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/49c3d683

Branch: refs/heads/develop
Commit: 49c3d6831f534cfaab0551d09e4b52ba95268eef
Parents: 6ffb7ff
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 16:44:06 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 16:44:06 2015 +0100

----------------------------------------------------------------------
 ...icalCollectionViewCursor_FLEX_34119_Tests.as | 364 ++++++++++++++++++
 ...hicalCollectionViewCursor_FLEX_34119_Test.as | 369 -------------------
 2 files changed, 364 insertions(+), 369 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/49c3d683/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
new file mode 100644
index 0000000..5119ed4
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
@@ -0,0 +1,364 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+    import flexunit.framework.AssertionFailedError;
+
+    import mx.core.FlexGlobals;
+
+    import org.flexunit.assertThat;
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertTrue;
+    import org.flexunit.runners.Parameterized;
+
+    import spark.components.Application;
+
+    /**
+     * README
+     *
+     * -This unit test was initially created to test FLEX-34119, and ended up uncovering FLEX-34424 as well.
+     * -This test builds a hierarchical collection from a string (see HIERARCHY_STRING), so that it's easy
+     * to edit and change it for specific scenarios.
+     * -This test uses utility functions from HierarchicalCollectionViewTestUtils, and data objects from DataNode.
+     * -Running the test takes about 3min on my machine. It will vary on yours, of course, but it shouldn't
+     * be wildly different.
+     * -To speed it up you can decrease the size of the hierarchical collection by editing HIERARCHY_STRING.
+     */
+	[RunWith("org.flexunit.runners.Parameterized")]
+	public class HierarchicalCollectionViewCursor_FLEX_34119_Tests
+	{
+        private static const OP_ADD:int = 0;
+        private static const OP_REMOVE:int = 1;
+        private static const OP_SET:int = 2;
+        private static const OPERATIONS:Array = [OP_ADD, OP_REMOVE, OP_SET];
+        private static var _generatedHierarchy:HierarchicalCollectionView;
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        public static var positionAndOperation:Array = [];
+
+	    {
+	        _generatedHierarchy = _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+	        NO_ITEMS_IN_HIERARCHY = _generatedHierarchy.length;
+	
+	        private static var SELECTED_INDEX:int = 0;
+	        private static var OPERATION_LOCATION:int = 0;
+	        private static var OPERATION_INDEX:int = 0;
+	        for(SELECTED_INDEX = 0; SELECTED_INDEX < NO_ITEMS_IN_HIERARCHY; SELECTED_INDEX++)
+		        for(OPERATION_LOCATION = SELECTED_INDEX; OPERATION_LOCATION >= 0; OPERATION_LOCATION--)
+		            for(OPERATION_INDEX = 0; OPERATION_INDEX < OPERATIONS.length; OPERATION_INDEX++)
+		                positionAndOperation.push([SELECTED_INDEX, OPERATION_LOCATION, OPERATIONS[OPERATION_INDEX]]);
+	    }
+
+        private static var NO_ITEMS_IN_HIERARCHY:int = NaN;
+        private static var _noErrorsThrown:Boolean = true;
+		private static var _operationPerformedInLastStep:Boolean = false;
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _sut:HierarchicalCollectionViewCursor;
+        private static var _operationCursor:HierarchicalCollectionViewCursor;
+		private static var _mirrorCursor:IViewCursor;
+
+        private static var foo:Parameterized;
+
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+        }
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+			if(_operationPerformedInLastStep || !_currentHierarchy)
+			{
+				_operationPerformedInLastStep = false;
+				
+				_currentHierarchy = _utils.clone(_generatedHierarchy);
+				_utils.openAllNodes(_currentHierarchy);
+				_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+			}
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			if(_operationPerformedInLastStep)
+			{
+				_sut = null;
+				_currentHierarchy = null;
+			}
+			
+			_operationCursor = null;
+			_mirrorCursor = null;
+		}
+
+		[Test]
+		public function reproduce_FLEX_34119_WithADDSimple():void
+		{
+			//given
+			var _level0:ArrayCollection = _utils.getRoot(_currentHierarchy) as ArrayCollection;
+			
+			var secondRegion:DataNode = _level0.getItemAt(1) as DataNode;
+			var firstCity:DataNode = secondRegion.children.getItemAt(0) as DataNode;
+			var secondCompany:DataNode = firstCity.children.getItemAt(1) as DataNode;
+			
+			//when
+			_sut.seek(new CursorBookmark(4)); //Region(2)->City(1)->Company(2)
+			secondRegion.children.addItemAt(_utils.createSimpleNode("City [INS]"), 0); //RTE should be thrown here
+			
+			//then
+			assertEquals(secondCompany, _sut.current);
+			assertTrue(_noErrorsThrown);
+		}
+		
+       	[Test(dataProvider="positionAndOperation")]
+        public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
+        {
+			assertThat(operationIndex <= selectedItemIndex);
+			
+            try {
+				//WHEN
+				//1. Select a random node
+				_sut.seek(new CursorBookmark(selectedItemIndex));
+				
+                var selectedNode:DataNode = DataNode(_sut.current);
+                assertNotNull(selectedNode);
+
+                //2. Make sure FLEX-34119 can be reproduced with the current indexes
+               if(!isFLEX_34119_Reproducible(operationIndex, selectedNode, operation))
+			   {
+				   //trace("can't reproduce " + operation + "; " + operationIndex + "; " + selectedNode);
+				   return;
+			   }
+			   
+			   selectedNode.isSelected = true;
+
+               var selectedNodeOrDirectAncestorWasRemoved:Boolean;
+                //3. Perform operation
+                if (operation == OP_ADD)
+                    selectedNodeOrDirectAncestorWasRemoved = testAddition(_operationCursor);
+                else if (operation == OP_REMOVE)
+                    selectedNodeOrDirectAncestorWasRemoved = testRemoval(_operationCursor, selectedNode);
+                else if(operation == OP_SET)
+                    selectedNodeOrDirectAncestorWasRemoved = testReplacement(_operationCursor, selectedNode);
+
+                //THEN 1
+                assertTrue(_noErrorsThrown);
+
+				if(selectedNodeOrDirectAncestorWasRemoved)
+                    return; //it means that _sut.current is now (correctly) null
+
+                //4. Create mirror HierarchicalCollectionView from the changed root, as the source of truth
+                _mirrorCursor = _utils.navigateToItem(_currentHierarchy.createCursor() as HierarchicalCollectionViewCursor, selectedNode);
+
+                //5. Navigate somewhere in both HierarchicalCollectionViews and make sure they do the same thing
+                _sut.moveNext();
+                _mirrorCursor.moveNext();
+
+                //THEN 2
+                assertEquals(_mirrorCursor.current, _sut.current);
+            }
+            catch(error:AssertionFailedError)
+            {
+                trace("FAIL ("+selectedItemIndex + "," + operationIndex + "," + operation + "): " + error.message);
+                _utils.printHCollectionView(_currentHierarchy);
+                throw(error);
+            }
+        }
+		
+		private function isFLEX_34119_Reproducible(where:int, selectedNode:DataNode, operation:int):Boolean
+		{
+			var hasParent:Boolean = _currentHierarchy.getParentItem(selectedNode) != null;
+			if(!hasParent)
+				return false;
+	
+			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+			_operationCursor.seek(new CursorBookmark(where));
+			var itemToPerformOperationOn:DataNode = _operationCursor.current as DataNode;
+            return _utils.nodesHaveCommonAncestor(itemToPerformOperationOn, selectedNode, _currentHierarchy);
+		}
+	
+	    private function testRemoval(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):Boolean
+	    {
+	        var itemToDelete:DataNode = where.current as DataNode;
+	        assertNotNull(itemToDelete);
+
+            var currentWillBeNulled:Boolean = itemToDelete == selectedNode || _utils.isAncestor(itemToDelete, selectedNode, _currentHierarchy);
+
+	        //mark the next item, so we know which item disappeared
+			where.moveNext();
+	        var nextItem:DataNode = where.current as DataNode;
+	        if (nextItem)
+	            nextItem.isPreviousSiblingRemoved = true;
+	
+			//remove the item
+	        var parentOfItemToRemove:DataNode = _currentHierarchy.getParentItem(itemToDelete) as DataNode;
+	        var collectionToChange:ArrayCollection = parentOfItemToRemove ? parentOfItemToRemove.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+			//trace("REM: sel=" + selectedNode + "; before=" + nextItem);
+			_operationPerformedInLastStep = true;
+	        collectionToChange.removeItem(itemToDelete);
+
+            return currentWillBeNulled;
+	    }
+
+
+        private function testAddition(where:HierarchicalCollectionViewCursor):Boolean
+        {
+            var itemBeforeWhichWereAdding:DataNode = where.current as DataNode;
+            assertNotNull(itemBeforeWhichWereAdding);
+
+            var parentOfAdditionLocation:DataNode = _currentHierarchy.getParentItem(itemBeforeWhichWereAdding) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfAdditionLocation ? parentOfAdditionLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var positionOfItemBeforeWhichWereAdding:int = collectionToChange.getItemIndex(itemBeforeWhichWereAdding);
+
+			_operationPerformedInLastStep = true;
+            collectionToChange.addItemAt(_utils.createSimpleNode(itemBeforeWhichWereAdding.label + " [INSERTED NODE]"), positionOfItemBeforeWhichWereAdding);
+			//trace("ADD: sel=" + selectedNode + ");
+            return false;
+        }
+
+        private function testReplacement(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):Boolean
+        {
+            var itemToBeReplaced:DataNode = where.current as DataNode;
+            assertNotNull(itemToBeReplaced);
+
+            var currentWillBeNulled:Boolean = itemToBeReplaced == selectedNode || _utils.isAncestor(itemToBeReplaced, selectedNode, _currentHierarchy);
+
+            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeReplaced) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var replacedItemIndex:int = collectionToChange.getItemIndex(itemToBeReplaced);
+
+            _operationPerformedInLastStep = true;
+            collectionToChange.setItemAt(_utils.createSimpleNode(itemToBeReplaced.label + " [REPLACED NODE]"), replacedItemIndex);
+            //trace("REPLACE: sel=" + selectedNode + ");
+            return currentWillBeNulled;
+        }
+
+
+
+		
+		
+		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n" + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+         Region(1)
+         Region(2)
+         Region(2)->City(1)
+         Region(2)->City(1)->Company(1)
+         Region(2)->City(1)->Company(2)
+         Region(2)->City(1)->Company(2)->Department(1)
+         Region(2)->City(1)->Company(2)->Department(1)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(1)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
+         Region(2)->City(1)->Company(2)->Department(3)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
+         Region(2)->City(1)->Company(3)
+         Region(2)->City(1)->Company(3)->Department(1)
+         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(2)
+         Region(2)->City(1)->Company(3)->Department(2)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(2)->Employee(2)
+         Region(2)->City(1)->Company(3)->Department(3)
+         Region(2)->City(1)->Company(3)->Department(3)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(3)->Employee(2)
+         Region(2)->City(1)->Company(3)->Department(3)->Employee(3)
+         Region(2)->City(1)->Company(3)->Department(3)->Employee(4)
+         Region(2)->City(1)->Company(3)->Department(3)->Employee(5)
+         Region(2)->City(1)->Company(3)->Department(4)
+         Region(2)->City(1)->Company(3)->Department(4)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(4)->Employee(2)
+         Region(2)->City(1)->Company(3)->Department(4)->Employee(3)
+         Region(2)->City(1)->Company(3)->Department(4)->Employee(4)
+         Region(2)->City(1)->Company(4)
+         Region(2)->City(1)->Company(4)->Department(1)
+         Region(2)->City(1)->Company(4)->Department(1)->Employee(1)
+         Region(2)->City(1)->Company(4)->Department(1)->Employee(2)
+         Region(2)->City(1)->Company(4)->Department(1)->Employee(3)
+         Region(3)
+         Region(3)->City(1)
+         Region(3)->City(1)->Company(1)
+         Region(3)->City(1)->Company(1)->Department(1)
+         Region(3)->City(1)->Company(1)->Department(1)->Employee(1)
+         Region(3)->City(1)->Company(1)->Department(1)->Employee(2)
+         Region(3)->City(1)->Company(1)->Department(1)->Employee(3)
+         Region(3)->City(1)->Company(1)->Department(1)->Employee(4)
+         Region(3)->City(1)->Company(1)->Department(2)
+         Region(3)->City(1)->Company(1)->Department(2)->Employee(1)
+         Region(3)->City(1)->Company(1)->Department(2)->Employee(2)
+         Region(3)->City(1)->Company(1)->Department(2)->Employee(3)
+         Region(3)->City(1)->Company(1)->Department(3)
+         Region(3)->City(1)->Company(1)->Department(3)->Employee(1)
+         Region(3)->City(1)->Company(1)->Department(3)->Employee(2)
+         Region(3)->City(1)->Company(1)->Department(3)->Employee(3)
+         Region(3)->City(1)->Company(2)
+         Region(3)->City(1)->Company(2)->Department(1)
+         Region(3)->City(1)->Company(2)->Department(1)->Employee(1)
+         Region(3)->City(1)->Company(2)->Department(2)
+         Region(3)->City(1)->Company(2)->Department(2)->Employee(1)
+         Region(3)->City(1)->Company(2)->Department(2)->Employee(2)
+         Region(3)->City(1)->Company(2)->Department(3)
+         Region(3)->City(1)->Company(2)->Department(4)
+         Region(3)->City(1)->Company(3)
+         Region(3)->City(1)->Company(4)
+         Region(3)->City(1)->Company(4)->Department(1)
+         Region(3)->City(1)->Company(4)->Department(1)->Employee(1)
+         Region(3)->City(1)->Company(4)->Department(1)->Employee(2)
+         Region(3)->City(1)->Company(4)->Department(1)->Employee(3)
+         Region(3)->City(1)->Company(4)->Department(1)->Employee(4)
+         Region(3)->City(1)->Company(4)->Department(2)
+         Region(3)->City(1)->Company(4)->Department(2)->Employee(1)
+         Region(3)->City(1)->Company(4)->Department(2)->Employee(2)
+         Region(3)->City(1)->Company(4)->Department(2)->Employee(3)
+         Region(3)->City(1)->Company(4)->Department(3)
+         Region(3)->City(1)->Company(5)
+         Region(3)->City(2)
+         Region(3)->City(3)
+         Region(3)->City(4)
+         Region(3)->City(4)->Company(1)
+         Region(4)
+         Region(4)->City(1)
+         Region(4)->City(1)->Company(1)
+       ]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/49c3d683/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Test.as
deleted file mode 100644
index 39e509c..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Test.as
+++ /dev/null
@@ -1,369 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-	import flash.events.UncaughtErrorEvent;
-	
-	import mx.collections.ArrayCollection;
-	import mx.collections.CursorBookmark;
-	import mx.collections.HierarchicalCollectionView;
-	import mx.collections.HierarchicalCollectionViewCursor;
-	import mx.collections.IViewCursor;
-	import mx.core.FlexGlobals;
-
-	import spark.components.WindowedApplication;
-	
-	import flexunit.framework.AssertionFailedError;
-	
-	import org.flexunit.assertThat;
-	import org.flexunit.asserts.assertEquals;
-	import org.flexunit.asserts.assertNotNull;
-	import org.flexunit.asserts.assertTrue;
-	import org.flexunit.runners.Parameterized;
-
-    /**
-     * README
-     *
-     * -This unit test was initially created to test FLEX-34119, and ended up uncovering FLEX-34424 as well.
-     * -This test builds a hierarchical collection from a string (see HIERARCHY_STRING), so that it's easy
-     * to edit and change it for specific scenarios.
-     * -This test uses utility functions from HierarchicalCollectionViewTestUtils, and data objects from DataNode.
-     * -Running the test takes about 3min on my machine. It will vary on yours, of course, but it shouldn't
-     * be wildly different.
-     * -To speed it up you can decrease the size of the hierarchical collection by editing HIERARCHY_STRING.
-     */
-	[RunWith("org.flexunit.runners.Parameterized")]
-	public class HierarchicalCollectionViewCursor_FLEX_34119_Test
-	{
-        private static const OP_ADD:int = 0;
-        private static const OP_REMOVE:int = 1;
-        private static const OP_SET:int = 2;
-        private static const OPERATIONS:Array = [OP_ADD, OP_REMOVE, OP_SET];
-        private static var _generatedHierarchy:HierarchicalCollectionView;
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        public static var positionAndOperation:Array = [];
-
-	    {
-	        _generatedHierarchy = _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-	        NO_ITEMS_IN_HIERARCHY = _generatedHierarchy.length;
-	
-	        private static var SELECTED_INDEX:int = 0;
-	        private static var OPERATION_LOCATION:int = 0;
-	        private static var OPERATION_INDEX:int = 0;
-	        for(SELECTED_INDEX = 0; SELECTED_INDEX < NO_ITEMS_IN_HIERARCHY; SELECTED_INDEX++)
-		        for(OPERATION_LOCATION = SELECTED_INDEX; OPERATION_LOCATION >= 0; OPERATION_LOCATION--)
-		            for(OPERATION_INDEX = 0; OPERATION_INDEX < OPERATIONS.length; OPERATION_INDEX++)
-		                positionAndOperation.push([SELECTED_INDEX, OPERATION_LOCATION, OPERATIONS[OPERATION_INDEX]]);
-	    }
-
-        private static var NO_ITEMS_IN_HIERARCHY:int = NaN;
-        private static var _noErrorsThrown:Boolean = true;
-		private static var _operationPerformedInLastStep:Boolean = false;
-        private static var _currentHierarchy:HierarchicalCollectionView;
-        private static var _sut:HierarchicalCollectionViewCursor;
-        private static var _operationCursor:HierarchicalCollectionViewCursor;
-		private static var _mirrorCursor:IViewCursor;
-
-        private static var foo:Parameterized;
-
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-        }
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-			if(_operationPerformedInLastStep || !_currentHierarchy)
-			{
-				_operationPerformedInLastStep = false;
-				
-				_currentHierarchy = _utils.clone(_generatedHierarchy);
-				_utils.openAllNodes(_currentHierarchy);
-				_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-			}
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			if(_operationPerformedInLastStep)
-			{
-				_sut = null;
-				_currentHierarchy = null;
-			}
-			
-			_operationCursor = null;
-			_mirrorCursor = null;
-		}
-
-		[Test]
-		public function reproduce_FLEX_34119_WithADDSimple():void
-		{
-			//given
-			var _level0:ArrayCollection = _utils.getRoot(_currentHierarchy) as ArrayCollection;
-			
-			var secondRegion:DataNode = _level0.getItemAt(1) as DataNode;
-			var firstCity:DataNode = secondRegion.children.getItemAt(0) as DataNode;
-			var secondCompany:DataNode = firstCity.children.getItemAt(1) as DataNode;
-			
-			//when
-			_sut.seek(new CursorBookmark(4)); //Region(2)->City(1)->Company(2)
-			secondRegion.children.addItemAt(_utils.createSimpleNode("City [INS]"), 0); //RTE should be thrown here
-			
-			//then
-			assertEquals(secondCompany, _sut.current);
-			assertTrue(_noErrorsThrown);
-		}
-		
-       	[Test(dataProvider="positionAndOperation")]
-        public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
-        {
-			assertThat(operationIndex <= selectedItemIndex);
-			
-            try {
-				//WHEN
-				//1. Select a random node
-				_sut.seek(new CursorBookmark(selectedItemIndex));
-				
-                var selectedNode:DataNode = DataNode(_sut.current);
-                assertNotNull(selectedNode);
-
-                //2. Make sure FLEX-34119 can be reproduced with the current indexes
-               if(!isFLEX_34119_Reproducible(operationIndex, selectedNode, operation))
-			   {
-				   //trace("can't reproduce " + operation + "; " + operationIndex + "; " + selectedNode);
-				   return;
-			   }
-			   
-			   selectedNode.isSelected = true;
-
-               var selectedNodeOrDirectAncestorWasRemoved:Boolean;
-                //3. Perform operation
-                if (operation == OP_ADD)
-                    selectedNodeOrDirectAncestorWasRemoved = testAddition(_operationCursor);
-                else if (operation == OP_REMOVE)
-                    selectedNodeOrDirectAncestorWasRemoved = testRemoval(_operationCursor, selectedNode);
-                else if(operation == OP_SET)
-                    selectedNodeOrDirectAncestorWasRemoved = testReplacement(_operationCursor, selectedNode);
-
-                //THEN 1
-                assertTrue(_noErrorsThrown);
-
-				if(selectedNodeOrDirectAncestorWasRemoved)
-                    return; //it means that _sut.current is now (correctly) null
-
-                //4. Create mirror HierarchicalCollectionView from the changed root, as the source of truth
-                _mirrorCursor = _utils.navigateToItem(_currentHierarchy.createCursor() as HierarchicalCollectionViewCursor, selectedNode);
-
-                //5. Navigate somewhere in both HierarchicalCollectionViews and make sure they do the same thing
-                _sut.moveNext();
-                _mirrorCursor.moveNext();
-
-                //THEN 2
-                assertEquals(_mirrorCursor.current, _sut.current);
-            }
-            catch(error:AssertionFailedError)
-            {
-                trace("FAIL ("+selectedItemIndex + "," + operationIndex + "," + operation + "): " + error.message);
-                _utils.printHCollectionView(_currentHierarchy);
-                throw(error);
-            }
-        }
-		
-		private function isFLEX_34119_Reproducible(where:int, selectedNode:DataNode, operation:int):Boolean
-		{
-			var hasParent:Boolean = _currentHierarchy.getParentItem(selectedNode) != null;
-			if(!hasParent)
-				return false;
-	
-			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-			_operationCursor.seek(new CursorBookmark(where));
-			var itemToPerformOperationOn:DataNode = _operationCursor.current as DataNode;
-            return _utils.nodesHaveCommonAncestor(itemToPerformOperationOn, selectedNode, _currentHierarchy);
-		}
-	
-	    private function testRemoval(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):Boolean
-	    {
-	        var itemToDelete:DataNode = where.current as DataNode;
-	        assertNotNull(itemToDelete);
-
-            var currentWillBeNulled:Boolean = itemToDelete == selectedNode || _utils.isAncestor(itemToDelete, selectedNode, _currentHierarchy);
-
-	        //mark the next item, so we know which item disappeared
-			where.moveNext();
-	        var nextItem:DataNode = where.current as DataNode;
-	        if (nextItem)
-	            nextItem.isPreviousSiblingRemoved = true;
-	
-			//remove the item
-	        var parentOfItemToRemove:DataNode = _currentHierarchy.getParentItem(itemToDelete) as DataNode;
-	        var collectionToChange:ArrayCollection = parentOfItemToRemove ? parentOfItemToRemove.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-			//trace("REM: sel=" + selectedNode + "; before=" + nextItem);
-			_operationPerformedInLastStep = true;
-	        collectionToChange.removeItem(itemToDelete);
-
-            return currentWillBeNulled;
-	    }
-
-
-        private function testAddition(where:HierarchicalCollectionViewCursor):Boolean
-        {
-            var itemBeforeWhichWereAdding:DataNode = where.current as DataNode;
-            assertNotNull(itemBeforeWhichWereAdding);
-
-            var parentOfAdditionLocation:DataNode = _currentHierarchy.getParentItem(itemBeforeWhichWereAdding) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfAdditionLocation ? parentOfAdditionLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var positionOfItemBeforeWhichWereAdding:int = collectionToChange.getItemIndex(itemBeforeWhichWereAdding);
-
-			_operationPerformedInLastStep = true;
-            collectionToChange.addItemAt(_utils.createSimpleNode(itemBeforeWhichWereAdding.label + " [INSERTED NODE]"), positionOfItemBeforeWhichWereAdding);
-			//trace("ADD: sel=" + selectedNode + ");
-            return false;
-        }
-
-        private function testReplacement(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):Boolean
-        {
-            var itemToBeReplaced:DataNode = where.current as DataNode;
-            assertNotNull(itemToBeReplaced);
-
-            var currentWillBeNulled:Boolean = itemToBeReplaced == selectedNode || _utils.isAncestor(itemToBeReplaced, selectedNode, _currentHierarchy);
-
-            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeReplaced) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var replacedItemIndex:int = collectionToChange.getItemIndex(itemToBeReplaced);
-
-            _operationPerformedInLastStep = true;
-            collectionToChange.setItemAt(_utils.createSimpleNode(itemToBeReplaced.label + " [REPLACED NODE]"), replacedItemIndex);
-            //trace("REPLACE: sel=" + selectedNode + ");
-            return currentWillBeNulled;
-        }
-
-
-
-		
-		
-		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n" + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-         Region(1)
-         Region(2)
-         Region(2)->City(1)
-         Region(2)->City(1)->Company(1)
-         Region(2)->City(1)->Company(2)
-         Region(2)->City(1)->Company(2)->Department(1)
-         Region(2)->City(1)->Company(2)->Department(1)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(1)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
-         Region(2)->City(1)->Company(2)->Department(3)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
-         Region(2)->City(1)->Company(3)
-         Region(2)->City(1)->Company(3)->Department(1)
-         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(2)
-         Region(2)->City(1)->Company(3)->Department(2)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(2)->Employee(2)
-         Region(2)->City(1)->Company(3)->Department(3)
-         Region(2)->City(1)->Company(3)->Department(3)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(3)->Employee(2)
-         Region(2)->City(1)->Company(3)->Department(3)->Employee(3)
-         Region(2)->City(1)->Company(3)->Department(3)->Employee(4)
-         Region(2)->City(1)->Company(3)->Department(3)->Employee(5)
-         Region(2)->City(1)->Company(3)->Department(4)
-         Region(2)->City(1)->Company(3)->Department(4)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(4)->Employee(2)
-         Region(2)->City(1)->Company(3)->Department(4)->Employee(3)
-         Region(2)->City(1)->Company(3)->Department(4)->Employee(4)
-         Region(2)->City(1)->Company(4)
-         Region(2)->City(1)->Company(4)->Department(1)
-         Region(2)->City(1)->Company(4)->Department(1)->Employee(1)
-         Region(2)->City(1)->Company(4)->Department(1)->Employee(2)
-         Region(2)->City(1)->Company(4)->Department(1)->Employee(3)
-         Region(3)
-         Region(3)->City(1)
-         Region(3)->City(1)->Company(1)
-         Region(3)->City(1)->Company(1)->Department(1)
-         Region(3)->City(1)->Company(1)->Department(1)->Employee(1)
-         Region(3)->City(1)->Company(1)->Department(1)->Employee(2)
-         Region(3)->City(1)->Company(1)->Department(1)->Employee(3)
-         Region(3)->City(1)->Company(1)->Department(1)->Employee(4)
-         Region(3)->City(1)->Company(1)->Department(2)
-         Region(3)->City(1)->Company(1)->Department(2)->Employee(1)
-         Region(3)->City(1)->Company(1)->Department(2)->Employee(2)
-         Region(3)->City(1)->Company(1)->Department(2)->Employee(3)
-         Region(3)->City(1)->Company(1)->Department(3)
-         Region(3)->City(1)->Company(1)->Department(3)->Employee(1)
-         Region(3)->City(1)->Company(1)->Department(3)->Employee(2)
-         Region(3)->City(1)->Company(1)->Department(3)->Employee(3)
-         Region(3)->City(1)->Company(2)
-         Region(3)->City(1)->Company(2)->Department(1)
-         Region(3)->City(1)->Company(2)->Department(1)->Employee(1)
-         Region(3)->City(1)->Company(2)->Department(2)
-         Region(3)->City(1)->Company(2)->Department(2)->Employee(1)
-         Region(3)->City(1)->Company(2)->Department(2)->Employee(2)
-         Region(3)->City(1)->Company(2)->Department(3)
-         Region(3)->City(1)->Company(2)->Department(4)
-         Region(3)->City(1)->Company(3)
-         Region(3)->City(1)->Company(4)
-         Region(3)->City(1)->Company(4)->Department(1)
-         Region(3)->City(1)->Company(4)->Department(1)->Employee(1)
-         Region(3)->City(1)->Company(4)->Department(1)->Employee(2)
-         Region(3)->City(1)->Company(4)->Department(1)->Employee(3)
-         Region(3)->City(1)->Company(4)->Department(1)->Employee(4)
-         Region(3)->City(1)->Company(4)->Department(2)
-         Region(3)->City(1)->Company(4)->Department(2)->Employee(1)
-         Region(3)->City(1)->Company(4)->Department(2)->Employee(2)
-         Region(3)->City(1)->Company(4)->Department(2)->Employee(3)
-         Region(3)->City(1)->Company(4)->Department(3)
-         Region(3)->City(1)->Company(5)
-         Region(3)->City(2)
-         Region(3)->City(3)
-         Region(3)->City(4)
-         Region(3)->City(4)->Company(1)
-         Region(4)
-         Region(4)->City(1)
-         Region(4)->City(1)->Company(1)
-       ]]>).toString();
-	}
-}
\ No newline at end of file


Re: [02/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. S

Posted by Mihai Chira <mi...@gmail.com>.
I think it is, yes. I wrote as many unit tests I could think of to
verify it, hopefully they're inclusive enough.

I found this bug while writing the unit tests to verify the fix for
this one[1]. I don't think I'm able to finish work on it this week,
but next week for sure. If it's not too late, maybe we can include
this too.

[1] https://issues.apache.org/jira/browse/FLEX-34775

On 11 March 2015 at 08:52, Erik de Bruin <er...@ixsoftware.nl> wrote:
> Mihai,
>
> I'd love to add this to the 4.14.1 release. Do you think it is stable
> enough for inclusion?
>
> EdB
>
>
>
> On Tue, Mar 10, 2015 at 5:43 PM,  <mi...@apache.org> wrote:
>> FLEX-34778
>> CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. So when a closed node's child is replaced, nestedCollectionChangeHandler is triggered, even if the node itself is closed. Part of nestedCollectionChangeHandler's function is to dispatch a REMOVE CollectionEvent for all the nodes which were removed by the replacement (which is, all the descendants of the replaced - but closed! - node). Then, since the node that's being replaced is not accessible anymore (because its parent was closed), it's not added to convertedEvent.items. But the next lines assume that the replaced node will be in that array without mistake. Otherwise (as it happens in this bus) it goes into an infinite loop trying to find it.
>>
>> SOLUTION: instead of looking for the node with an (indefinitely) incrementing index, we're now using Array.indexOf() to locate the node and remove it if it's found.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/32f39500
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/32f39500
>> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/32f39500
>>
>> Branch: refs/heads/develop
>> Commit: 32f39500d34d05c14282cdafcef7ae494783df85
>> Parents: ab0943c
>> Author: Mihai Chira <mi...@apache.org>
>> Authored: Tue Mar 10 13:00:10 2015 +0100
>> Committer: Mihai Chira <mi...@apache.org>
>> Committed: Tue Mar 10 13:00:10 2015 +0100
>>
>> ----------------------------------------------------------------------
>>  .../src/mx/collections/HierarchicalCollectionView.as | 15 ++++++++-------
>>  1 file changed, 8 insertions(+), 7 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/32f39500/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
>> index 6d4901c..d752e8e 100644
>> --- a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
>> +++ b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
>> @@ -1152,7 +1152,7 @@ public class HierarchicalCollectionView extends EventDispatcher
>>      private function internalRefresh(dispatch:Boolean):Boolean
>>      {
>>          var obj:Object;
>> -        var coll:ICollectionView
>> +        var coll:ICollectionView;
>>          var needUpdate:Boolean = false;
>>
>>          // apply filter function to all the collections including the child collections
>> @@ -1531,9 +1531,9 @@ public class HierarchicalCollectionView extends EventDispatcher
>>                  for (i = 0; i < n; i++)
>>                  {
>>                      node = ce.items[i].oldValue;
>> -                    while (convertedEvent.items[j] != node)
>> -                        j++;
>> -                    convertedEvent.items.splice(j, 1);
>> +                    var replacedNodePosition:int = convertedEvent.items.indexOf(node);
>> +                    if(replacedNodePosition != -1)
>> +                        convertedEvent.items.splice(replacedNodePosition, 1);
>>                  }
>>                  if (convertedEvent.items.length)
>>                  {
>> @@ -1654,9 +1654,10 @@ public class HierarchicalCollectionView extends EventDispatcher
>>                      changingNode = ce.items[i].oldValue;
>>                      if (changingNode is XML)
>>                          stopTrackUpdates(changingNode);
>> -                    while (convertedEvent.items[j] != changingNode)
>> -                        j++;
>> -                    convertedEvent.items.splice(j, 1);
>> +
>> +                    var replacedNodePosition:int = convertedEvent.items.indexOf(changingNode);
>> +                    if(replacedNodePosition != -1)
>> +                        convertedEvent.items.splice(replacedNodePosition, 1);
>>                  }
>>                  if (convertedEvent.items.length)
>>                  {
>>
>
>
>
> --
> Ix Multimedia Software
>
> Jan Luykenstraat 27
> 3521 VB Utrecht
>
> T. 06-51952295
> I. www.ixsoftware.nl

Re: [02/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. S

Posted by Erik de Bruin <er...@ixsoftware.nl>.
Mihai,

I'd love to add this to the 4.14.1 release. Do you think it is stable
enough for inclusion?

EdB



On Tue, Mar 10, 2015 at 5:43 PM,  <mi...@apache.org> wrote:
> FLEX-34778
> CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. So when a closed node's child is replaced, nestedCollectionChangeHandler is triggered, even if the node itself is closed. Part of nestedCollectionChangeHandler's function is to dispatch a REMOVE CollectionEvent for all the nodes which were removed by the replacement (which is, all the descendants of the replaced - but closed! - node). Then, since the node that's being replaced is not accessible anymore (because its parent was closed), it's not added to convertedEvent.items. But the next lines assume that the replaced node will be in that array without mistake. Otherwise (as it happens in this bus) it goes into an infinite loop trying to find it.
>
> SOLUTION: instead of looking for the node with an (indefinitely) incrementing index, we're now using Array.indexOf() to locate the node and remove it if it's found.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/32f39500
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/32f39500
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/32f39500
>
> Branch: refs/heads/develop
> Commit: 32f39500d34d05c14282cdafcef7ae494783df85
> Parents: ab0943c
> Author: Mihai Chira <mi...@apache.org>
> Authored: Tue Mar 10 13:00:10 2015 +0100
> Committer: Mihai Chira <mi...@apache.org>
> Committed: Tue Mar 10 13:00:10 2015 +0100
>
> ----------------------------------------------------------------------
>  .../src/mx/collections/HierarchicalCollectionView.as | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/32f39500/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
> index 6d4901c..d752e8e 100644
> --- a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
> +++ b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
> @@ -1152,7 +1152,7 @@ public class HierarchicalCollectionView extends EventDispatcher
>      private function internalRefresh(dispatch:Boolean):Boolean
>      {
>          var obj:Object;
> -        var coll:ICollectionView
> +        var coll:ICollectionView;
>          var needUpdate:Boolean = false;
>
>          // apply filter function to all the collections including the child collections
> @@ -1531,9 +1531,9 @@ public class HierarchicalCollectionView extends EventDispatcher
>                  for (i = 0; i < n; i++)
>                  {
>                      node = ce.items[i].oldValue;
> -                    while (convertedEvent.items[j] != node)
> -                        j++;
> -                    convertedEvent.items.splice(j, 1);
> +                    var replacedNodePosition:int = convertedEvent.items.indexOf(node);
> +                    if(replacedNodePosition != -1)
> +                        convertedEvent.items.splice(replacedNodePosition, 1);
>                  }
>                  if (convertedEvent.items.length)
>                  {
> @@ -1654,9 +1654,10 @@ public class HierarchicalCollectionView extends EventDispatcher
>                      changingNode = ce.items[i].oldValue;
>                      if (changingNode is XML)
>                          stopTrackUpdates(changingNode);
> -                    while (convertedEvent.items[j] != changingNode)
> -                        j++;
> -                    convertedEvent.items.splice(j, 1);
> +
> +                    var replacedNodePosition:int = convertedEvent.items.indexOf(changingNode);
> +                    if(replacedNodePosition != -1)
> +                        convertedEvent.items.splice(replacedNodePosition, 1);
>                  }
>                  if (convertedEvent.items.length)
>                  {
>



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

[02/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34778 CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. S

Posted by mi...@apache.org.
FLEX-34778
CAUSE: When a node is opened, HierarchicalCollectionView starts to listen to changes to its children collection. And when it's closed, it doesn't stop listening to these CollectionEvents. So when a closed node's child is replaced, nestedCollectionChangeHandler is triggered, even if the node itself is closed. Part of nestedCollectionChangeHandler's function is to dispatch a REMOVE CollectionEvent for all the nodes which were removed by the replacement (which is, all the descendants of the replaced - but closed! - node). Then, since the node that's being replaced is not accessible anymore (because its parent was closed), it's not added to convertedEvent.items. But the next lines assume that the replaced node will be in that array without mistake. Otherwise (as it happens in this bus) it goes into an infinite loop trying to find it.

SOLUTION: instead of looking for the node with an (indefinitely) incrementing index, we're now using Array.indexOf() to locate the node and remove it if it's found.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/32f39500
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/32f39500
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/32f39500

Branch: refs/heads/develop
Commit: 32f39500d34d05c14282cdafcef7ae494783df85
Parents: ab0943c
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 13:00:10 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 13:00:10 2015 +0100

----------------------------------------------------------------------
 .../src/mx/collections/HierarchicalCollectionView.as | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/32f39500/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
index 6d4901c..d752e8e 100644
--- a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
+++ b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionView.as
@@ -1152,7 +1152,7 @@ public class HierarchicalCollectionView extends EventDispatcher
     private function internalRefresh(dispatch:Boolean):Boolean
     {
         var obj:Object;
-        var coll:ICollectionView
+        var coll:ICollectionView;
         var needUpdate:Boolean = false;
         
         // apply filter function to all the collections including the child collections
@@ -1531,9 +1531,9 @@ public class HierarchicalCollectionView extends EventDispatcher
                 for (i = 0; i < n; i++)
                 {
                     node = ce.items[i].oldValue;
-                    while (convertedEvent.items[j] != node)
-                        j++;
-                    convertedEvent.items.splice(j, 1);
+                    var replacedNodePosition:int = convertedEvent.items.indexOf(node);
+                    if(replacedNodePosition != -1)
+                        convertedEvent.items.splice(replacedNodePosition, 1);
                 }
                 if (convertedEvent.items.length)
                 {
@@ -1654,9 +1654,10 @@ public class HierarchicalCollectionView extends EventDispatcher
                     changingNode = ce.items[i].oldValue;
                     if (changingNode is XML)
                         stopTrackUpdates(changingNode);
-                    while (convertedEvent.items[j] != changingNode)
-                        j++;
-                    convertedEvent.items.splice(j, 1);
+
+                    var replacedNodePosition:int = convertedEvent.items.indexOf(changingNode);
+                    if(replacedNodePosition != -1)
+                        convertedEvent.items.splice(replacedNodePosition, 1);
                 }
                 if (convertedEvent.items.length)
                 {


[11/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34456 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured

Posted by mi...@apache.org.
FLEX-34456 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured to reflect this.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/939c510f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/939c510f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/939c510f

Branch: refs/heads/develop
Commit: 939c510fe609b7abf73984a89f2d4313819f7c0e
Parents: 5cb1e94
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 16:58:18 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 16:58:18 2015 +0100

----------------------------------------------------------------------
 ...icalCollectionViewCursor_FLEX_34456_Tests.as | 184 +++++++++++++++++++
 ...hicalCollectionViewCursor_FLEX_34456_Test.as | 184 -------------------
 2 files changed, 184 insertions(+), 184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/939c510f/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Tests.as
new file mode 100644
index 0000000..353e885
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Tests.as
@@ -0,0 +1,184 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+    import mx.core.FlexGlobals;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertTrue;
+    import org.flexunit.runners.Parameterized;
+
+    import spark.components.Application;
+
+    [RunWith("org.flexunit.runners.Parameterized")]
+	public class HierarchicalCollectionViewCursor_FLEX_34456_Tests
+	{
+        public static var positionAndOperation:Array = [[11, 5, 0], [11, 5, 1]];
+		
+        private static const OP_ADD:int = 0;
+        private static const OP_REMOVE:int = 1;
+        private static var _generatedHierarchy:HierarchicalCollectionView;
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _noErrorsThrown:Boolean = true;
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _sut:HierarchicalCollectionViewCursor;
+        private static var _operationCursor:HierarchicalCollectionViewCursor;
+		private static var _mirrorCursor:HierarchicalCollectionViewCursor;
+
+        private static var foo:Parameterized;
+
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+			_generatedHierarchy = _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+        }
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+			_generatedHierarchy = null;
+			_utils = null;
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+			_currentHierarchy = _utils.clone(_generatedHierarchy);
+			_utils.openAllNodes(_currentHierarchy);
+			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+			_currentHierarchy = null;
+			_operationCursor = null;
+			_mirrorCursor = null;
+		}
+
+
+		[Test(dataProvider="positionAndOperation")]
+        public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
+        {
+			//WHEN
+			//1. Select a random node
+			_sut.seek(new CursorBookmark(selectedItemIndex));
+			
+            var selectedNode:DataNode = DataNode(_sut.current);
+            assertNotNull(selectedNode);
+
+		   selectedNode.isSelected = true;
+		   
+            //2. Perform operation
+		   _operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+		   _operationCursor.seek(new CursorBookmark(operationIndex));
+		   
+            if (operation == OP_ADD)
+                testAddition(_operationCursor);
+            else if (operation == OP_REMOVE)
+                testRemoval(_operationCursor, selectedNode);
+
+            //THEN 1
+            assertTrue(_noErrorsThrown);
+
+            //3. Create mirror HierarchicalCollectionView from the changed root, as the source of truth
+            _mirrorCursor = _utils.navigateToItem(_currentHierarchy.createCursor() as HierarchicalCollectionViewCursor, selectedNode) as HierarchicalCollectionViewCursor;
+
+            //4. Navigate somewhere in both HierarchicalCollectionViews and make sure they do the same thing
+            _sut.moveNext();
+            _mirrorCursor.moveNext();
+
+            //THEN 2
+            assertEquals(_mirrorCursor.current, _sut.current);
+        }
+		
+	
+	    private function testRemoval(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):void
+	    {
+	        var itemToDelete:DataNode = where.current as DataNode;
+	        assertNotNull(itemToDelete);
+
+	        //mark the next item, so we know which item disappeared
+			where.moveNext();
+	        var nextItem:DataNode = where.current as DataNode;
+	        if (nextItem)
+	            nextItem.isPreviousSiblingRemoved = true;
+	
+			//remove the item
+	        var parentOfItemToRemove:DataNode = _currentHierarchy.getParentItem(itemToDelete) as DataNode;
+	        var collectionToChange:ArrayCollection = parentOfItemToRemove ? parentOfItemToRemove.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+			
+	        collectionToChange.removeItem(itemToDelete);
+	    }
+
+
+        private function testAddition(where:HierarchicalCollectionViewCursor):void
+        {
+            var itemBeforeWhichWereAdding:DataNode = where.current as DataNode;
+            assertNotNull(itemBeforeWhichWereAdding);
+
+            var parentOfAdditionLocation:DataNode = _currentHierarchy.getParentItem(itemBeforeWhichWereAdding) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfAdditionLocation ? parentOfAdditionLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var positionOfItemBeforeWhichWereAdding:int = collectionToChange.getItemIndex(itemBeforeWhichWereAdding);
+
+			collectionToChange.addItemAt(_utils.createSimpleNode(itemBeforeWhichWereAdding.label + " [INSERTED NODE]"), positionOfItemBeforeWhichWereAdding);
+        }
+
+
+		
+		
+		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n" + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+         Region(1)
+         Region(2)
+         Region(2)->City(1)
+         Region(2)->City(1)->Company(1)
+         Region(2)->City(1)->Company(2)
+         Region(2)->City(1)->Company(2)->Department(1)[REM]
+         Region(2)->City(1)->Company(2)->Department(1)[REM]->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(1)[REM]->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)[SEL]
+         Region(2)->City(1)->Company(2)->Department(3)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
+         Region(2)->City(1)->Company(3)
+       ]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/939c510f/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Test.as
deleted file mode 100644
index c8a96a9..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34456_Test.as
+++ /dev/null
@@ -1,184 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-	import flash.events.UncaughtErrorEvent;
-	
-	import mx.core.FlexGlobals;
-	
-	import spark.components.WindowedApplication;
-	
-	import org.flexunit.asserts.assertEquals;
-	import org.flexunit.asserts.assertNotNull;
-	import org.flexunit.asserts.assertTrue;
-	import org.flexunit.runners.Parameterized;
-
-	[RunWith("org.flexunit.runners.Parameterized")]
-	public class HierarchicalCollectionViewCursor_FLEX_34456_Test
-	{
-        public static var positionAndOperation:Array = [[11, 5, 0], [11, 5, 1]];
-		
-        private static const OP_ADD:int = 0;
-        private static const OP_REMOVE:int = 1;
-        private static var _generatedHierarchy:HierarchicalCollectionView;
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _noErrorsThrown:Boolean = true;
-        private static var _currentHierarchy:HierarchicalCollectionView;
-        private static var _sut:HierarchicalCollectionViewCursor;
-        private static var _operationCursor:HierarchicalCollectionViewCursor;
-		private static var _mirrorCursor:HierarchicalCollectionViewCursor;
-
-        private static var foo:Parameterized;
-
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-			_generatedHierarchy = _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-        }
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-			_generatedHierarchy = null;
-			_utils = null;
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-			_currentHierarchy = _utils.clone(_generatedHierarchy);
-			_utils.openAllNodes(_currentHierarchy);
-			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-			_currentHierarchy = null;
-			_operationCursor = null;
-			_mirrorCursor = null;
-		}
-
-
-		[Test(dataProvider="positionAndOperation")]
-        public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
-        {
-			//WHEN
-			//1. Select a random node
-			_sut.seek(new CursorBookmark(selectedItemIndex));
-			
-            var selectedNode:DataNode = DataNode(_sut.current);
-            assertNotNull(selectedNode);
-
-		   selectedNode.isSelected = true;
-		   
-            //2. Perform operation
-		   _operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-		   _operationCursor.seek(new CursorBookmark(operationIndex));
-		   
-            if (operation == OP_ADD)
-                testAddition(_operationCursor);
-            else if (operation == OP_REMOVE)
-                testRemoval(_operationCursor, selectedNode);
-
-            //THEN 1
-            assertTrue(_noErrorsThrown);
-
-            //3. Create mirror HierarchicalCollectionView from the changed root, as the source of truth
-            _mirrorCursor = _utils.navigateToItem(_currentHierarchy.createCursor() as HierarchicalCollectionViewCursor, selectedNode) as HierarchicalCollectionViewCursor;
-
-            //4. Navigate somewhere in both HierarchicalCollectionViews and make sure they do the same thing
-            _sut.moveNext();
-            _mirrorCursor.moveNext();
-
-            //THEN 2
-            assertEquals(_mirrorCursor.current, _sut.current);
-        }
-		
-	
-	    private function testRemoval(where:HierarchicalCollectionViewCursor, selectedNode:DataNode):void
-	    {
-	        var itemToDelete:DataNode = where.current as DataNode;
-	        assertNotNull(itemToDelete);
-
-	        //mark the next item, so we know which item disappeared
-			where.moveNext();
-	        var nextItem:DataNode = where.current as DataNode;
-	        if (nextItem)
-	            nextItem.isPreviousSiblingRemoved = true;
-	
-			//remove the item
-	        var parentOfItemToRemove:DataNode = _currentHierarchy.getParentItem(itemToDelete) as DataNode;
-	        var collectionToChange:ArrayCollection = parentOfItemToRemove ? parentOfItemToRemove.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-			
-	        collectionToChange.removeItem(itemToDelete);
-	    }
-
-
-        private function testAddition(where:HierarchicalCollectionViewCursor):void
-        {
-            var itemBeforeWhichWereAdding:DataNode = where.current as DataNode;
-            assertNotNull(itemBeforeWhichWereAdding);
-
-            var parentOfAdditionLocation:DataNode = _currentHierarchy.getParentItem(itemBeforeWhichWereAdding) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfAdditionLocation ? parentOfAdditionLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var positionOfItemBeforeWhichWereAdding:int = collectionToChange.getItemIndex(itemBeforeWhichWereAdding);
-
-			collectionToChange.addItemAt(_utils.createSimpleNode(itemBeforeWhichWereAdding.label + " [INSERTED NODE]"), positionOfItemBeforeWhichWereAdding);
-        }
-
-
-		
-		
-		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n" + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-         Region(1)
-         Region(2)
-         Region(2)->City(1)
-         Region(2)->City(1)->Company(1)
-         Region(2)->City(1)->Company(2)
-         Region(2)->City(1)->Company(2)->Department(1)[REM]
-         Region(2)->City(1)->Company(2)->Department(1)[REM]->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(1)[REM]->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)[SEL]
-         Region(2)->City(1)->Company(2)->Department(3)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
-         Region(2)->City(1)->Company(3)
-       ]]>).toString();
-	}
-}
\ No newline at end of file


[09/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34424 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured

Posted by mi...@apache.org.
FLEX-34424 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured to reflect this.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/01894ff6
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/01894ff6
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/01894ff6

Branch: refs/heads/develop
Commit: 01894ff6d652d27bcb97d2bfa911a623b890711d
Parents: 49c3d68
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 16:50:12 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 16:50:12 2015 +0100

----------------------------------------------------------------------
 ...icalCollectionViewCursor_FLEX_34424_Tests.as | 153 ++++++++++++++++++
 ...hicalCollectionViewCursor_FLEX_34424_Test.as | 159 -------------------
 2 files changed, 153 insertions(+), 159 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/01894ff6/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Tests.as
new file mode 100644
index 0000000..117c633
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Tests.as
@@ -0,0 +1,153 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+    import mx.core.FlexGlobals;
+    import mx.events.CollectionEvent;
+    import mx.events.CollectionEventKind;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertTrue;
+    import org.flexunit.runners.Parameterized;
+
+    import spark.components.Application;
+
+    [RunWith("org.flexunit.runners.Parameterized")]
+public class HierarchicalCollectionViewCursor_FLEX_34424_Tests
+	{
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _noErrorsThrown:Boolean = true;
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _sut:HierarchicalCollectionViewCursor;
+        private static var _operationCursor:HierarchicalCollectionViewCursor;
+        public static var selectionAndRemovalLocations:Array = [[10, 8, 1], [11, 7, 1], [11, 6, 2], [19, 17, 1]];
+
+        private static var foo:Parameterized;
+
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+        }
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+			_currentHierarchy = null;
+			_operationCursor = null;
+		}
+
+        [Test(dataProvider="selectionAndRemovalLocations")]
+        public function testReproduce_FLEX_34424(selectedItemIndex:int, removalIndex:int, noItemsToRemove:int):void
+        {
+			//WHEN
+			//1. Select a specific node
+			_sut.seek(new CursorBookmark(selectedItemIndex));
+			
+            var selectedNode:DataNode = DataNode(_sut.current);
+            assertNotNull(selectedNode);
+		    selectedNode.isSelected = true;
+
+            //2. Perform removal
+			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+			_operationCursor.seek(new CursorBookmark(removalIndex));
+		    performRemoval(_operationCursor, noItemsToRemove);
+
+            //THEN
+            assertTrue(_noErrorsThrown);
+            assertEquals(selectedNode, _sut.current);
+        }
+		
+        private static function performRemoval(where:HierarchicalCollectionViewCursor, noItemsToRemove:int):void
+        {
+            var itemToBeRemoved:DataNode = where.current as DataNode;
+            assertNotNull(itemToBeRemoved);
+
+            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeRemoved) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var removedItemIndex:int = collectionToChange.getItemIndex(itemToBeRemoved);
+
+            if(noItemsToRemove == 1)
+                collectionToChange.removeItemAt(removedItemIndex);
+            else {//note that this assumes the collection is not filtered or sorted; for this test the assumption holds.
+                var removedItems:Array = collectionToChange.source.splice(removedItemIndex, noItemsToRemove);
+                //fake a CollectionEventKind.REMOVE event with more than one item removed
+                collectionToChange.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE, false, false, CollectionEventKind.REMOVE, removedItemIndex, -1, removedItems));
+            }
+        }
+
+
+
+		
+		
+		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n FAIL: " + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+         Region(1)
+         Region(2)
+		 Region(2)->City(0)
+         Region(2)->City(1)
+         Region(2)->City(1)->Company(1)
+         Region(2)->City(1)->Company(2)
+         Region(2)->City(1)->Company(2)->Department(1)
+         Region(2)->City(1)->Company(2)->Department(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
+         Region(2)->City(1)->Company(2)->Department(3)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
+         Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
+         Region(2)->City(1)->Company(3)
+         Region(2)->City(1)->Company(3)->Department(1)
+         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
+         Region(2)->City(1)->Company(3)->Department(2)
+       ]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/01894ff6/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as
deleted file mode 100644
index 887d9c2..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as
+++ /dev/null
@@ -1,159 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-import flash.events.UncaughtErrorEvent;
-
-import mx.collections.ArrayCollection;
-import mx.collections.CursorBookmark;
-import mx.collections.HierarchicalCollectionView;
-import mx.collections.HierarchicalCollectionViewCursor;
-import mx.core.FlexGlobals;
-import mx.events.CollectionEvent;
-import mx.events.CollectionEventKind;
-import mx.events.PropertyChangeEvent;
-
-import org.flexunit.asserts.assertEquals;
-
-import org.flexunit.asserts.assertNotNull;
-import org.flexunit.asserts.assertTrue;
-import org.flexunit.runners.Parameterized;
-
-import spark.components.WindowedApplication;
-
-[RunWith("org.flexunit.runners.Parameterized")]
-public class HierarchicalCollectionViewCursor_FLEX_34424_Test
-	{
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _noErrorsThrown:Boolean = true;
-        private static var _currentHierarchy:HierarchicalCollectionView;
-        private static var _sut:HierarchicalCollectionViewCursor;
-        private static var _operationCursor:HierarchicalCollectionViewCursor;
-        public static var selectionAndRemovalLocations:Array = [[10, 8, 1], [11, 7, 1], [11, 6, 2], [19, 17, 1]];
-
-        private static var foo:Parameterized;
-
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-        }
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-			_currentHierarchy = null;
-			_operationCursor = null;
-		}
-
-        [Test(dataProvider="selectionAndRemovalLocations")]
-        public function testReproduce_FLEX_34424(selectedItemIndex:int, removalIndex:int, noItemsToRemove:int):void
-        {
-			//WHEN
-			//1. Select a specific node
-			_sut.seek(new CursorBookmark(selectedItemIndex));
-			
-            var selectedNode:DataNode = DataNode(_sut.current);
-            assertNotNull(selectedNode);
-		    selectedNode.isSelected = true;
-
-            //2. Perform removal
-			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-			_operationCursor.seek(new CursorBookmark(removalIndex));
-		    performRemoval(_operationCursor, noItemsToRemove);
-
-            //THEN
-            assertTrue(_noErrorsThrown);
-            assertEquals(selectedNode, _sut.current);
-        }
-		
-        private static function performRemoval(where:HierarchicalCollectionViewCursor, noItemsToRemove:int):void
-        {
-            var itemToBeRemoved:DataNode = where.current as DataNode;
-            assertNotNull(itemToBeRemoved);
-
-            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeRemoved) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var removedItemIndex:int = collectionToChange.getItemIndex(itemToBeRemoved);
-
-            if(noItemsToRemove == 1)
-                collectionToChange.removeItemAt(removedItemIndex);
-            else {//note that this assumes the collection is not filtered or sorted; for this test the assumption holds.
-                var removedItems:Array = collectionToChange.source.splice(removedItemIndex, noItemsToRemove);
-                //fake a CollectionEventKind.REMOVE event with more than one item removed
-                collectionToChange.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE, false, false, CollectionEventKind.REMOVE, removedItemIndex, -1, removedItems));
-            }
-        }
-
-
-
-		
-		
-		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n FAIL: " + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-         Region(1)
-         Region(2)
-		 Region(2)->City(0)
-         Region(2)->City(1)
-         Region(2)->City(1)->Company(1)
-         Region(2)->City(1)->Company(2)
-         Region(2)->City(1)->Company(2)->Department(1)
-         Region(2)->City(1)->Company(2)->Department(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(2)->Employee(3)
-         Region(2)->City(1)->Company(2)->Department(3)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(1)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(2)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(3)
-         Region(2)->City(1)->Company(2)->Department(3)->Employee(4)
-         Region(2)->City(1)->Company(3)
-         Region(2)->City(1)->Company(3)->Department(1)
-         Region(2)->City(1)->Company(3)->Department(1)->Employee(1)
-         Region(2)->City(1)->Company(3)->Department(2)
-       ]]>).toString();
-	}
-}
\ No newline at end of file


Re: [14/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34119 Running the over 10, 000 parameterized tests in the ant test runner takes over an hour! (On my computer it only takes a bit above three minutes.) I'm ignoring this for now.

Posted by Mihai Chira <mi...@apache.org>.
Should I un-ignore this test, to see if it's faster on the server? (On
my machine, in IntelliJ it finishes in three minutes.) I guess it's so
slow because it's writing the reports to disk while running?

Also, now that it's ignored, FlexUnit (Flash, really) throws a stack
overflow error at around 10% of the 10,000+ parameterised tests
because it goes through each of them and then ignores it, and because
it's only the arguments that change, I guess it thinks it's stuck in
an infinite loop. Is this avoidable? Is it possible to write an
[Ignore] tag which will make the test runner ignore all parameterised
versions of that function at once, instead of having it go through
each of them?

On 10 March 2015 at 17:44,  <mi...@apache.org> wrote:
> FLEX-34119 Running the over 10,000 parameterized tests in the ant test runner takes over an hour! (On my computer it only takes a bit above three minutes.) I'm ignoring this for now.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/410945f0
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/410945f0
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/410945f0
>
> Branch: refs/heads/develop
> Commit: 410945f0f78f889147d83e4fb07a5c5ce56c71bf
> Parents: f7fcf12
> Author: Mihai Chira <mi...@apache.org>
> Authored: Tue Mar 10 17:30:19 2015 +0100
> Committer: Mihai Chira <mi...@apache.org>
> Committed: Tue Mar 10 17:30:19 2015 +0100
>
> ----------------------------------------------------------------------
>  .../HierarchicalCollectionViewCursor_FLEX_34119_Tests.as          | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/410945f0/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
> index 5119ed4..e378c6c 100644
> --- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
> +++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
> @@ -136,7 +136,8 @@ package mx.collections
>                         assertEquals(secondCompany, _sut.current);
>                         assertTrue(_noErrorsThrown);
>                 }
> -
> +
> +        [Ignore]
>                 [Test(dataProvider="positionAndOperation")]
>          public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
>          {
>

[14/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34119 Running the over 10, 000 parameterized tests in the ant test runner takes over an hour! (On my computer it only takes a bit above three minutes.) I'm ignoring this for now.

Posted by mi...@apache.org.
FLEX-34119 Running the over 10,000 parameterized tests in the ant test runner takes over an hour! (On my computer it only takes a bit above three minutes.) I'm ignoring this for now.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/410945f0
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/410945f0
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/410945f0

Branch: refs/heads/develop
Commit: 410945f0f78f889147d83e4fb07a5c5ce56c71bf
Parents: f7fcf12
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 17:30:19 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 17:30:19 2015 +0100

----------------------------------------------------------------------
 .../HierarchicalCollectionViewCursor_FLEX_34119_Tests.as          | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/410945f0/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
index 5119ed4..e378c6c 100644
--- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34119_Tests.as
@@ -136,7 +136,8 @@ package mx.collections
 			assertEquals(secondCompany, _sut.current);
 			assertTrue(_noErrorsThrown);
 		}
-		
+
+        [Ignore]
        	[Test(dataProvider="positionAndOperation")]
         public function testReproduce_FLEX_34119_Comprehensive(selectedItemIndex:int, operationIndex:int, operation:int):void
         {


[12/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34458 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured

Posted by mi...@apache.org.
FLEX-34458 moved the unit test where it can be run by 'ant test'. Also, the main test runner is an Application, rather than a WindowedApplication, so I changed how uncaught client errors are captured to reflect this.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/143a23cd
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/143a23cd
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/143a23cd

Branch: refs/heads/develop
Commit: 143a23cd34fdb22b34f704a356ae1443bc5edf1c
Parents: 939c510
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 17:00:34 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 17:00:34 2015 +0100

----------------------------------------------------------------------
 ...icalCollectionViewCursor_FLEX_34458_Tests.as | 126 ++++++++++++++++++
 ...hicalCollectionViewCursor_FLEX_34458_Test.as | 132 -------------------
 2 files changed, 126 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/143a23cd/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Tests.as
new file mode 100644
index 0000000..963e780
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Tests.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+    import mx.core.FlexGlobals;
+
+    import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
+    import org.flexunit.asserts.assertTrue;
+
+    import spark.components.Application;
+
+    public class HierarchicalCollectionViewCursor_FLEX_34458_Tests
+	{
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _noErrorsThrown:Boolean = true;
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _sut:HierarchicalCollectionViewCursor;
+        private static var _operationCursor:HierarchicalCollectionViewCursor;
+
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+        }
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+			_currentHierarchy = null;
+			_operationCursor = null;
+		}
+
+       	[Test]
+        public function testReproduce_FLEX_34458():void
+        {
+			//WHEN
+			//1. Select a specific node
+			_sut.moveToLast();
+            _sut.movePrevious(); //Region(2)->City(3), with currentChildBookmark == CursorBookmark.LAST
+			
+            var selectedNode:DataNode = DataNode(_sut.current);
+            assertNotNull(selectedNode);
+		    selectedNode.isSelected = true;
+
+            //2. Remove previous region
+            _operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+            _operationCursor.seek(CursorBookmark.FIRST, 3); //Region(2)->City(1)
+            performRemoval(_operationCursor);
+
+            //THEN
+            assertTrue(_noErrorsThrown);
+            assertEquals(selectedNode, _sut.current);
+        }
+
+
+        private static function performRemoval(where:HierarchicalCollectionViewCursor):void
+        {
+            var itemToBeRemoved:DataNode = where.current as DataNode;
+            assertNotNull(itemToBeRemoved);
+
+            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeRemoved) as DataNode;
+            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            var removedItemIndex:int = collectionToChange.getItemIndex(itemToBeRemoved);
+            collectionToChange.removeItemAt(removedItemIndex);
+        }
+
+		
+		
+		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n FAIL: " + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+         Region(1)
+         Region(2)
+		 Region(2)->City(0)
+         Region(2)->City(1)
+         Region(2)->City(2)
+         Region(2)->City(3)
+         Region(3)
+       ]]>).toString();
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/143a23cd/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Test.as b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Test.as
deleted file mode 100644
index 34f0b2f..0000000
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Test.as
+++ /dev/null
@@ -1,132 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-import flash.events.UncaughtErrorEvent;
-
-import mx.collections.ArrayCollection;
-import mx.collections.CursorBookmark;
-import mx.collections.HierarchicalCollectionView;
-import mx.collections.HierarchicalCollectionViewCursor;
-import mx.core.FlexGlobals;
-
-    import org.flexunit.asserts.assertEquals;
-
-    import org.flexunit.asserts.assertNotNull;
-import org.flexunit.asserts.assertTrue;
-import org.flexunit.runners.Parameterized;
-
-import spark.components.WindowedApplication;
-
-public class HierarchicalCollectionViewCursor_FLEX_34458_Test
-	{
-        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-        private static var _noErrorsThrown:Boolean = true;
-        private static var _currentHierarchy:HierarchicalCollectionView;
-        private static var _sut:HierarchicalCollectionViewCursor;
-        private static var _operationCursor:HierarchicalCollectionViewCursor;
-
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-        }
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-                (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-			_currentHierarchy = _utils.generateOpenHierarchyFromRootListWithAllNodesMethod(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-			_sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-			_currentHierarchy = null;
-			_operationCursor = null;
-		}
-
-       	[Test]
-        public function testReproduce_FLEX_34458():void
-        {
-			//WHEN
-			//1. Select a specific node
-			_sut.moveToLast();
-            _sut.movePrevious(); //Region(2)->City(3), with currentChildBookmark == CursorBookmark.LAST
-			
-            var selectedNode:DataNode = DataNode(_sut.current);
-            assertNotNull(selectedNode);
-		    selectedNode.isSelected = true;
-
-            //2. Remove previous region
-            _operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-            _operationCursor.seek(CursorBookmark.FIRST, 3); //Region(2)->City(1)
-            performRemoval(_operationCursor);
-
-            //THEN
-            assertTrue(_noErrorsThrown);
-            assertEquals(selectedNode, _sut.current);
-        }
-
-
-        private static function performRemoval(where:HierarchicalCollectionViewCursor):void
-        {
-            var itemToBeRemoved:DataNode = where.current as DataNode;
-            assertNotNull(itemToBeRemoved);
-
-            var parentOfReplacementLocation:DataNode = _currentHierarchy.getParentItem(itemToBeRemoved) as DataNode;
-            var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children : _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            var removedItemIndex:int = collectionToChange.getItemIndex(itemToBeRemoved);
-            collectionToChange.removeItemAt(removedItemIndex);
-        }
-
-		
-		
-		private static function onUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n FAIL: " + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-
-        private static const HIERARCHY_STRING:String = (<![CDATA[
-         Region(1)
-         Region(2)
-		 Region(2)->City(0)
-         Region(2)->City(1)
-         Region(2)->City(2)
-         Region(2)->City(3)
-         Region(3)
-       ]]>).toString();
-	}
-}
\ No newline at end of file


[06/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34119 our test runner seems to be an Application, rather than WindowedApplication. Now the unit test reflects that.

Posted by mi...@apache.org.
FLEX-34119 our test runner seems to be an Application, rather than WindowedApplication. Now the unit test reflects that.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/3e27fadc
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/3e27fadc
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/3e27fadc

Branch: refs/heads/develop
Commit: 3e27fadca8ebb61990ed7f9ecf467bd819a2c4b8
Parents: 45707ff
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 13:43:37 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 13:43:37 2015 +0100

----------------------------------------------------------------------
 ...archicalCollectionViewCursor_Basics_Tests.as | 115 +++++++++----------
 1 file changed, 55 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/3e27fadc/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
index c2bd0cb..93cd2d9 100644
--- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
@@ -20,60 +20,55 @@
 package mx.collections
 {
     import flash.events.UncaughtErrorEvent;
+    import flash.utils.describeType;
 
-import flashx.textLayout.debug.assert;
-
-import mx.collections.ArrayCollection;
-    import mx.collections.CursorBookmark;
-    import mx.collections.HierarchicalCollectionView;
-    import mx.collections.HierarchicalCollectionViewCursor;
     import mx.core.FlexGlobals;
-    
-    import spark.components.WindowedApplication;
-    
+
     import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertNotNull;
 
-    public class HierarchicalCollectionViewCursor_Basics_Test
+    import spark.components.Application;
+
+    public class HierarchicalCollectionViewCursor_Basics_Tests
 	{
-		private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-		private static var _currentHierarchy:HierarchicalCollectionView;
-		private static var _noErrorsThrown:Boolean = true;
-		private var _level0:ArrayCollection;
-		
-		private var _sut:HierarchicalCollectionViewCursor;
-		
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
+        private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+        private static var _currentHierarchy:HierarchicalCollectionView;
+        private static var _noErrorsThrown:Boolean = true;
+        private var _level0:ArrayCollection;
+
+        private var _sut:HierarchicalCollectionViewCursor;
+
+        [BeforeClass]
+        public static function setUpBeforeClass():void
+        {
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+        }
+
+        [AfterClass]
+        public static function tearDownAfterClass():void
+        {
+            if(FlexGlobals.topLevelApplication is Application)
+                (FlexGlobals.topLevelApplication as Application).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+        }
+
+        [Before]
+        public function setUp():void
+        {
             _currentHierarchy = generateHierarchyViewWithOpenNodes();
             _level0 = _utils.getRoot(_currentHierarchy) as ArrayCollection;
             _sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
 
-			_noErrorsThrown = true;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
+            _noErrorsThrown = true;
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
             _currentHierarchy = null;
             _level0 = null;
-		}
-
+        }
 
 
         [Test]
@@ -223,23 +218,23 @@ import mx.collections.ArrayCollection;
             //then
             assertEquals(firstLocation, _sut.current);
         }
-		
-		
-		private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n" + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-		
-		private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
-		{
-			return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-		}
+
+
+        private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
+        {
+            event.preventDefault();
+            event.stopImmediatePropagation();
+            _noErrorsThrown = false;
+
+            trace("\n" + event.error);
+            _utils.printHCollectionView(_currentHierarchy);
+        }
+
+
+        private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
+        {
+            return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+        }
 
 		private static const HIERARCHY_STRING:String = (<![CDATA[
 			Company(1)


[05/14] git commit: [flex-sdk] [refs/heads/develop] - FLEX-34119 renamed the test to the format expected by the ant test script.

Posted by mi...@apache.org.
FLEX-34119 renamed the test to the format expected by the ant test script.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/45707ff0
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/45707ff0
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/45707ff0

Branch: refs/heads/develop
Commit: 45707ff0981c5c75cf2bf24e839e23c5c6ed1f13
Parents: 4cb597a
Author: Mihai Chira <mi...@apache.org>
Authored: Tue Mar 10 13:26:46 2015 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Tue Mar 10 13:26:46 2015 +0100

----------------------------------------------------------------------
 ...rarchicalCollectionViewCursor_Basics_Test.as | 262 -------------------
 ...archicalCollectionViewCursor_Basics_Tests.as | 262 +++++++++++++++++++
 2 files changed, 262 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/45707ff0/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
deleted file mode 100644
index c2bd0cb..0000000
--- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Test.as
+++ /dev/null
@@ -1,262 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-package mx.collections
-{
-    import flash.events.UncaughtErrorEvent;
-
-import flashx.textLayout.debug.assert;
-
-import mx.collections.ArrayCollection;
-    import mx.collections.CursorBookmark;
-    import mx.collections.HierarchicalCollectionView;
-    import mx.collections.HierarchicalCollectionViewCursor;
-    import mx.core.FlexGlobals;
-    
-    import spark.components.WindowedApplication;
-    
-    import org.flexunit.asserts.assertEquals;
-
-    public class HierarchicalCollectionViewCursor_Basics_Test
-	{
-		private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
-		private static var _currentHierarchy:HierarchicalCollectionView;
-		private static var _noErrorsThrown:Boolean = true;
-		private var _level0:ArrayCollection;
-		
-		private var _sut:HierarchicalCollectionViewCursor;
-		
-		[BeforeClass]
-		public static function setUpBeforeClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[AfterClass]
-		public static function tearDownAfterClass():void
-		{
-            if(FlexGlobals.topLevelApplication is WindowedApplication)
-			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
-		}
-		
-		[Before]
-		public function setUp():void
-		{
-            _currentHierarchy = generateHierarchyViewWithOpenNodes();
-            _level0 = _utils.getRoot(_currentHierarchy) as ArrayCollection;
-            _sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-
-			_noErrorsThrown = true;
-		}
-		
-		[After]
-		public function tearDown():void
-		{
-			_sut = null;
-            _currentHierarchy = null;
-            _level0 = null;
-		}
-
-
-
-        [Test]
-        public function testMovingAround():void
-        {
-            //given
-            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var firstDepartment:DataNode = firstLocation.children.getItemAt(0) as DataNode;
-            var secondDepartment:DataNode = firstLocation.children.getItemAt(1) as DataNode;
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(firstDepartment, _sut.current);
-
-            //when
-            _sut.moveNext();
-
-            //then
-            assertEquals(secondDepartment, _sut.current);
-
-            //when
-            _sut.movePrevious();
-
-            //then
-            assertEquals(firstDepartment, _sut.current);
-
-            //when
-            _sut.moveToLast();
-
-            //then
-            assertEquals(lastCompany, _sut.current);
-
-            //when
-            _sut.seek(new CursorBookmark(4));
-
-            //then
-            assertEquals(secondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testCollectionChangeInRootDoesNotChangeCurrent():void
-        {
-            //given
-            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
-
-            //when
-            _sut.moveToLast();
-
-            var newFirstCompany:DataNode = _utils.createSimpleNode("[INS] Company");
-            _level0.addItemAt(newFirstCompany, 0);
-
-            var newLastCompany:DataNode = _utils.createSimpleNode("[INS] Company");
-            _level0.addItemAt(newLastCompany, _level0.length);
-
-            //then
-            assertEquals(lastCompany, _sut.current);
-
-            //when
-            _sut.moveToLast();
-
-            //then
-            assertEquals(newLastCompany, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingCurrentMiddleItemChangesCurrentToNextItem():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var thirdDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(2) as DataNode;
-
-            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
-
-            //when
-            secondLocation.children.removeItemAt(1);
-
-            //then
-            assertEquals(thirdDepartmentOfSecondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingPreviousSiblingOfCurrentMiddleItemDoesNotChangeCurrent():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
-            var secondDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(1) as DataNode;
-
-            //when
-            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
-
-            //then
-            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
-
-            //when
-            secondLocation.children.removeItemAt(0);
-
-            //then
-            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingCurrentFirstItemChangesCurrentToNextItem():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var secondCompany:DataNode = _level0.getItemAt(1) as DataNode;
-
-            //initial assumption
-            assertEquals(firstCompany, _sut.current);
-
-            //when
-            _level0.removeItemAt(0);
-
-            //then
-            assertEquals(secondCompany, _sut.current);
-        }
-
-        [Test]
-        public function testRemovingSiblingOfCurrentFirstItemDoesNotChangeCurrent():void
-        {
-            //given
-            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
-            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
-
-            //when
-            _sut.seek(new CursorBookmark(1)); //Company(1)->Location(1)
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-
-            //when
-            firstCompany.children.removeItemAt(1);
-
-            //then
-            assertEquals(firstLocation, _sut.current);
-        }
-		
-		
-		private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
-		{
-			event.preventDefault();
-			event.stopImmediatePropagation();
-			_noErrorsThrown = false;
-			
-			trace("\n" + event.error);
-			_utils.printHCollectionView(_currentHierarchy);
-		}
-
-		
-		private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
-		{
-			return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
-		}
-
-		private static const HIERARCHY_STRING:String = (<![CDATA[
-			Company(1)
-			Company(1)->Location(1)
-			Company(1)->Location(1)->Department(1)
-			Company(1)->Location(1)->Department(2)
-			Company(1)->Location(2)
-			Company(1)->Location(2)->Department(1)
-			Company(1)->Location(2)->Department(2)
-			Company(1)->Location(2)->Department(3)
-			Company(1)->Location(3)
-			Company(2)
-			Company(2)->Location(1)
-			Company(2)->Location(2)
-			Company(2)->Location(2)->Department(1)
-			Company(2)->Location(3)
-			Company(3)
-		]]>).toString();
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/45707ff0/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
new file mode 100644
index 0000000..c2bd0cb
--- /dev/null
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_Basics_Tests.as
@@ -0,0 +1,262 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.collections
+{
+    import flash.events.UncaughtErrorEvent;
+
+import flashx.textLayout.debug.assert;
+
+import mx.collections.ArrayCollection;
+    import mx.collections.CursorBookmark;
+    import mx.collections.HierarchicalCollectionView;
+    import mx.collections.HierarchicalCollectionViewCursor;
+    import mx.core.FlexGlobals;
+    
+    import spark.components.WindowedApplication;
+    
+    import org.flexunit.asserts.assertEquals;
+
+    public class HierarchicalCollectionViewCursor_Basics_Test
+	{
+		private static var _utils:HierarchicalCollectionViewTestUtils = new HierarchicalCollectionViewTestUtils();
+		private static var _currentHierarchy:HierarchicalCollectionView;
+		private static var _noErrorsThrown:Boolean = true;
+		private var _level0:ArrayCollection;
+		
+		private var _sut:HierarchicalCollectionViewCursor;
+		
+		[BeforeClass]
+		public static function setUpBeforeClass():void
+		{
+            if(FlexGlobals.topLevelApplication is WindowedApplication)
+			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+		}
+		
+		[AfterClass]
+		public static function tearDownAfterClass():void
+		{
+            if(FlexGlobals.topLevelApplication is WindowedApplication)
+			    (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.removeEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtClientError);
+		}
+		
+		[Before]
+		public function setUp():void
+		{
+            _currentHierarchy = generateHierarchyViewWithOpenNodes();
+            _level0 = _utils.getRoot(_currentHierarchy) as ArrayCollection;
+            _sut = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
+
+			_noErrorsThrown = true;
+		}
+		
+		[After]
+		public function tearDown():void
+		{
+			_sut = null;
+            _currentHierarchy = null;
+            _level0 = null;
+		}
+
+
+
+        [Test]
+        public function testMovingAround():void
+        {
+            //given
+            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var firstDepartment:DataNode = firstLocation.children.getItemAt(0) as DataNode;
+            var secondDepartment:DataNode = firstLocation.children.getItemAt(1) as DataNode;
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(firstDepartment, _sut.current);
+
+            //when
+            _sut.moveNext();
+
+            //then
+            assertEquals(secondDepartment, _sut.current);
+
+            //when
+            _sut.movePrevious();
+
+            //then
+            assertEquals(firstDepartment, _sut.current);
+
+            //when
+            _sut.moveToLast();
+
+            //then
+            assertEquals(lastCompany, _sut.current);
+
+            //when
+            _sut.seek(new CursorBookmark(4));
+
+            //then
+            assertEquals(secondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testCollectionChangeInRootDoesNotChangeCurrent():void
+        {
+            //given
+            var lastCompany:DataNode = _level0.getItemAt(_level0.length - 1) as DataNode;
+
+            //when
+            _sut.moveToLast();
+
+            var newFirstCompany:DataNode = _utils.createSimpleNode("[INS] Company");
+            _level0.addItemAt(newFirstCompany, 0);
+
+            var newLastCompany:DataNode = _utils.createSimpleNode("[INS] Company");
+            _level0.addItemAt(newLastCompany, _level0.length);
+
+            //then
+            assertEquals(lastCompany, _sut.current);
+
+            //when
+            _sut.moveToLast();
+
+            //then
+            assertEquals(newLastCompany, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingCurrentMiddleItemChangesCurrentToNextItem():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var thirdDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(2) as DataNode;
+
+            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
+
+            //when
+            secondLocation.children.removeItemAt(1);
+
+            //then
+            assertEquals(thirdDepartmentOfSecondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingPreviousSiblingOfCurrentMiddleItemDoesNotChangeCurrent():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondLocation:DataNode = firstCompany.children.getItemAt(1) as DataNode;
+            var secondDepartmentOfSecondLocation:DataNode = secondLocation.children.getItemAt(1) as DataNode;
+
+            //when
+            _sut.seek(new CursorBookmark(6)); //Company(1)->Location(2)->Department(2)
+
+            //then
+            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
+
+            //when
+            secondLocation.children.removeItemAt(0);
+
+            //then
+            assertEquals(secondDepartmentOfSecondLocation, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingCurrentFirstItemChangesCurrentToNextItem():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var secondCompany:DataNode = _level0.getItemAt(1) as DataNode;
+
+            //initial assumption
+            assertEquals(firstCompany, _sut.current);
+
+            //when
+            _level0.removeItemAt(0);
+
+            //then
+            assertEquals(secondCompany, _sut.current);
+        }
+
+        [Test]
+        public function testRemovingSiblingOfCurrentFirstItemDoesNotChangeCurrent():void
+        {
+            //given
+            var firstCompany:DataNode = _level0.getItemAt(0) as DataNode;
+            var firstLocation:DataNode = firstCompany.children.getItemAt(0) as DataNode;
+
+            //when
+            _sut.seek(new CursorBookmark(1)); //Company(1)->Location(1)
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+
+            //when
+            firstCompany.children.removeItemAt(1);
+
+            //then
+            assertEquals(firstLocation, _sut.current);
+        }
+		
+		
+		private static function handleUncaughtClientError(event:UncaughtErrorEvent):void
+		{
+			event.preventDefault();
+			event.stopImmediatePropagation();
+			_noErrorsThrown = false;
+			
+			trace("\n" + event.error);
+			_utils.printHCollectionView(_currentHierarchy);
+		}
+
+		
+		private static function generateHierarchyViewWithOpenNodes():HierarchicalCollectionView
+		{
+			return _utils.generateOpenHierarchyFromRootList(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
+		}
+
+		private static const HIERARCHY_STRING:String = (<![CDATA[
+			Company(1)
+			Company(1)->Location(1)
+			Company(1)->Location(1)->Department(1)
+			Company(1)->Location(1)->Department(2)
+			Company(1)->Location(2)
+			Company(1)->Location(2)->Department(1)
+			Company(1)->Location(2)->Department(2)
+			Company(1)->Location(2)->Department(3)
+			Company(1)->Location(3)
+			Company(2)
+			Company(2)->Location(1)
+			Company(2)->Location(2)
+			Company(2)->Location(2)->Department(1)
+			Company(2)->Location(3)
+			Company(3)
+		]]>).toString();
+	}
+}
\ No newline at end of file