blob: 494fbe0e9a329adc32ba886184e654ff6bcd16ce [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 savedObject:Object;
]]>
</mx:Script>
<testCases>
<!--
getItemIndex() is called in the AssertMethodValue step of lots of other test cases, so this file only covers what
has not been done in those.
This is just a reminder.
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):void{
-->
<TestCase testID="getItemIndex_test1" keywords="[AsyncListView,getItemIndex]" description="Object isn't there." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.alv = new AsyncListView(FlexGlobals.topLevelApplication.obj1.ac)" />
</setup>
<body>
<AssertMethodValue method="value = FlexGlobals.topLevelApplication.obj1.alv.getItemIndex({info: 'some item', status: 'present'})" value="-1" />
</body>
</TestCase>
<TestCase testID="getItemIndex_test2" keywords="[AsyncListView,getItemIndex]" description="Object has been removed." >
<setup>
<ResetComponent target="obj1" className="assets.PagedDataComp1" waitEvent="updateComplete" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.alv = new AsyncListView(FlexGlobals.topLevelApplication.obj1.ac)" />
<RunCode code="savedObject = {info: 'added item', status: 'present'}" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.alv.addItem(savedObject)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.alv.removeItemAt(0)" />
</setup>
<body>
<AssertMethodValue method="value = FlexGlobals.topLevelApplication.obj1.alv.getItemIndex({info: 'some item', status: 'present'})" value="-1" />
</body>
</TestCase>
<!-- SDK-23832 -->
<TestCase testID="getItemIndex_test3" keywords="[AsyncListView,addItemAt]" description="Call getItemIndex() for the last item in the list if the last item in the list was made pending and received before the other items were made pending." >
<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="FlexGlobals.topLevelApplication.obj1.alv.getItemAt(29)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.items.receiveItem(29)" />
<RunCode code="FlexGlobals.topLevelApplication.callGetItemAtFor(0, 29, FlexGlobals.topLevelApplication.obj1.alv)" />
<RunCode code="FlexGlobals.topLevelApplication.obj1.alv.getItemIndex(FlexGlobals.topLevelApplication.obj1.alv.getItemAt(29))" />
<AssertMethodValue method="value = FlexGlobals.topLevelApplication.verifyItems(0, 28, 'pending', FlexGlobals.topLevelApplication.obj1.alv)" value="pass" />
<AssertMethodValue method="value = FlexGlobals.topLevelApplication.obj1.alv.getItemAt(29).info" value="item 29 present" />
</body>
</TestCase>
</testCases>
</UnitTester>