Repository: flex-sdk Updated Branches: refs/heads/develop 6a26ebb07 -> e87c827b2
FLEX-35031 Added two more test functions to make explicit the assumption that searching by sealed class instances with a subset of the properties of the object to be found will NOT work (analogous to searching by anonymous objects with a subset of the properties of the target object, which should work, as documented in the same class), at least at the moment. There is no business case for it, and the framework itself doesn't seem to require it. -A couple of other minor changes, like removing unused imports and editing asdocs. Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/e87c827b Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/e87c827b Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/e87c827b Branch: refs/heads/develop Commit: e87c827b2abf5e1e58091a6a3d356f43113aeaa9 Parents: 6a26ebb Author: Mihai Chira <[email protected]> Authored: Wed Feb 17 10:11:12 2016 +0100 Committer: Mihai Chira <[email protected]> Committed: Wed Feb 17 10:11:12 2016 +0100 ---------------------------------------------------------------------- ...rchicalCollectionViewCursor_FindAny_Tests.as | 52 +++++++++++++++++++- .../src/mx/collections/ListCollectionView.as | 3 +- .../framework/src/mx/utils/ObjectUtil.as | 5 +- 3 files changed, 54 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/e87c827b/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 b5e9b90..5a64c03 100644 --- a/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as +++ b/frameworks/projects/advancedgrids/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as @@ -21,6 +21,7 @@ package mx.collections { import org.flexunit.asserts.assertEquals; import org.flexunit.asserts.assertFalse; import org.flexunit.asserts.assertNotNull; + import org.flexunit.asserts.assertNull; import org.flexunit.asserts.assertTrue; public class HierarchicalCollectionViewCursor_FindAny_Tests @@ -117,7 +118,7 @@ package mx.collections { } [Test] //FLEX-35031 - public function test_FLEX_35031_finding_current_sealed_class_instance_with_findFirst():void + public function test_FLEX_35031_finding_current_sealed_class_instance_with_findAny():void { //given _utils.openAllNodes(_collectionView); @@ -276,6 +277,45 @@ package mx.collections { assertEquals(ID_TO_FIND, currentEmployee.uniqueID); } + /** + * Note that in a perfect world this would work. However, to accomplish this task + * we'd need to use <code>flash.utils.describeType()</code> (or + * <code>DescribeTypeCache.describeType()</code> or <code>ObjectUtil.getClassInfo()</code>). + * But since no usage of findAny(), findFirst() and findLast() in the framework requires + * this feature (as they are all about finding items that already exist in the collection), + * there's no business case for implementing it. + */ + [Test] + public function test_findAny_does_NOT_find_sealed_class_instance_via_other_sealed_class_instance_with_subset_of_properties():void + { + //given + _utils.openAllNodes(_collectionView); + var lastEmployee:EmployeeVO = _employeesByID[_employeesByID.length - 1]; + + //when + var found:Boolean = _sut.findAny(new NamedVO(lastEmployee.name)); + + //then + assertFalse(found); + assertNull(_sut.current); + } + + //see the comment for the function above + [Test] + public function test_findLast_does_NOT_find_sealed_class_instance_via_other_sealed_class_instance_with_subset_of_properties():void + { + //given + _utils.openAllNodes(_collectionView); + var firstEmployee:EmployeeVO = _employeesByID[0]; + + //when + var found:Boolean = _sut.findLast(new NamedVO(firstEmployee.name)); + + //then + assertFalse(found); + assertNull(_sut.current); + } + [Test] public function test_findLast_finds_different_object_to_findFirst_via_anonymous_object_with_subset_of_properties():void { @@ -355,4 +395,14 @@ class EmployeeVO this.department = department; this.uniqueID = uniqueID; } +} + +class NamedVO +{ + public var name:String; + + public function NamedVO(name:String) + { + this.name = name; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/e87c827b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as index cdc4e4b..173a2d9 100644 --- a/frameworks/projects/framework/src/mx/collections/ListCollectionView.as +++ b/frameworks/projects/framework/src/mx/collections/ListCollectionView.as @@ -1902,7 +1902,6 @@ public class ListCollectionView extends Proxy } -import flash.events.Event; import flash.events.EventDispatcher; import mx.collections.*; @@ -2224,7 +2223,7 @@ class ListCollectionViewCursor extends EventDispatcher implements IViewCursor * @playerversion AIR 1.1 * @productversion Flex 3 */ - public function findFirst(values:Object):Boolean + public function findFirst(values:Object):Boolean { checkValid(); var lcView:ListCollectionView = ListCollectionView(view); http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/e87c827b/frameworks/projects/framework/src/mx/utils/ObjectUtil.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/src/mx/utils/ObjectUtil.as b/frameworks/projects/framework/src/mx/utils/ObjectUtil.as index 4a939b3..6b1e79a 100644 --- a/frameworks/projects/framework/src/mx/utils/ObjectUtil.as +++ b/frameworks/projects/framework/src/mx/utils/ObjectUtil.as @@ -1110,12 +1110,11 @@ public class ObjectUtil } } - propertyNames.sort(Array.CASEINSENSITIVE | - (numericIndex ? Array.NUMERIC : 0)); + propertyNames.sort(Array.CASEINSENSITIVE | (numericIndex ? Array.NUMERIC : 0)); // dictionary keys can be indexed by an object reference // there's a possibility that two keys will have the same toString() - // so we don't want to remove dupes + // so we don't want to remove duplicates if (!isDict) { // for Arrays, etc., on the other hand...
