blob: 86cf5d3e611a61a934a648af623ec0d9094c92c2 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<UnitTester
testDir="mx/collections/AsyncListView/methods/"
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="*"
xmlns:assets="assets.*"
testSWF="AsyncListView_App1.mxml">
<!-- this set of lines form a template that must be in each unit test -->
<mx:Script>
<![CDATA[
public static function init(o:DisplayObject):void
{
}
]]>
</mx:Script>
<mx:Metadata>
<![CDATA[
[Mixin]
]]>
</mx:Metadata>
<!-- end of set of lines that must be in each unit test -->
<mx:Script>
<![CDATA[
import assets.*;
import mx.collections.*;
import mx.core.FlexGlobals;
public var theArray:Array;
// Call getItemAt() on the first numItems items.
// This will make sure we have a bunch of pending items
// in our AsyncListView.
public function callGetItemAt(numItems:int):void{
var i:int;
for(i = 0; i < numItems; ++i){
FlexGlobals.topLevelApplication.obj1.alv.getItemAt(i);
}
}
// Verify that there are numItems items with the correct status.
public function verifyItems(numItems:int, status:String):String{
var ret:String = "pass";
var expectedString:String;
var actualString:String;
var i:int;
if(theArray.length == numItems){
for(i = 0; i < theArray.length; ++i){
expectedString = "item " + i.toString() + " " + status + " " + status;
actualString = theArray[i].info + " " + theArray[i].status;
if( expectedString != actualString ){
ret = "expected: " + expectedString + " got: " + actualString;
break;
}
}
}else{
ret = "Array length was " + theArray.length.toString() + ", expected " + numItems.toString();
}
return ret;
}
]]>
</mx:Script>
<testCases>
<!--
public function setup( responseDelay:int = 500,
numItems:int = 100,
numPreloadedPages:int = 0,
pageSize:int = 1,
mode:String = 'manual',
failureProbability:int = 0,
createPendingItemFunction:Boolean = true,
createFailedItemFunction:Boolean = true
assignToList:Boolean = true):void
-->
<TestCase testID="toArray_headless_test1" keywords="[AsyncListView,toArray]" description="An AsyncListView should get populated with pending items when toArray() is called." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,1,'manual',0,true,true,false)" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'pending')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_headless_test2" keywords="[AsyncListView,toArray]" description="Call when there are all items are already pending." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,1,'manual',0,true,true,false)" />
</setup>
<body>
<RunCode code="callGetItemAt(30)" />
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'pending')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_headless_test3" keywords="[AsyncListView,toArray]" description="Call when there are all failed items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,30,'manual',0,true,true,false)" />
</setup>
<body>
<RunCode code="callGetItemAt(30)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.items.failPage()" />
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'failed')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_headless_test4" keywords="[AsyncListView,toArray]" description="Call when there are all present items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,30,'manual',0,true,true,false)" />
</setup>
<body>
<RunCode code="callGetItemAt(30)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.items.receivePage()" />
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'present')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_headless_test5" keywords="[AsyncListView,toArray]" description="Call when there are no items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,0,0,1,'manual',0,true,true,false)" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertPropertyValue target="script:theArray" propertyName="length" value="0" />
</body>
</TestCase>
<TestCase testID="toArray_headless_test6" keywords="[AsyncListView,toArray]" description="Call it when the AsyncListView has no list.">
<body>
<Pause timeout="1" />
<AssertMethodValue method="value = new AsyncListView().toArray()" value="" />
<Pause timeout="1" />
</body>
</TestCase>
<TestCase testID="toArray_inVirtualizedList_test1" keywords="[AsyncListView,toArray]" description="Call when there are all pending items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30)" waitTarget="obj1.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'pending')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inVirtualizedList_test2" keywords="[AsyncListView,toArray]" description="Call when there are all failed items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,30)" waitTarget="obj1.theList.dataGroup" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.callGetItemAtFor(0, 29, FlexGlobals.topLevelApplication.obj1.alv)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.items.failPage()" waitTarget="obj1.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'failed')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inVirtualizedList_test3" keywords="[AsyncListView,toArray]" description="Call when there are all present items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,30,0,30)" waitTarget="obj1.theList.dataGroup" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.items.receivePage()" waitTarget="obj1.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'present')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inVirtualizedList_test4" keywords="[AsyncListView,toArray]" description="Call when there are no items." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.setup(0,0)" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj1.alv.toArray()" />
<AssertPropertyValue target="script:theArray" propertyName="length" value="0" />
</body>
</TestCase>
<TestCase testID="toArray_inNonvirtualizedList_test1" keywords="[AsyncListView,toArray]" description="Call when there are all pending items." >
<setup>
<ResetComponent target="obj8" className="assets.PagedDataComp8" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.setup(0,30)" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj8.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'pending')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inNonvirtualizedList_test2" keywords="[AsyncListView,toArray]" description="Call when there are all failed items." >
<setup>
<ResetComponent target="obj8" className="assets.PagedDataComp8" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.setup(0,30,0,30)" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.theSimulator.failPage()" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj8.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'failed')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inNonvirtualizedList_test3" keywords="[AsyncListView,toArray]" description="Call when there are all present items." >
<setup>
<ResetComponent target="obj8" className="assets.PagedDataComp8" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.setup(0,30,0,30)" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.theSimulator.receivePage()" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj8.alv.toArray()" />
<AssertMethodValue method="value = verifyItems(30, 'present')" value="pass" />
</body>
</TestCase>
<TestCase testID="toArray_inNonvirtualizedList_test4" keywords="[AsyncListView,toArray]" description="Call when there are no items." >
<setup>
<ResetComponent target="obj8" className="assets.PagedDataComp8" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj8.setup(0,0)" waitTarget="obj8.theList.dataGroup" waitEvent="updateComplete" />
</setup>
<body>
<RunCode code="theArray = FlexGlobals.topLevelApplication.obj8.alv.toArray()" />
<AssertPropertyValue target="script:theArray" propertyName="length" value="0" />
</body>
</TestCase>
</testCases>
</UnitTester>