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/254c25af
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/254c25af
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/254c25af

Branch: refs/heads/master
Commit: 254c25afaf51f6419a8a711829c70d4ac64149dd
Parents: d8c1a9f
Author: Mihai Chira <mih...@apache.org>
Authored: Tue Mar 10 13:17:53 2015 +0100
Committer: Erik de Bruin <e...@ixsoftware.nl>
Committed: Fri Mar 20 09:51:22 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/254c25af/frameworks/build.xml
----------------------------------------------------------------------
diff --git a/frameworks/build.xml b/frameworks/build.xml
index 01ef156..ce5205f 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">
@@ -522,6 +523,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/254c25af/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/254c25af/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/254c25af/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/254c25af/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/254c25af/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/254c25af/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/254c25af/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

Reply via email to