FLEX-34837, FLEX-34854
Moved one test function to FLEX_34854_Tests, as it was more appropriate for 
this ticket.


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

Branch: refs/heads/develop
Commit: d440bd2293f034ed7ce75b399836578bcad05cdb
Parents: 2937a78
Author: Mihai Chira <[email protected]>
Authored: Mon Jun 8 13:04:22 2015 +0200
Committer: Mihai Chira <[email protected]>
Committed: Mon Jun 8 13:04:22 2015 +0200

----------------------------------------------------------------------
 .../framework/tests/FLEX_34854_Tests.as         | 130 +++++++++++++++++++
 .../ListCollectionView_FLEX_34837_Tests.as      |  23 ----
 2 files changed, 130 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d440bd22/frameworks/projects/framework/tests/FLEX_34854_Tests.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/tests/FLEX_34854_Tests.as 
b/frameworks/projects/framework/tests/FLEX_34854_Tests.as
new file mode 100644
index 0000000..7acce5e
--- /dev/null
+++ b/frameworks/projects/framework/tests/FLEX_34854_Tests.as
@@ -0,0 +1,130 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package {
+    import mx.collections.ArrayList;
+    import mx.collections.ComplexSortField;
+    import mx.collections.IList;
+    import mx.collections.ListCollectionView;
+    import mx.collections.Sort;
+
+    import org.flexunit.asserts.assertEquals;
+
+    public class FLEX_34854_Tests {
+        private var _sut:ListCollectionView;
+
+        [Before]
+        public function setUp():void
+        {
+            _sut = new ListCollectionView(new ArrayList());
+        }
+
+        [After]
+        public function tearDown():void
+        {
+            _sut = null;
+        }
+
+        [Test]
+        public function 
test_changing_complex_sort_field_value_places_it_correctly_according_to_collection_sort():void
+        {
+            //given
+            var from1To4:IList = generateVOs(5);
+            from1To4.removeItemAt(0);
+            _sut.addAll(from1To4);
+
+            const sortByNameAscending:Sort = new Sort();
+            sortByNameAscending.fields = [new 
ComplexSortField("address.street", false, false, false)];
+            _sut.sort = sortByNameAscending;
+            _sut.refresh(); //values: Object1, Object2, Object3, Object4
+
+            //when
+            const newItem:ListCollectionView_FLEX_34854_VO = 
generateOneObject(5);
+            _sut.addItem(newItem); //values: Object1, Object2, Object3, 
Object4, Object5
+            newItem.address.street = "Street0"; //this should immediately 
place the newItem at position 0
+
+            //then
+            const newItemIndex:int = _sut.getItemIndex(newItem);
+            assertEquals("the new item should have been placed at the 
beginning of the list as soon as its address's street name was changed", 0, 
newItemIndex);
+            _sut.removeItemAt(_sut.getItemIndex(newItem)); //if the bug is 
present, this will throw an RTE
+        }
+
+        private function assertIndexesAre(indexes:Array):void
+        {
+            assertEquals(indexes.length, _sut.length);
+
+            for(var i:int = 0; i < _sut.length; i++)
+            {
+                
assertEquals(ListCollectionView_FLEX_34854_VO(_sut.getItemAt(i)).index, 
indexes[i]);
+            }
+        }
+
+
+        private static function generateVOs(no:int, reverse:Boolean = 
false):IList
+        {
+            return generateObjects(no, reverse, generateOneObject);
+        }
+
+        private static function generateObjects(no:int, reverse:Boolean, 
generator:Function):IList
+        {
+            var result:Array = [];
+            for(var i:int = 0; i < no; i++)
+            {
+                result.push(generator(i));
+            }
+
+            if(reverse)
+                result.reverse();
+
+            return new ArrayList(result);
+        }
+
+        private static function 
generateOneObject(i:Number):ListCollectionView_FLEX_34854_VO
+        {
+            return new ListCollectionView_FLEX_34854_VO(i, "Object", "Street");
+        }
+    }
+}
+
+
+[Bindable]
+class ListCollectionView_FLEX_34854_VO
+{
+    public var name:String;
+    public var address:ListCollectionView_FLEX_34854_AddressVO;
+    public var index:Number;
+
+    public function ListCollectionView_FLEX_34854_VO(index:Number, 
namePrefix:String, streetPrefix:String)
+    {
+        this.index = index;
+        this.name = namePrefix + index;
+        this.address = new 
ListCollectionView_FLEX_34854_AddressVO(streetPrefix + index);
+    }
+}
+
+[Bindable]
+class ListCollectionView_FLEX_34854_AddressVO
+{
+    public var street:String;
+
+    public function ListCollectionView_FLEX_34854_AddressVO(street:String)
+    {
+        this.street = street;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d440bd22/frameworks/projects/framework/tests/ListCollectionView_FLEX_34837_Tests.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/framework/tests/ListCollectionView_FLEX_34837_Tests.as 
b/frameworks/projects/framework/tests/ListCollectionView_FLEX_34837_Tests.as
index 33d0336..776b4a4 100644
--- a/frameworks/projects/framework/tests/ListCollectionView_FLEX_34837_Tests.as
+++ b/frameworks/projects/framework/tests/ListCollectionView_FLEX_34837_Tests.as
@@ -121,29 +121,6 @@ package {
             assertEquals("the new item should have been placed at the 
beginning of the list as soon as its name was changed", 0, newItemIndex);
         }
 
-        [Test]
-        public function 
test_changing_complex_sort_field_value_places_it_correctly_according_to_collection_sort():void
-        {
-            //given
-            var from1To4:IList = generateVOs(5);
-            from1To4.removeItemAt(0);
-            _sut.addAll(from1To4);
-
-            const sortByNameAscending:Sort = new Sort();
-            sortByNameAscending.fields = [new 
ComplexSortField("address.street", false, false, false)];
-            _sut.sort = sortByNameAscending;
-            _sut.refresh(); //values: Object1, Object2, Object3, Object4
-
-            //when
-            const newItem:ListCollectionView_FLEX_34837_VO = 
generateOneObject(5);
-            _sut.addItem(newItem); //values: Object1, Object2, Object3, 
Object4, Object5
-            newItem.address.street = "Street0"; //this should immediately 
place the newItem at position 0
-
-            //then
-            const newItemIndex:int = _sut.getItemIndex(newItem);
-            assertEquals("the new item should have been placed at the 
beginning of the list as soon as its address's street name was changed", 0, 
newItemIndex);
-            _sut.removeItemAt(_sut.getItemIndex(newItem)); //if the bug is 
present, this will throw an RTE
-        }
 
         private function assertIndexesAre(indexes:Array):void
         {

Reply via email to