FLEX-35037
Renaming ac to _sut ("system under test") and making it private instead of
protected.
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/1d8d02c6
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/1d8d02c6
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/1d8d02c6
Branch: refs/heads/develop
Commit: 1d8d02c643a9d4cd911c44e867cfc42fdc80d9b5
Parents: a000600
Author: Mihai Chira <[email protected]>
Authored: Mon Feb 22 19:04:45 2016 +0100
Committer: Mihai Chira <[email protected]>
Committed: Mon Feb 22 19:04:45 2016 +0100
----------------------------------------------------------------------
.../tests/mx/collections/FilerAndSortNumbers.as | 95 ++--
.../tests/mx/collections/FilerAndSortStrings.as | 95 ++--
.../tests/mx/collections/FilterNumbers.as | 217 ++++----
.../tests/mx/collections/FilterStrings.as | 273 +++++-----
...rchicalCollectionViewCursor_FindAny_Tests.as | 510 +++++++++++++++++++
.../tests/mx/collections/SortNumbers.as | 145 +++---
.../tests/mx/collections/SortStrings.as | 227 ++++-----
7 files changed, 1033 insertions(+), 529 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index 46a1613..85fdccc 100644
--- a/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as
+++ b/frameworks/projects/framework/tests/mx/collections/FilerAndSortNumbers.as
@@ -21,30 +21,29 @@ package mx.collections {
public class FilerAndSortNumbers
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addNumbers():void
{
- ac.addItem(6);
- ac.addItem(2);
- ac.addItem(3);
- ac.addItem(1);
- ac.addItem(5);
- ac.addItem(4);
+ _sut.addItem(6);
+ _sut.addItem(2);
+ _sut.addItem(3);
+ _sut.addItem(1);
+ _sut.addItem(5);
+ _sut.addItem(4);
}
protected function even(object:Object):Boolean
@@ -61,53 +60,53 @@ package mx.collections {
public function filterAndSortCombinations():void
{
addNumbers();
- ac.filterFunction = even;
- ac.sort = new Sort();
- ac.refresh();
+ _sut.filterFunction = even;
+ _sut.sort = new Sort();
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 4, ac[1]);
- assertEquals("Third element not correct", 6, ac[2]);
+ 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]);
- ac.filterFunction = odd;
- ac.refresh();
+ _sut.filterFunction = odd;
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 3, ac[1]);
- assertEquals("Third element not correct", 5, ac[2]);
+ 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]);
- ac.sort = new Sort();
- ac.sort.fields = [new SortField(null, false, true,
true)];
- ac.refresh();
+ _sut.sort = new Sort();
+ _sut.sort.fields = [new SortField(null, false, true,
true)];
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 5, ac[0]);
- assertEquals("Second element not correct", 3, ac[1]);
- assertEquals("Third element not correct", 1, ac[2]);
+ 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]);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not six", 6, ac.length);
- assertEquals("First element not correct", 6, ac[0]);
- assertEquals("Second element not correct", 5, ac[1]);
- assertEquals("Third element not correct", 4, ac[2]);
- assertEquals("Fourth element not correct", 3, ac[3]);
- assertEquals("Fith element not correct", 2, ac[4]);
- assertEquals("Six element not correct", 1, ac[5]);
+ 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]);
- ac.sort = null;
- ac.refresh();
+ _sut.sort = null;
+ _sut.refresh();
- assertEquals("Length is not six", 6, ac.length);
- assertEquals("First element not correct", 6, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
- assertEquals("Third element not correct", 3, ac[2]);
- assertEquals("Fourth element not correct", 1, ac[3]);
- assertEquals("Fith element not correct", 5, ac[4]);
- assertEquals("Six element not correct", 4, ac[5]);
+ 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]);
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index 0de4b95..d256032 100644
--- a/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as
+++ b/frameworks/projects/framework/tests/mx/collections/FilerAndSortStrings.as
@@ -21,30 +21,29 @@ package mx.collections {
public class FilerAndSortStrings
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addNumbers():void
{
- ac.addItem(6);
- ac.addItem(2);
- ac.addItem(3);
- ac.addItem(1);
- ac.addItem(5);
- ac.addItem(4);
+ _sut.addItem(6);
+ _sut.addItem(2);
+ _sut.addItem(3);
+ _sut.addItem(1);
+ _sut.addItem(5);
+ _sut.addItem(4);
}
protected function even(object:Object):Boolean
@@ -61,53 +60,53 @@ package mx.collections {
public function filterAndSortCombinations():void
{
addNumbers();
- ac.filterFunction = even;
- ac.sort = new Sort();
- ac.refresh();
+ _sut.filterFunction = even;
+ _sut.sort = new Sort();
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 4, ac[1]);
- assertEquals("Third element not correct", 6, ac[2]);
+ 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]);
- ac.filterFunction = odd;
- ac.refresh();
+ _sut.filterFunction = odd;
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 3, ac[1]);
- assertEquals("Third element not correct", 5, ac[2]);
+ 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]);
- ac.sort = new Sort();
- ac.sort.fields = [new SortField(null, false, true,
true)];
- ac.refresh();
+ _sut.sort = new Sort();
+ _sut.sort.fields = [new SortField(null, false, true,
true)];
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", 5, ac[0]);
- assertEquals("Second element not correct", 3, ac[1]);
- assertEquals("Third element not correct", 1, ac[2]);
+ 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]);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not six", 6, ac.length);
- assertEquals("First element not correct", 6, ac[0]);
- assertEquals("Second element not correct", 5, ac[1]);
- assertEquals("Third element not correct", 4, ac[2]);
- assertEquals("Fourth element not correct", 3, ac[3]);
- assertEquals("Fith element not correct", 2, ac[4]);
- assertEquals("Six element not correct", 1, ac[5]);
+ 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]);
- ac.sort = null;
- ac.refresh();
+ _sut.sort = null;
+ _sut.refresh();
- assertEquals("Length is not six", 6, ac.length);
- assertEquals("First element not correct", 6, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
- assertEquals("Third element not correct", 3, ac[2]);
- assertEquals("Fourth element not correct", 1, ac[3]);
- assertEquals("Fith element not correct", 5, ac[4]);
- assertEquals("Six element not correct", 4, ac[5]);
+ 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]);
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index 8f27acc..bbc9330 100644
--- a/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as
+++ b/frameworks/projects/framework/tests/mx/collections/FilterNumbers.as
@@ -21,25 +21,24 @@ package mx.collections {
public class FilterNumbers
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addNumbers():void
{
- ac.addItem(1);
- ac.addItem(2);
+ _sut.addItem(1);
+ _sut.addItem(2);
}
protected function allIn(object:Object):Boolean
@@ -61,34 +60,34 @@ package mx.collections {
public function nullFilter():void
{
addNumbers();
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.filterFunction = allIn;
- ac.refresh();
+ _sut.filterFunction = allIn;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not two", 0, ac.length);
+ assertEquals("Length is not two", 0, _sut.length);
}
@@ -96,42 +95,42 @@ package mx.collections {
public function filterNoRefresh():void
{
addNumbers();
- ac.filterFunction = allOut;
+ _sut.filterFunction = allOut;
// Filter should not take effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.filterFunction = null;
+ _sut.filterFunction = null;
// Filter should not take effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
// Filter should not take effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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
@@ -140,26 +139,26 @@ package mx.collections {
{
addNumbers();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
+ _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, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
-
- ac.refresh();
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
- assertEquals("First element not correct", 1, ac[2]);
- assertEquals("Second element not correct", 2, ac[3]);
+ 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]
@@ -167,24 +166,24 @@ package mx.collections {
{
addNumbers();
- ac.filterFunction = allOut;
- ac.refresh();
- ac.filterFunction = null;
+ _sut.filterFunction = allOut;
+ _sut.refresh();
+ _sut.filterFunction = null;
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
try {
- ac.removeItemAt(0);
+ _sut.removeItemAt(0);
}
catch (error:Error)
{
assertTrue("Error not range error", error is
RangeError);
}
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.refresh();
- assertEquals("Length is not two", 2, ac.length);
+ _sut.refresh();
+ assertEquals("Length is not two", 2, _sut.length);
}
[Test]
@@ -193,13 +192,13 @@ package mx.collections {
addNumbers();
addNumbers();
- ac.filterFunction = isOne;
- ac.refresh();
+ _sut.filterFunction = isOne;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
+ assertEquals("Length is not two", 2, _sut.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
+ assertEquals("First element not correct", 1, _sut[0]);
+ assertEquals("Second element not correct", 1, _sut[1]);
}
// Fails in Apache Flex 4.9.1
@@ -208,107 +207,107 @@ package mx.collections {
{
//given
addNumbers();
- ac.filterFunction = allIn;
- ac.refresh();
+ _sut.filterFunction = allIn;
+ _sut.refresh();
- var item1:Number = ac.getItemAt(0) as Number;
- var item2:Number = ac.getItemAt(1) as Number;
+ var item1:Number = _sut.getItemAt(0) as Number;
+ var item2:Number = _sut.getItemAt(1) as Number;
//when
- ac.setItemAt(item2, 0);
- ac.setItemAt(item1, 1);
+ _sut.setItemAt(item2, 0);
+ _sut.setItemAt(item1, 1);
//then
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
+ 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();
- ac.filterFunction = allIn;
- ac.refresh();
+ _sut.filterFunction = allIn;
+ _sut.refresh();
- var item1:Number = ac.getItemAt(0) as Number;
- var item2:Number = ac.getItemAt(1) as Number;
+ var item1:Number = _sut.getItemAt(0) as Number;
+ var item2:Number = _sut.getItemAt(1) as Number;
- ac.setItemAt(item1,1);
- ac.setItemAt(item2,0);
+ _sut.setItemAt(item1,1);
+ _sut.setItemAt(item2,0);
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
+ 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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not two", 0, ac.length);
+ assertEquals("Length is not two", 0, _sut.length);
- ac.removeAll();
+ _sut.removeAll();
- assertEquals("Length is not two", 0, ac.length);
+ assertEquals("Length is not two", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.filterFunction = isOne;
- ac.refresh();
+ _sut.filterFunction = isOne;
+ _sut.refresh();
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
- ac.removeItemAt(ac.getItemIndex(1));
+ _sut.removeItemAt(_sut.getItemIndex(1));
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not two", 1, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
+ assertEquals("Length is not two", 1, _sut.length);
+ assertEquals("First element not correct", 2, _sut[0]);
}
[Test]
public function removeNonFilteredItem():void
{
addNumbers();
- ac.filterFunction = isOne;
- ac.refresh();
+ _sut.filterFunction = isOne;
+ _sut.refresh();
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
try {
// not removed as filter hids it - perhaps it
should be removed?
- ac.removeItemAt(ac.getItemIndex(2));
+ _sut.removeItemAt(_sut.getItemIndex(2));
}
catch (error:Error)
{
assertTrue("Error not range error", error is
RangeError);
}
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("First element not correct", 2, ac[1]);
+ assertEquals("Length is not two", 2, _sut.length);
+ assertEquals("First element not correct", 1, _sut[0]);
+ assertEquals("First element not correct", 2, _sut[1]);
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index 7413421..45677df 100644
--- a/frameworks/projects/framework/tests/mx/collections/FilterStrings.as
+++ b/frameworks/projects/framework/tests/mx/collections/FilterStrings.as
@@ -21,27 +21,26 @@ package mx.collections {
public class FilterStrings
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addStrings():void
{
- ac.addItem("A");
- ac.addItem("B");
- ac.addItem("D");
- ac.addItem("C");
+ _sut.addItem("A");
+ _sut.addItem("B");
+ _sut.addItem("D");
+ _sut.addItem("C");
}
protected function allIn(object:Object):Boolean
@@ -63,38 +62,38 @@ package mx.collections {
public function nullFilter():void
{
addStrings();
- ac.filterFunction = null;
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ _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();
- ac.filterFunction = allIn;
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ _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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
}
@@ -102,48 +101,48 @@ package mx.collections {
public function filterNoRefresh():void
{
addStrings();
- ac.filterFunction = allOut;
+ _sut.filterFunction = allOut;
// Filter should not take effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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();
- ac.filterFunction = null;
+ _sut.filterFunction = null;
// Filter should not take effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
// Filter should not take effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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
@@ -152,32 +151,32 @@ package mx.collections {
{
addStrings();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
+ _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, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
-
- ac.refresh();
- assertEquals("Length is not eight", 8, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
- assertEquals("First element not correct", "A", ac[4]);
- assertEquals("Second element not correct", "B", ac[5]);
- assertEquals("Third element not correct", "D", ac[6]);
- assertEquals("Four element not correct", "C", ac[7]);
+ 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]
@@ -185,24 +184,24 @@ package mx.collections {
{
addStrings();
- ac.filterFunction = allOut;
- ac.refresh();
- ac.filterFunction = null;
+ _sut.filterFunction = allOut;
+ _sut.refresh();
+ _sut.filterFunction = null;
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
try {
- ac.removeItemAt(0);
+ _sut.removeItemAt(0);
}
catch (error:Error)
{
assertTrue("Error not range error", error is
RangeError);
}
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.refresh();
- assertEquals("Length is not four", 4, ac.length);
+ _sut.refresh();
+ assertEquals("Length is not four", 4, _sut.length);
}
[Test]
@@ -211,13 +210,13 @@ package mx.collections {
addStrings();
addStrings();
- ac.filterFunction = isA;
- ac.refresh();
+ _sut.filterFunction = isA;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
+ assertEquals("Length is not two", 2, _sut.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "A", ac[1]);
+ assertEquals("First element not correct", "A",
_sut[0]);
+ assertEquals("Second element not correct", "A",
_sut[1]);
}
// Fails in Apache Flex 4.9.1
@@ -226,115 +225,115 @@ package mx.collections {
{
//given
addStrings();
- ac.filterFunction = allIn;
- ac.refresh();
+ _sut.filterFunction = allIn;
+ _sut.refresh();
- var item1:String = ac.getItemAt(0) as String;
- var item2:String = ac.getItemAt(1) as String;
+ var item1:String = _sut.getItemAt(0) as String;
+ var item2:String = _sut.getItemAt(1) as String;
//when
- ac.setItemAt(item2,0);
- ac.setItemAt(item1,1);
+ _sut.setItemAt(item2,0);
+ _sut.setItemAt(item1,1);
//then
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", ac[0], "B");
- assertEquals("Second element not correct", ac[1], "A");
- assertEquals("Third element not correct", ac[2], "D");
- assertEquals("Four element not correct", ac[3], "C");
+ 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();
- ac.filterFunction = allIn;
- ac.refresh();
+ _sut.filterFunction = allIn;
+ _sut.refresh();
- var item1:String = ac.getItemAt(0) as String;
- var item2:String = ac.getItemAt(1) as String;
+ var item1:String = _sut.getItemAt(0) as String;
+ var item2:String = _sut.getItemAt(1) as String;
- ac.setItemAt(item1,1);
- ac.setItemAt(item2,0);
+ _sut.setItemAt(item1,1);
+ _sut.setItemAt(item2,0);
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "B", ac[0]);
- assertEquals("Second element not correct", "A", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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();
- ac.filterFunction = allOut;
- ac.refresh();
+ _sut.filterFunction = allOut;
+ _sut.refresh();
- assertEquals("Length is not two", 0, ac.length);
+ assertEquals("Length is not two", 0, _sut.length);
- ac.removeAll();
+ _sut.removeAll();
- assertEquals("Length is not two", 0, ac.length);
+ assertEquals("Length is not two", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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();
- ac.filterFunction = isA;
- ac.refresh();
+ _sut.filterFunction = isA;
+ _sut.refresh();
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
- ac.removeItemAt(ac.getItemIndex("A"));
+ _sut.removeItemAt(_sut.getItemIndex("A"));
- assertEquals("Length is not zero", 0, ac.length);
+ assertEquals("Length is not zero", 0, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", "B", ac[0]);
+ assertEquals("Length is not three", 3, _sut.length);
+ assertEquals("First element not correct", "B",
_sut[0]);
}
[Test]
public function removeNonFilteredItem():void
{
addStrings();
- ac.filterFunction = isA;
- ac.refresh();
+ _sut.filterFunction = isA;
+ _sut.refresh();
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
try {
// not removed as filter hids it - perhaps it
should be removed?
- ac.removeItemAt(ac.getItemIndex("B"));
+ _sut.removeItemAt(_sut.getItemIndex("B"));
}
catch (error:Error)
{
assertTrue("Error not range error", error is
RangeError);
}
- assertEquals("Length is not one", 1, ac.length);
+ assertEquals("Length is not one", 1, _sut.length);
- ac.filterFunction = null;
- ac.refresh();
+ _sut.filterFunction = null;
+ _sut.refresh();
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("Third element not correct", "D", ac[2]);
- assertEquals("Four element not correct", "C", ac[3]);
+ 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]);
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/frameworks/projects/framework/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
----------------------------------------------------------------------
diff --git
a/frameworks/projects/framework/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
b/frameworks/projects/framework/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
new file mode 100644
index 0000000..230fa91
--- /dev/null
+++
b/frameworks/projects/framework/tests/mx/collections/HierarchicalCollectionViewCursor_FindAny_Tests.as
@@ -0,0 +1,510 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.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
+ {
+ private static const DEPARTMENT_SALES:String = "Sales";
+ private static const DEPARTMENT_DEVELOPMENT:String = "Development";
+ private static const NO_EMPLOYEES_PER_DEPARTMENT:int = 5;
+ private static const NO_DEPARTMENTS:int = 2;
+ private static const NO_EMPLOYEES:int = NO_EMPLOYEES_PER_DEPARTMENT *
NO_DEPARTMENTS;
+ private static const _utils:HierarchicalCollectionViewTestUtils = new
HierarchicalCollectionViewTestUtils();
+ private static var _collectionView:HierarchicalCollectionView;
+ private static var _sut:HierarchicalCollectionViewCursor;
+ private static var _level0:ArrayCollection;
+ private static var _employeesByID:Array = [];
+
+ [Before]
+ public function setUp():void
+ {
+ _collectionView =
createHierarchicalCollectionView(createGroupingCollection(createEmployees()));
+ _level0 = _utils.getRoot(_collectionView) as ArrayCollection;
+ _sut = _collectionView.createCursor() as
HierarchicalCollectionViewCursor;
+ }
+
+ [After]
+ public function tearDown():void
+ {
+ _collectionView = null;
+ _sut = null;
+ }
+
+ [Test]
+ public function test_seeking_first_lands_on_development():void
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ _sut.seek(new CursorBookmark(CursorBookmark.FIRST));
+
+ //then
+ var developmentGroup:Object = _level0.getItemAt(0);
+ assertTrue(developmentGroup.hasOwnProperty("GroupLabel"));
+ assertEquals(DEPARTMENT_DEVELOPMENT,
developmentGroup["GroupLabel"]);
+ assertEquals(developmentGroup, _sut.current);
+ }
+
+ [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
+ _utils.openAllNodes(_collectionView);
+ _sut.seek(new CursorBookmark(CursorBookmark.FIRST));
+
+ //when
+ var found:Boolean = _sut.findAny(_sut.current);
+
+ //then
+ assertTrue(found);
+ assertEquals(_level0.getItemAt(0), _sut.current);
+ }
+
+ [Test] //FLEX-35031
+ public function
test_FLEX_35031_finding_current_sealed_class_instance_with_findAny():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.findAny(_sut.current);
+
+ //then
+ assertTrue(found);
+ assertTrue(_sut.current is EmployeeVO);
+ assertEquals(DEPARTMENT_DEVELOPMENT,
EmployeeVO(_sut.current).department);
+ }
+
+ [Test] //FLEX-35031
+ 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);
+ _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);
+ }
+
+ [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_the_first_item_when_its_argument_is_an_empty_anonymous_object():void
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean = _sut.findAny({});
+
+ //then
+ assertTrue(found);
+ assertEquals(_level0.getItemAt(0), _sut.current);
+ }
+
+ [Test]
+ public function
test_findLast_finds_the_last_item_when_its_argument_is_an_empty_anonymous_object():void
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean = _sut.findLast({});
+
+ //then
+ assertTrue(found);
+ assertEquals(_employeesByID[_employeesByID.length - 1],
_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 = NO_EMPLOYEES_PER_DEPARTMENT;
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean = _sut.findAny({department:DEPARTMENT_SALES,
uniqueID: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.uniqueID);
+ }
+
+ [Test]
+ public function
test_findAny_finds_sealed_class_instance_via_anonymous_object_with_subset_of_properties_and_string_values_instead_of_int():void
+ {
+ //given
+ const ID_TO_FIND:int = NO_EMPLOYEES_PER_DEPARTMENT;
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean = _sut.findAny({department:DEPARTMENT_SALES,
uniqueID:ID_TO_FIND.toString()});
+
+ //then
+ assertTrue(found);
+ var currentEmployee:EmployeeVO = _sut.current as EmployeeVO;
+ assertNotNull(currentEmployee);
+ assertEquals(DEPARTMENT_SALES, currentEmployee.department);
+ assertEquals(ID_TO_FIND, currentEmployee.uniqueID);
+ }
+
+ [Test]
+ public function
test_findLast_finds_sealed_class_instance_via_anonymous_object_with_subset_of_properties():void
+ {
+ //given
+ const ID_TO_FIND:int = 0;
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean =
_sut.findLast({department:DEPARTMENT_DEVELOPMENT, uniqueID: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.uniqueID);
+ }
+
+ [Test]
+ public function
test_findLast_finds_sealed_class_instance_via_anonymous_object_with_subset_of_properties_and_string_values_instead_of_int():void
+ {
+ //given
+ const ID_TO_FIND:int = 0;
+ _utils.openAllNodes(_collectionView);
+
+ //when
+ var found:Boolean =
_sut.findLast({department:DEPARTMENT_DEVELOPMENT,
uniqueID:ID_TO_FIND.toString()});
+
+ //then
+ assertTrue(found);
+ var currentEmployee:EmployeeVO = _sut.current as EmployeeVO;
+ assertNotNull(currentEmployee);
+ assertEquals(DEPARTMENT_DEVELOPMENT, currentEmployee.department);
+ assertEquals(ID_TO_FIND, currentEmployee.uniqueID);
+ }
+
+ [Test]
+ public function
test_findAny_finds_sealed_class_instance_via_dynamic_class_instance_with_subset_of_properties():void
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+ var lastEmployee:EmployeeVO = _employeesByID[_employeesByID.length
- 1];
+
+ //when
+ var found:Boolean = _sut.findLast(new
DynamicVO(lastEmployee.name));
+
+ //then
+ assertTrue(found);
+ assertEquals(lastEmployee, _sut.current);
+ }
+
+ [Test]
+ public function
test_findLast_finds_sealed_class_instance_via_dynamic_class_instance_with_subset_of_properties():void
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+ var firstEmployee:EmployeeVO = _employeesByID[0];
+
+ //when
+ var found:Boolean = _sut.findLast(new
DynamicVO(firstEmployee.name));
+
+ //then
+ assertTrue(found);
+ assertEquals(firstEmployee, _sut.current);
+ }
+
+ /**
+ * 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
+ {
+ //given
+ _utils.openAllNodes(_collectionView);
+
+ var secondEmployee:EmployeeVO = _employeesByID[1] as EmployeeVO;
+ var secondToLastEmployee:EmployeeVO = _employeesByID[NO_EMPLOYEES
- 2] as EmployeeVO;
+
+ const sameName:String = "John";
+
+ //when
+ secondEmployee.name = sameName;
+ secondToLastEmployee.name = sameName;
+
+ var foundFromBeginning:Boolean = _sut.findAny({name:sameName});
+
+ //then
+ assertTrue(foundFromBeginning);
+ assertEquals(secondEmployee, _sut.current);
+
+ //when
+ var foundFromEnd:Boolean = _sut.findLast({name:sameName});
+
+ //then
+ assertTrue(foundFromEnd);
+ assertEquals(secondToLastEmployee, _sut.current);
+ }
+
+ private static function
createHierarchicalCollectionView(groupingCollection:GroupingCollection2):HierarchicalCollectionView
+ {
+ return new HierarchicalCollectionView(groupingCollection);
+ }
+
+ private static function createEmployees():ArrayCollection
+ {
+ var result:ArrayCollection = new ArrayCollection();
+ for (var i:int = 0; i < NO_EMPLOYEES_PER_DEPARTMENT * 2; i++)
+ {
+ result.addItem(createEmployee("Emp-" + i, (i <
NO_EMPLOYEES_PER_DEPARTMENT ? DEPARTMENT_DEVELOPMENT : DEPARTMENT_SALES), i));
+ }
+
+ return result;
+ }
+
+ private static function createEmployee(name:String, department:String,
uniqueID:int):EmployeeVO
+ {
+ var employeeVO:EmployeeVO = new EmployeeVO(name, department,
uniqueID);
+ _employeesByID[employeeVO.uniqueID] = employeeVO;
+ return employeeVO;
+ }
+
+ private static function
createGroupingCollection(source:ArrayCollection):GroupingCollection2
+ {
+ var collection:GroupingCollection2 = new GroupingCollection2();
+ var grouping:Grouping = new Grouping();
+ grouping.fields = [new GroupingField("department")];
+ collection.grouping = grouping;
+
+ collection.source = source;
+ collection.refresh();
+
+ return collection;
+ }
+ }
+}
+
+class EmployeeVO
+{
+ public var name:String;
+ public var department:String;
+ public var uniqueID:int;
+
+ public function EmployeeVO(name:String, department:String, uniqueID:int)
+ {
+ this.name = name;
+ this.department = department;
+ this.uniqueID = uniqueID;
+ }
+}
+
+class NamedVO
+{
+ public var name:String;
+
+ public function NamedVO(name:String)
+ {
+ this.name = name;
+ }
+}
+
+dynamic class DynamicVO
+{
+ public function DynamicVO(name:String)
+ {
+ this.name = name;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index 73ed1fd..514f27c 100644
--- a/frameworks/projects/framework/tests/mx/collections/SortNumbers.as
+++ b/frameworks/projects/framework/tests/mx/collections/SortNumbers.as
@@ -21,49 +21,48 @@ package mx.collections {
public class SortNumbers
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addNumbers():void
{
- ac.addItem(1);
- ac.addItem(2);
+ _sut.addItem(1);
+ _sut.addItem(2);
}
[Test]
public function nullSort():void
{
addNumbers();
- ac.sort = null;
- ac.refresh();
+ _sut.sort = null;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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();
- ac.sort = new Sort();
- ac.refresh();
+ _sut.sort = new Sort();
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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]
@@ -72,12 +71,12 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
addNumbers();
- ac.sort = sort;
- ac.refresh();
+ _sut.sort = sort;
+ _sut.refresh();
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
+ 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]
@@ -86,12 +85,12 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
addNumbers();
- ac.sort = sort;
+ _sut.sort = sort;
// Short should not take effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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]
@@ -100,21 +99,21 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
addNumbers();
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
// Sort should be in effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
+ assertEquals("Length is not two", 2, _sut.length);
+ assertEquals("First element not correct", 2, _sut[0]);
+ assertEquals("Second element not correct", 1, _sut[1]);
- ac.refresh();
+ _sut.refresh();
// and back to original
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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]
@@ -123,15 +122,15 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
addNumbers();
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
- ac.refresh();
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
+ _sut.refresh();
// Sort should not be in effect
- assertEquals("Length is not two", 2, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
+ 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
@@ -142,27 +141,27 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _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, ac.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 1, ac[1]);
- assertEquals("Third element not correct", 1, ac[2]);
- assertEquals("Fourth element not correct", 2, ac[3]);
+ 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]);
- ac.refresh();
+ _sut.refresh();
// and back to being unsorted
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
- assertEquals("Third element not correct", 1, ac[2]);
- assertEquals("Fourth element not correct", 2, ac[3]);
+ 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
@@ -173,21 +172,21 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
- assertEquals("Length is not two", 2, ac.length);
+ assertEquals("Length is not two", 2, _sut.length);
- ac.removeItemAt(0); // still sorted so 2 is removed
leaving 1
- assertEquals("Length is not one", 1, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
+ _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]);
- ac.refresh();
+ _sut.refresh();
// still the same
- assertEquals("Length is not one", 1, ac.length);
- assertEquals("First element not correct", 1, ac[0]);
+ assertEquals("Length is not one", 1, _sut.length);
+ assertEquals("First element not correct", 1, _sut[0]);
}
[Test]
@@ -198,15 +197,15 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
- ac.sort = sort;
- ac.refresh();
+ _sut.sort = sort;
+ _sut.refresh();
- assertEquals("Length is not four", 4, ac.length);
+ assertEquals("Length is not four", 4, _sut.length);
- assertEquals("First element not correct", 2, ac[0]);
- assertEquals("Second element not correct", 2, ac[1]);
- assertEquals("Third element not correct", 1, ac[2]);
- assertEquals("Fourth element not correct", 1, ac[3]);
+ 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]);
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1d8d02c6/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
index bbdfbe7..09ba812 100644
--- a/frameworks/projects/framework/tests/mx/collections/SortStrings.as
+++ b/frameworks/projects/framework/tests/mx/collections/SortStrings.as
@@ -21,55 +21,54 @@ package mx.collections {
public class SortStrings
{
-
- protected var ac:ArrayCollection;
+ private var _sut:ArrayCollection;
[Before]
public function setUp():void
{
- ac = new ArrayCollection();
+ _sut = new ArrayCollection();
}
[After]
public function tearDown():void
{
- ac = null;
+ _sut = null;
}
protected function addStrings():void
{
- ac.addItem("A");
- ac.addItem("B");
- ac.addItem("D");
- ac.addItem("C");
+ _sut.addItem("A");
+ _sut.addItem("B");
+ _sut.addItem("D");
+ _sut.addItem("C");
}
[Test]
public function nullSort():void
{
addStrings();
- ac.sort = null;
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "D", ac[2]);
- assertEquals("Second element not correct", "C", ac[3]);
+ _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();
- ac.sort = new Sort();
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "C", ac[2]);
- assertEquals("Second element not correct", "D", ac[3]);
+ _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]
@@ -78,14 +77,14 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true)];
addStrings();
- ac.sort = sort;
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "D", ac[0]);
- assertEquals("Second element not correct", "C", ac[1]);
- assertEquals("First element not correct", "B", ac[2]);
- assertEquals("Second element not correct", "A", ac[3]);
+ _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]
@@ -94,14 +93,14 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
addStrings();
- ac.sort = sort;
- ac.refresh();
-
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "C", ac[2]);
- assertEquals("Second element not correct", "D", ac[3]);
+ _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]
@@ -110,14 +109,14 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
addStrings();
- ac.sort = sort;
+ _sut.sort = sort;
// Short should not take effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "D", ac[2]);
- assertEquals("Second element not correct", "C", ac[3]);
+ 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]
@@ -126,25 +125,25 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
addStrings();
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
// Sort should be in effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "C", ac[2]);
- assertEquals("Second element not correct", "D", ac[3]);
+ 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]);
- ac.refresh();
+ _sut.refresh();
// and back to original
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "D", ac[2]);
- assertEquals("Second element not correct", "C", ac[3]);
+ 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]
@@ -153,17 +152,17 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
addStrings();
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
- ac.refresh();
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
+ _sut.refresh();
// Sort should not be in effect
- assertEquals("Length is not four", 4, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "D", ac[2]);
- assertEquals("Second element not correct", "C", ac[3]);
+ 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
@@ -174,35 +173,35 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _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, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "C", ac[2]);
- assertEquals("Second element not correct", "D", ac[3]);
- assertEquals("First element not correct", "A", ac[4]);
- assertEquals("Second element not correct", "B", ac[5]);
- assertEquals("First element not correct", "D", ac[6]);
- assertEquals("Second element not correct", "C", ac[7]);
-
- ac.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("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, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "B", ac[1]);
- assertEquals("First element not correct", "D", ac[2]);
- assertEquals("Second element not correct", "C", ac[3]);
- assertEquals("First element not correct", "A", ac[4]);
- assertEquals("Second element not correct", "B", ac[5]);
- assertEquals("First element not correct", "D", ac[6]);
- assertEquals("Second element not correct", "C", ac[7]);
+ 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
@@ -213,20 +212,20 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField(null, false, true, true)];
- ac.sort = sort;
- ac.refresh();
- ac.sort = null;
+ _sut.sort = sort;
+ _sut.refresh();
+ _sut.sort = null;
- assertEquals("Length is not four", 4, ac.length);
+ assertEquals("Length is not four", 4, _sut.length);
- ac.removeItemAt(0); // still sorted so 2 is removed
leaving 1
- assertEquals("Length is not three", 3, ac.length);
- assertEquals("First element not correct", "B", ac[0]);
+ _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]);
- ac.refresh();
+ _sut.refresh();
- assertEquals("Length is not four", 3, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
+ assertEquals("Length is not four", 3, _sut.length);
+ assertEquals("First element not correct", "A",
_sut[0]);
}
[Test]
@@ -237,18 +236,18 @@ package mx.collections {
var sort:Sort = new Sort();
sort.fields = [new SortField()];
- ac.sort = sort;
- ac.refresh();
-
- assertEquals("Length is not eight", 8, ac.length);
- assertEquals("First element not correct", "A", ac[0]);
- assertEquals("Second element not correct", "A", ac[1]);
- assertEquals("First element not correct", "B", ac[2]);
- assertEquals("Second element not correct", "B", ac[3]);
- assertEquals("First element not correct", "C", ac[4]);
- assertEquals("Second element not correct", "C", ac[5]);
- assertEquals("First element not correct", "D", ac[6]);
- assertEquals("Second element not correct", "D", ac[7]);
+ _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]);
}
}