flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bigosma...@apache.org
Subject [25/50] git commit: [flex-sdk] [refs/heads/new_android_skins] - FLEX-34424 Improved the unit test by making it parameterized and adding a few more cases.
Date Sun, 17 Aug 2014 07:48:12 GMT
FLEX-34424 Improved the unit test by making it parameterized and adding a few more cases.


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

Branch: refs/heads/new_android_skins
Commit: cc5f71cd2161d0264ef1a178961eafe8d3ffc1ed
Parents: 4970df8
Author: Mihai Chira <mihaic@apache.org>
Authored: Mon Jul 28 17:23:22 2014 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Mon Jul 28 17:23:22 2014 +0100

----------------------------------------------------------------------
 ...hicalCollectionViewCursor_FLEX_34424_Test.as | 38 +++++++++++++-------
 1 file changed, 25 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/cc5f71cd/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
index 2927c16..8c2469c 100644
--- a/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34424_Test.as
@@ -7,6 +7,11 @@ 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;
@@ -14,6 +19,7 @@ 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();
@@ -21,6 +27,9 @@ public class HierarchicalCollectionViewCursor_FLEX_34424_Test
         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
@@ -49,12 +58,9 @@ public class HierarchicalCollectionViewCursor_FLEX_34424_Test
 			_operationCursor = null;
 		}
 
-       	[Test]
-        public function testReproduce_FLEX_34424():void
+        [Test(dataProvider="selectionAndRemovalLocations")]
+        public function testReproduce_FLEX_34424(selectedItemIndex:int, removalIndex:int,
noItemsToRemove:int):void
         {
-			//GIVEN
-			var selectedItemIndex:int = 10, operationIndex:int = 8;
-			
 			//WHEN
 			//1. Select a specific node
 			_sut.seek(new CursorBookmark(selectedItemIndex));
@@ -63,17 +69,17 @@ public class HierarchicalCollectionViewCursor_FLEX_34424_Test
             assertNotNull(selectedNode);
 		    selectedNode.isSelected = true;
 
-            //2. Perform setItemAt operation
+            //2. Perform removal
 			_operationCursor = _currentHierarchy.createCursor() as HierarchicalCollectionViewCursor;
-			_operationCursor.seek(new CursorBookmark(operationIndex));
-		    performRemoval(_operationCursor);
+			_operationCursor.seek(new CursorBookmark(removalIndex));
+		    performRemoval(_operationCursor, noItemsToRemove);
 
             //THEN
             assertTrue(_noErrorsThrown);
-            assertNotNull(_sut.current);
+            assertEquals(selectedNode, _sut.current);
         }
 		
-        private static function performRemoval(where:HierarchicalCollectionViewCursor):void
+        private static function performRemoval(where:HierarchicalCollectionViewCursor, noItemsToRemove:int):void
         {
             var itemToBeRemoved:DataNode = where.current as DataNode;
             assertNotNull(itemToBeRemoved);
@@ -82,7 +88,13 @@ public class HierarchicalCollectionViewCursor_FLEX_34424_Test
             var collectionToChange:ArrayCollection = parentOfReplacementLocation ? parentOfReplacementLocation.children
: _utils.getRoot(_currentHierarchy) as ArrayCollection;
             var removedItemIndex:int = collectionToChange.getItemIndex(itemToBeRemoved);
 
-            collectionToChange.removeItemAt(removedItemIndex);
+            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));
+            }
         }
 
 
@@ -109,9 +121,9 @@ public class HierarchicalCollectionViewCursor_FLEX_34424_Test
          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)TBR
+         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(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)


Mime
View raw message