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 2014/08/08 18:17:52 UTC
[09/10] git commit: [flex-sdk] [refs/heads/FLEX-34119] - FLEX-34458
Added a unit test which reproduces the bug (which means it currently fails).
FLEX-34458 Added a unit test which reproduces the bug (which means it currently fails).
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/979c7a8f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/979c7a8f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/979c7a8f
Branch: refs/heads/FLEX-34119
Commit: 979c7a8f69fb1f4697c11874e94220fe5c2106aa
Parents: 04bb0b2
Author: Mihai Chira <mi...@apache.org>
Authored: Fri Aug 8 15:44:21 2014 +0100
Committer: Mihai Chira <mi...@apache.org>
Committed: Fri Aug 8 15:44:21 2014 +0100
----------------------------------------------------------------------
...hicalCollectionViewCursor_FLEX_34458_Test.as | 111 +++++++++++++++++++
1 file changed, 111 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/979c7a8f/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
new file mode 100644
index 0000000..e875291
--- /dev/null
+++ b/frameworks/tests/unitTests/mx/collections/HierarchicalCollectionViewCursor_FLEX_34458_Test.as
@@ -0,0 +1,111 @@
+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
+ {
+ (FlexGlobals.topLevelApplication as WindowedApplication).loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onUncaughtClientError);
+ }
+
+ [AfterClass]
+ public static function tearDownAfterClass():void
+ {
+ (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