Repository: flex-sdk
Updated Branches:
  refs/heads/develop ca0db33d8 -> ea13945b4


FLEX-35031
Just noticed that findLast uses the same algorithm as findAny, so I added a 
unit test which reproduces the bug there as well, and renamed some of the local 
variables in a similar way to the recent findAny() renames.
-Also added unit tests to make sure that searching via partial objects works.


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

Branch: refs/heads/develop
Commit: ea13945b42cdcb8e1727ba30c0927c9c663a803a
Parents: ca0db33
Author: Mihai Chira <[email protected]>
Authored: Tue Feb 16 13:06:03 2016 +0100
Committer: Mihai Chira <[email protected]>
Committed: Tue Feb 16 13:06:03 2016 +0100

----------------------------------------------------------------------
 .../HierarchicalCollectionViewCursor.as         |  8 +--
 ...rchicalCollectionViewCursor_FindAny_Tests.as | 51 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ea13945b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
 
b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
index ee6268b..bb5a19b 100644
--- 
a/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
+++ 
b/frameworks/projects/advancedgrids/src/mx/collections/HierarchicalCollectionViewCursor.as
@@ -372,19 +372,19 @@ public class HierarchicalCollectionViewCursor extends 
EventDispatcher
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
      */
-    public function findLast(values:Object):Boolean
+    public function findLast(valuesToMatch:Object):Boolean
     {
         seek(CursorBookmark.LAST);
         
         var done:Boolean = false;
         while (!done)
         {
-            var o:Object = current; 
+            var currentData:Object = current;
             
             var matches:Boolean = true;
-            for (var p:String in values)
+            for (var property:String in valuesToMatch)
             {
-                if (o[p] != values[p])
+                if (currentData[property] != valuesToMatch[property])
                 {
                     matches = false;
                     break;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/ea13945b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
 
b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
index aa9898f..525300e 100644
--- 
a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
+++ 
b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
@@ -63,6 +63,40 @@ package mx.collections {
         }
 
         [Test]
+        public function 
test_searching_for_sales_using_anonymous_object_lands_on_sales_group():void
+        {
+            //given
+            var salesIdentifier:Object = {GroupLabel:DEPARTMENT_SALES};
+
+            //when
+            var found:Boolean = _sut.findAny(salesIdentifier);
+
+            //then
+            assertTrue(found);
+
+            var current:Object = _sut.current;
+            assertTrue(current.hasOwnProperty("GroupLabel"));
+            assertEquals(DEPARTMENT_SALES, current["GroupLabel"]);
+        }
+
+        [Test]
+        public function 
test_searching_for_sales_via_findLast_using_anonymous_object_lands_on_sales_group():void
+        {
+            //given
+            var salesIdentifier:Object = {GroupLabel:DEPARTMENT_SALES};
+
+            //when
+            var found:Boolean = _sut.findLast(salesIdentifier);
+
+            //then
+            assertTrue(found);
+
+            var current:Object = _sut.current;
+            assertTrue(current.hasOwnProperty("GroupLabel"));
+            assertEquals(DEPARTMENT_SALES, current["GroupLabel"]);
+        }
+
+        [Test]
         public function test_finding_current_leaves_first_unchanged():void
         {
             //given
@@ -94,6 +128,23 @@ package mx.collections {
             assertEquals(DEPARTMENT_DEVELOPMENT, 
EmployeeVO(_sut.current).department);
         }
 
+        [Test] //FLEX-35031
+        public function 
test_FLEX_35031_finding_sealed_class_instance_with_findLast():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+            _sut.seek(new CursorBookmark(CursorBookmark.FIRST));
+            _sut.moveNext(); //an EmployeeVO instance from the "Development" 
department
+
+            //when
+            var found:Boolean = _sut.findLast(_sut.current);
+
+            //then
+            assertTrue(found);
+            assertTrue(_sut.current is EmployeeVO);
+            assertEquals(DEPARTMENT_DEVELOPMENT, 
EmployeeVO(_sut.current).department);
+        }
+
         private static function 
createHierarchicalCollectionView(groupingCollection:GroupingCollection2):HierarchicalCollectionView
         {
             return new HierarchicalCollectionView(groupingCollection);

Reply via email to