Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 91CF118E8E for ; Mon, 22 Feb 2016 18:17:54 +0000 (UTC) Received: (qmail 91010 invoked by uid 500); 22 Feb 2016 18:16:56 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 90973 invoked by uid 500); 22 Feb 2016 18:16:56 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 90965 invoked by uid 99); 22 Feb 2016 18:16:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Feb 2016 18:16:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C9778E025B; Mon, 22 Feb 2016 18:16:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mihaic@apache.org To: commits@flex.apache.org Date: Mon, 22 Feb 2016 18:16:55 -0000 Message-Id: <7f78904a575a494a9644067faea5a7e5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: [flex-sdk] [refs/heads/develop] - FLEX-35037 Renaming test files to 1) show what they're testing and 2) make sure they're picked up and ran by the test scripts. Repository: flex-sdk Updated Branches: refs/heads/develop 1d8d02c64 -> 81643dd12 http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as b/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as deleted file mode 100644 index 85fdccc..0000000 --- a/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as +++ /dev/null @@ -1,114 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class FilerAndSortNumbers - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - - protected function addNumbers():void - { - _sut.addItem(6); - _sut.addItem(2); - _sut.addItem(3); - _sut.addItem(1); - _sut.addItem(5); - _sut.addItem(4); - } - - protected function even(object:Object):Boolean - { - return Number(object) % 2 == 0; - } - - protected function odd(object:Object):Boolean - { - return Number(object) % 2 == 1; - } - - [Test] - public function filterAndSortCombinations():void - { - addNumbers(); - _sut.filterFunction = even; - _sut.sort = new Sort(); - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 4, _sut[1]); - assertEquals("Third element not correct", 6, _sut[2]); - - _sut.filterFunction = odd; - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 3, _sut[1]); - assertEquals("Third element not correct", 5, _sut[2]); - - _sut.sort = new Sort(); - _sut.sort.fields = [new SortField(null, false, true, true)]; - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 5, _sut[0]); - assertEquals("Second element not correct", 3, _sut[1]); - assertEquals("Third element not correct", 1, _sut[2]); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not six", 6, _sut.length); - assertEquals("First element not correct", 6, _sut[0]); - assertEquals("Second element not correct", 5, _sut[1]); - assertEquals("Third element not correct", 4, _sut[2]); - assertEquals("Fourth element not correct", 3, _sut[3]); - assertEquals("Fith element not correct", 2, _sut[4]); - assertEquals("Six element not correct", 1, _sut[5]); - - _sut.sort = null; - _sut.refresh(); - - assertEquals("Length is not six", 6, _sut.length); - assertEquals("First element not correct", 6, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - assertEquals("Third element not correct", 3, _sut[2]); - assertEquals("Fourth element not correct", 1, _sut[3]); - assertEquals("Fith element not correct", 5, _sut[4]); - assertEquals("Six element not correct", 4, _sut[5]); - } - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as b/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as deleted file mode 100644 index d256032..0000000 --- a/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as +++ /dev/null @@ -1,114 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class FilerAndSortStrings - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - - protected function addNumbers():void - { - _sut.addItem(6); - _sut.addItem(2); - _sut.addItem(3); - _sut.addItem(1); - _sut.addItem(5); - _sut.addItem(4); - } - - protected function even(object:Object):Boolean - { - return Number(object) % 2 == 0; - } - - protected function odd(object:Object):Boolean - { - return Number(object) % 2 == 1; - } - - [Test] - public function filterAndSortCombinations():void - { - addNumbers(); - _sut.filterFunction = even; - _sut.sort = new Sort(); - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 4, _sut[1]); - assertEquals("Third element not correct", 6, _sut[2]); - - _sut.filterFunction = odd; - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 3, _sut[1]); - assertEquals("Third element not correct", 5, _sut[2]); - - _sut.sort = new Sort(); - _sut.sort.fields = [new SortField(null, false, true, true)]; - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", 5, _sut[0]); - assertEquals("Second element not correct", 3, _sut[1]); - assertEquals("Third element not correct", 1, _sut[2]); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not six", 6, _sut.length); - assertEquals("First element not correct", 6, _sut[0]); - assertEquals("Second element not correct", 5, _sut[1]); - assertEquals("Third element not correct", 4, _sut[2]); - assertEquals("Fourth element not correct", 3, _sut[3]); - assertEquals("Fith element not correct", 2, _sut[4]); - assertEquals("Six element not correct", 1, _sut[5]); - - _sut.sort = null; - _sut.refresh(); - - assertEquals("Length is not six", 6, _sut.length); - assertEquals("First element not correct", 6, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - assertEquals("Third element not correct", 3, _sut[2]); - assertEquals("Fourth element not correct", 1, _sut[3]); - assertEquals("Fith element not correct", 5, _sut[4]); - assertEquals("Six element not correct", 4, _sut[5]); - } - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as b/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as deleted file mode 100644 index bbc9330..0000000 --- a/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as +++ /dev/null @@ -1,315 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class FilterNumbers - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - protected function addNumbers():void - { - _sut.addItem(1); - _sut.addItem(2); - } - - protected function allIn(object:Object):Boolean - { - return true; - } - - protected function allOut(object:Object):Boolean - { - return false; - } - - protected function isOne(object:Object):Boolean - { - return object == 1; - } - - [Test] - public function nullFilter():void - { - addNumbers(); - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function trueFilter():void - { - addNumbers(); - _sut.filterFunction = allIn; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function falseFilter():void - { - addNumbers(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not two", 0, _sut.length); - } - - - [Test] - public function filterNoRefresh():void - { - addNumbers(); - _sut.filterFunction = allOut; - - // Filter should not take effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function nullFilterNoRefresh():void - { - addNumbers(); - _sut.filterFunction = null; - - // Filter should not take effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function filterDoubleRefresh():void - { - addNumbers(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - // Filter should not take effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - // RTEs in Apache Flex 4.9.1 - [Test] - public function filterAddAfterNullNoRefresh():void - { - addNumbers(); - - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - addNumbers(); - - // Filter should be in effect and first 2 items sorted - // item added after are not filtered until refresh called - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - - _sut.refresh(); - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - assertEquals("First element not correct", 1, _sut[2]); - assertEquals("Second element not correct", 2, _sut[3]); - } - - [Test] - public function filterRemoveAfterNullNoRefresh():void - { - addNumbers(); - - _sut.filterFunction = allOut; - _sut.refresh(); - _sut.filterFunction = null; - - assertEquals("Length is not zero", 0, _sut.length); - - try { - _sut.removeItemAt(0); - } - catch (error:Error) - { - assertTrue("Error not range error", error is RangeError); - } - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.refresh(); - assertEquals("Length is not two", 2, _sut.length); - } - - [Test] - public function filterIncludingDuplicates():void - { - addNumbers(); - addNumbers(); - - _sut.filterFunction = isOne; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - } - - // Fails in Apache Flex 4.9.1 - [Test] - public function swapItemsTwoThenOne():void - { - //given - addNumbers(); - _sut.filterFunction = allIn; - _sut.refresh(); - - var item1:Number = _sut.getItemAt(0) as Number; - var item2:Number = _sut.getItemAt(1) as Number; - - //when - _sut.setItemAt(item2, 0); - _sut.setItemAt(item1, 1); - - //then - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - } - - [Test] - public function swapItemsOneThenTwo():void - { - addNumbers(); - _sut.filterFunction = allIn; - _sut.refresh(); - - var item1:Number = _sut.getItemAt(0) as Number; - var item2:Number = _sut.getItemAt(1) as Number; - - _sut.setItemAt(item1,1); - _sut.setItemAt(item2,0); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - } - - [Test] - public function removeAllAfterFiltered():void - { - addNumbers(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not two", 0, _sut.length); - - _sut.removeAll(); - - assertEquals("Length is not two", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function removeFilteredItem():void - { - addNumbers(); - _sut.filterFunction = isOne; - _sut.refresh(); - - assertEquals("Length is not one", 1, _sut.length); - - _sut.removeItemAt(_sut.getItemIndex(1)); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not two", 1, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - } - - [Test] - public function removeNonFilteredItem():void - { - addNumbers(); - _sut.filterFunction = isOne; - _sut.refresh(); - - assertEquals("Length is not one", 1, _sut.length); - - try { - // not removed as filter hids it - perhaps it should be removed? - _sut.removeItemAt(_sut.getItemIndex(2)); - } - catch (error:Error) - { - assertTrue("Error not range error", error is RangeError); - } - - assertEquals("Length is not one", 1, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("First element not correct", 2, _sut[1]); - } - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/FilterStrings.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/FilterStrings.as b/frameworks/projects/framework/tests/mx/collections/FilterStrings.as deleted file mode 100644 index 45677df..0000000 --- a/frameworks/projects/framework/tests/mx/collections/FilterStrings.as +++ /dev/null @@ -1,341 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class FilterStrings - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - protected function addStrings():void - { - _sut.addItem("A"); - _sut.addItem("B"); - _sut.addItem("D"); - _sut.addItem("C"); - } - - protected function allIn(object:Object):Boolean - { - return true; - } - - protected function allOut(object:Object):Boolean - { - return false; - } - - protected function isA(object:Object):Boolean - { - return object == "A"; - } - - [Test] - public function nullFilter():void - { - addStrings(); - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function trueFilter():void - { - addStrings(); - _sut.filterFunction = allIn; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function falseFilter():void - { - addStrings(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not zero", 0, _sut.length); - } - - - [Test] - public function filterNoRefresh():void - { - addStrings(); - _sut.filterFunction = allOut; - - // Filter should not take effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function nullFilterNoRefresh():void - { - addStrings(); - _sut.filterFunction = null; - - // Filter should not take effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function filterDoubleRefresh():void - { - addStrings(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - // Filter should not take effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - // RTEs in Apache Flex 4.9.1 - [Test] - public function filterAddAfterNullNoRefresh():void - { - addStrings(); - - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - addStrings(); - - // Filter should be in effect and first 2 items sorted - // item added after are not filtered until refresh called - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - - _sut.refresh(); - assertEquals("Length is not eight", 8, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - assertEquals("First element not correct", "A", _sut[4]); - assertEquals("Second element not correct", "B", _sut[5]); - assertEquals("Third element not correct", "D", _sut[6]); - assertEquals("Four element not correct", "C", _sut[7]); - } - - [Test] - public function filterRemoveAfterNullNoRefresh():void - { - addStrings(); - - _sut.filterFunction = allOut; - _sut.refresh(); - _sut.filterFunction = null; - - assertEquals("Length is not zero", 0, _sut.length); - - try { - _sut.removeItemAt(0); - } - catch (error:Error) - { - assertTrue("Error not range error", error is RangeError); - } - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.refresh(); - assertEquals("Length is not four", 4, _sut.length); - } - - [Test] - public function filterIncludingDuplicates():void - { - addStrings(); - addStrings(); - - _sut.filterFunction = isA; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "A", _sut[1]); - } - - // Fails in Apache Flex 4.9.1 - [Test] - public function swapItemsTwoThenOne():void - { - //given - addStrings(); - _sut.filterFunction = allIn; - _sut.refresh(); - - var item1:String = _sut.getItemAt(0) as String; - var item2:String = _sut.getItemAt(1) as String; - - //when - _sut.setItemAt(item2,0); - _sut.setItemAt(item1,1); - - //then - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", _sut[0], "B"); - assertEquals("Second element not correct", _sut[1], "A"); - assertEquals("Third element not correct", _sut[2], "D"); - assertEquals("Four element not correct", _sut[3], "C"); - } - - [Test] - public function swapItemsOneThenTwo():void - { - addStrings(); - _sut.filterFunction = allIn; - _sut.refresh(); - - var item1:String = _sut.getItemAt(0) as String; - var item2:String = _sut.getItemAt(1) as String; - - _sut.setItemAt(item1,1); - _sut.setItemAt(item2,0); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "B", _sut[0]); - assertEquals("Second element not correct", "A", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function removeAllAfterFiltered():void - { - addStrings(); - _sut.filterFunction = allOut; - _sut.refresh(); - - assertEquals("Length is not two", 0, _sut.length); - - _sut.removeAll(); - - assertEquals("Length is not two", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - [Test] - public function removeFilteredItem():void - { - addStrings(); - _sut.filterFunction = isA; - _sut.refresh(); - - assertEquals("Length is not one", 1, _sut.length); - - _sut.removeItemAt(_sut.getItemIndex("A")); - - assertEquals("Length is not zero", 0, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", "B", _sut[0]); - } - - [Test] - public function removeNonFilteredItem():void - { - addStrings(); - _sut.filterFunction = isA; - _sut.refresh(); - - assertEquals("Length is not one", 1, _sut.length); - - try { - // not removed as filter hids it - perhaps it should be removed? - _sut.removeItemAt(_sut.getItemIndex("B")); - } - catch (error:Error) - { - assertTrue("Error not range error", error is RangeError); - } - - assertEquals("Length is not one", 1, _sut.length); - - _sut.filterFunction = null; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("Third element not correct", "D", _sut[2]); - assertEquals("Four element not correct", "C", _sut[3]); - } - - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/SortNumbers.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/SortNumbers.as b/frameworks/projects/framework/tests/mx/collections/SortNumbers.as deleted file mode 100644 index 514f27c..0000000 --- a/frameworks/projects/framework/tests/mx/collections/SortNumbers.as +++ /dev/null @@ -1,212 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class SortNumbers - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - protected function addNumbers():void - { - _sut.addItem(1); - _sut.addItem(2); - } - - [Test] - public function nullSort():void - { - addNumbers(); - _sut.sort = null; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function emptySort():void - { - addNumbers(); - _sut.sort = new Sort(); - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function reverseSort():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - addNumbers(); - _sut.sort = sort; - _sut.refresh(); - - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - } - - [Test] - public function sortNoRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - addNumbers(); - _sut.sort = sort; - - // Short should not take effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function nullSortNoRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - addNumbers(); - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - - // Sort should be in effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - - _sut.refresh(); - - // and back to original - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - [Test] - public function sortDoubleRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - addNumbers(); - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - _sut.refresh(); - - // Sort should not be in effect - assertEquals("Length is not two", 2, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - } - - // RTEs in APache flex 4.9.1 - [Test] - public function sortAddAfterNullNoRefresh():void - { - addNumbers(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - addNumbers(); - - // Sort should be in effect and first 2 items sorted - // item added after are not sorted - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 1, _sut[1]); - assertEquals("Third element not correct", 1, _sut[2]); - assertEquals("Fourth element not correct", 2, _sut[3]); - - _sut.refresh(); - - // and back to being unsorted - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - assertEquals("Third element not correct", 1, _sut[2]); - assertEquals("Fourth element not correct", 2, _sut[3]); - } - - // RTEs in Apache Flex 4.9.1 - [Test] - public function sortRemoveAfterNullNoRefresh():void - { - addNumbers(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - - assertEquals("Length is not two", 2, _sut.length); - - _sut.removeItemAt(0); // still sorted so 2 is removed leaving 1 - assertEquals("Length is not one", 1, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - - _sut.refresh(); - - // still the same - assertEquals("Length is not one", 1, _sut.length); - assertEquals("First element not correct", 1, _sut[0]); - } - - [Test] - public function sortIncludingDuplicates():void - { - addNumbers(); - addNumbers(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - _sut.sort = sort; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - - assertEquals("First element not correct", 2, _sut[0]); - assertEquals("Second element not correct", 2, _sut[1]); - assertEquals("Third element not correct", 1, _sut[2]); - assertEquals("Fourth element not correct", 1, _sut[3]); - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/81643dd1/frameworks/projects/framework/tests/mx/collections/SortStrings.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/framework/tests/mx/collections/SortStrings.as b/frameworks/projects/framework/tests/mx/collections/SortStrings.as deleted file mode 100644 index 09ba812..0000000 --- a/frameworks/projects/framework/tests/mx/collections/SortStrings.as +++ /dev/null @@ -1,254 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// 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 mx.collections { - import org.flexunit.asserts.*; - - public class SortStrings - { - private var _sut:ArrayCollection; - - [Before] - public function setUp():void - { - _sut = new ArrayCollection(); - } - - [After] - public function tearDown():void - { - _sut = null; - } - - protected function addStrings():void - { - _sut.addItem("A"); - _sut.addItem("B"); - _sut.addItem("D"); - _sut.addItem("C"); - } - - [Test] - public function nullSort():void - { - addStrings(); - _sut.sort = null; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "D", _sut[2]); - assertEquals("Second element not correct", "C", _sut[3]); - } - - [Test] - public function emptySort():void - { - addStrings(); - _sut.sort = new Sort(); - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "C", _sut[2]); - assertEquals("Second element not correct", "D", _sut[3]); - } - - [Test] - public function reverseSort():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true)]; - addStrings(); - _sut.sort = sort; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "D", _sut[0]); - assertEquals("Second element not correct", "C", _sut[1]); - assertEquals("First element not correct", "B", _sut[2]); - assertEquals("Second element not correct", "A", _sut[3]); - } - - [Test] - public function forwardSort():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - addStrings(); - _sut.sort = sort; - _sut.refresh(); - - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "C", _sut[2]); - assertEquals("Second element not correct", "D", _sut[3]); - } - - [Test] - public function sortNoRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - addStrings(); - _sut.sort = sort; - - // Short should not take effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "D", _sut[2]); - assertEquals("Second element not correct", "C", _sut[3]); - } - - [Test] - public function nullSortNoRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - addStrings(); - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - - // Sort should be in effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "C", _sut[2]); - assertEquals("Second element not correct", "D", _sut[3]); - - _sut.refresh(); - - // and back to original - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "D", _sut[2]); - assertEquals("Second element not correct", "C", _sut[3]); - } - - [Test] - public function sortDoubleRefresh():void - { - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - addStrings(); - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - _sut.refresh(); - - // Sort should not be in effect - assertEquals("Length is not four", 4, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "D", _sut[2]); - assertEquals("Second element not correct", "C", _sut[3]); - } - - // RTEs in APache flex 4.9.1 - [Test] - public function sortAddAfterNullNoRefresh():void - { - addStrings(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - addStrings(); - - // Sort should be in effect and first 4 items sorted - // item added after are not sorted - assertEquals("Length is not eight", 8, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "C", _sut[2]); - assertEquals("Second element not correct", "D", _sut[3]); - assertEquals("First element not correct", "A", _sut[4]); - assertEquals("Second element not correct", "B", _sut[5]); - assertEquals("First element not correct", "D", _sut[6]); - assertEquals("Second element not correct", "C", _sut[7]); - - _sut.refresh(); - - // and back to being unsorted - assertEquals("Length is not eight", 8, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "B", _sut[1]); - assertEquals("First element not correct", "D", _sut[2]); - assertEquals("Second element not correct", "C", _sut[3]); - assertEquals("First element not correct", "A", _sut[4]); - assertEquals("Second element not correct", "B", _sut[5]); - assertEquals("First element not correct", "D", _sut[6]); - assertEquals("Second element not correct", "C", _sut[7]); - } - - // RTEs in Apache Flex 4.9.1 - [Test] - public function sortRemoveAfterNullNoRefresh():void - { - addStrings(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField(null, false, true, true)]; - _sut.sort = sort; - _sut.refresh(); - _sut.sort = null; - - assertEquals("Length is not four", 4, _sut.length); - - _sut.removeItemAt(0); // still sorted so 2 is removed leaving 1 - assertEquals("Length is not three", 3, _sut.length); - assertEquals("First element not correct", "B", _sut[0]); - - _sut.refresh(); - - assertEquals("Length is not four", 3, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - } - - [Test] - public function sortIncludingDuplicates():void - { - addStrings(); - addStrings(); - - var sort:Sort = new Sort(); - sort.fields = [new SortField()]; - _sut.sort = sort; - _sut.refresh(); - - assertEquals("Length is not eight", 8, _sut.length); - assertEquals("First element not correct", "A", _sut[0]); - assertEquals("Second element not correct", "A", _sut[1]); - assertEquals("First element not correct", "B", _sut[2]); - assertEquals("Second element not correct", "B", _sut[3]); - assertEquals("First element not correct", "C", _sut[4]); - assertEquals("Second element not correct", "C", _sut[5]); - assertEquals("First element not correct", "D", _sut[6]); - assertEquals("Second element not correct", "D", _sut[7]); - } - - } -} \ No newline at end of file