flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mih...@apache.org
Subject git commit: [flex-sdk] [refs/heads/develop] - FLEX-34775 Improved unit tests.
Date Thu, 05 Mar 2015 16:58:09 GMT
Repository: flex-sdk
Updated Branches:
  refs/heads/develop cc2ccf6a0 -> f34fc4446


FLEX-34775 Improved unit tests.


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

Branch: refs/heads/develop
Commit: f34fc444622c4a592ba58da130514fe58891ba43
Parents: cc2ccf6
Author: Mihai Chira <mihaic@apache.org>
Authored: Thu Mar 5 17:57:43 2015 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Thu Mar 5 17:57:43 2015 +0100

----------------------------------------------------------------------
 ...erarchicalCollectionView_FLEX_34775_Tests.as | 133 ++++++++++++++-----
 1 file changed, 102 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f34fc444/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
index e4eeccd..2b07605 100644
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionView_FLEX_34775_Tests.as
@@ -19,61 +19,132 @@
 
 package mx.collections
 {
+    import 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
-		{
+    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
-		{
+        }
+
+        [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_opening_hidden_node():void
+        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);
 
-            var cursor:IViewCursor = _sut.createCursor();
+            //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();
             }
 
-            //then
-            assertEquals(1, i);
-            assertEquals(1, _sut.length);
+            return i;
+        }
+
+        private static function generateHierarchyViewWithClosedNodes():HierarchicalCollectionView
+        {
+            return _utils.generateHCV(_utils.generateHierarchySourceFromString(HIERARCHY_STRING));
         }
 
-		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();
-	}
+        private static const HIERARCHY_STRING:String = (<![CDATA[
+                Adobe
+        Adobe->London
+        Adobe->London->FlexDept
+    ]]>).toString();
+    }
 }
\ No newline at end of file


Mime
View raw message