flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mih...@apache.org
Subject [1/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35031 Added more unit tests to define how findAny() and findLast() should work, for when I attempt fixes for this bug. -By adding more unit tests I also found that null as a parameter to findAny()
Date Tue, 16 Feb 2016 13:00:43 GMT
Repository: flex-sdk
Updated Branches:
  refs/heads/develop ea13945b4 -> 6a26ebb07


FLEX-35031
Added more unit tests to define how findAny() and findLast() should work, for when I attempt
fixes for this bug.
-By adding more unit tests I also found that null as a parameter to findAny() or findLast()
makes the cursor think it's found that value.


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

Branch: refs/heads/develop
Commit: d072e9e2d39a00f59fab89c3f9bba3c9fb934e4f
Parents: ea13945
Author: Mihai Chira <mihaic@apache.org>
Authored: Tue Feb 16 13:39:02 2016 +0100
Committer: Mihai Chira <mihaic@apache.org>
Committed: Tue Feb 16 13:39:02 2016 +0100

----------------------------------------------------------------------
 ...rchicalCollectionViewCursor_FindAny_Tests.as | 132 ++++++++++++++++++-
 1 file changed, 130 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d072e9e2/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 525300e..36708d0 100644
--- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
+++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
@@ -19,6 +19,8 @@
 
 package mx.collections {
     import org.flexunit.asserts.assertEquals;
+    import org.flexunit.asserts.assertFalse;
+    import org.flexunit.asserts.assertNotNull;
     import org.flexunit.asserts.assertTrue;
 
     public class HierarchicalCollectionViewCursor_FindAny_Tests
@@ -112,7 +114,7 @@ package mx.collections {
         }
 
         [Test] //FLEX-35031
-        public function test_FLEX_35031_finding_sealed_class_instance():void
+        public function test_FLEX_35031_finding_current_sealed_class_instance_with_findFirst():void
         {
             //given
             _utils.openAllNodes(_collectionView);
@@ -129,7 +131,41 @@ package mx.collections {
         }
 
         [Test] //FLEX-35031
-        public function test_FLEX_35031_finding_sealed_class_instance_with_findLast():void
+        public function test_FLEX_35031_finding_different_sealed_class_instance_with_findAny():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+            var salesGroup:Object = _level0.getItemAt(1);
+            var salesEmployee:EmployeeVO = salesGroup.children.getItemAt(0) as EmployeeVO;
+            assertEquals(DEPARTMENT_SALES, salesEmployee.department);
+
+            //when
+            var found:Boolean = _sut.findAny(salesEmployee);
+
+            //then
+            assertTrue(found);
+            assertEquals(salesEmployee, _sut.current);
+        }
+
+        [Test] //FLEX-35031
+        public function test_FLEX_35031_finding_different_sealed_class_instance_with_findLast():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+            var developmentGroup:Object = _level0.getItemAt(0);
+            var developmentEmployee:EmployeeVO = developmentGroup.children.getItemAt(0) as
EmployeeVO;
+            assertEquals(DEPARTMENT_DEVELOPMENT, developmentEmployee.department);
+
+            //when
+            var found:Boolean = _sut.findLast(developmentEmployee);
+
+            //then
+            assertTrue(found);
+            assertEquals(developmentEmployee, _sut.current);
+        }
+
+        [Test] //FLEX-35031
+        public function test_FLEX_35031_finding_sealed_class_instance_from_current_with_findLast():void
         {
             //given
             _utils.openAllNodes(_collectionView);
@@ -145,6 +181,98 @@ package mx.collections {
             assertEquals(DEPARTMENT_DEVELOPMENT, EmployeeVO(_sut.current).department);
         }
 
+        [Test] //FLEX-33058
+        public function test_FLEX_33058_when_not_found_via_findAny_using_anonymous_object_current_is_null():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findAny({someProperty:"someValue"});
+
+            //then
+            assertFalse(found);
+            assertEquals(null, _sut.current);
+        }
+
+        [Test] //FLEX-33058
+        public function test_FLEX_33058_when_not_found_via_findLast_using_anonymous_object_current_is_null():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findLast({someProperty:"someValue"});
+
+            //then
+            assertFalse(found);
+            assertEquals(null, _sut.current);
+        }
+
+        [Test] //FLEX-35031
+        public function test_FLEX_35031_findAny_does_not_fatal_when_trying_to_find_null_and_doesnt_find_it():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findAny(null);
+
+            //then
+            assertFalse(found);
+            assertEquals(null, _sut.current);
+        }
+
+        [Test] //FLEX-35031
+        public function test_FLEX_35031_findLast_does_not_fatal_when_trying_to_find_null_and_doesnt_find_it():void
+        {
+            //given
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findLast(null);
+
+            //then
+            assertFalse(found);
+            assertEquals(null, _sut.current);
+        }
+
+        [Test]
+        public function test_findAny_finds_sealed_class_instance_via_anonymous_object_with_subset_of_properties():void
+        {
+            //given
+            const ID_TO_FIND:int = 1;
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findAny({department:DEPARTMENT_SALES, idInDepartment:ID_TO_FIND});
+
+            //then
+            assertTrue(found);
+            var currentEmployee:EmployeeVO = _sut.current as EmployeeVO;
+            assertNotNull(currentEmployee);
+            assertEquals(DEPARTMENT_SALES, currentEmployee.department);
+            assertEquals(ID_TO_FIND, currentEmployee.idInDepartment);
+        }
+
+        [Test]
+        public function test_findLast_finds_sealed_class_instance_via_anonymous_object_with_subset_of_properties():void
+        {
+            //given
+            const ID_TO_FIND:int = 1;
+            _utils.openAllNodes(_collectionView);
+
+            //when
+            var found:Boolean = _sut.findLast({department:DEPARTMENT_DEVELOPMENT, idInDepartment:ID_TO_FIND});
+
+            //then
+            assertTrue(found);
+            var currentEmployee:EmployeeVO = _sut.current as EmployeeVO;
+            assertNotNull(currentEmployee);
+            assertEquals(DEPARTMENT_DEVELOPMENT, currentEmployee.department);
+            assertEquals(ID_TO_FIND, currentEmployee.idInDepartment);
+        }
+
         private static function createHierarchicalCollectionView(groupingCollection:GroupingCollection2):HierarchicalCollectionView
         {
             return new HierarchicalCollectionView(groupingCollection);


Mime
View raw message