blob: b3e4f72b5ca9e039bc5d909da227ef64e60e21c3 [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.
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="800" height="600"
xmlns:assets="assets.*">
<fx:Script>
<![CDATA[
import assets.*;
import mx.collections.AsyncListView;
import spark.components.*;
public var storedItem:Object;
// I've created so many verify methods that I'm confused calling one of them just "verifyItems()", but I
// don't want to to go rewrite hundreds of tests. I guess I'm lazy. So verifyALVItems() just calls verifyItems().
public function verifyALVItems(startIndex:int, endIndex:int, status:String, alv:AsyncListView, offset:int = 0):String{
return verifyItems(startIndex, endIndex, status, alv, offset);
}
// Verify the startIndex to endIndex items with the given status with getItemAt().
public function verifyItems(startIndex:int, endIndex:int, status:String, alv:AsyncListView, offset:int = 0):String{
var ret:String = "pass";
var expectedString:String;
var actualString:String;
var i:int;
for(i = startIndex; i <= endIndex; ++i){
expectedString = "item " + (i+offset).toString() + " " + status;
actualString = alv.getItemAt(i).info;
//trace("i=" + i + ", expected=" + expectedString + ", actual=" + actualString);
if( expectedString != actualString ){
if(ret == "pass")
ret = "";
ret += " expected: " + expectedString + " got: " + actualString;
}
}
return ret;
}
// Call getItemAt on the AsyncListView's list. This will cause RTEs if the items are pending.
public function verifyGetItemRTEs(startIndex:int, endIndex:int, alv:AsyncListView):String{
var ret:String = "pass";
var expectedSubString:String;
var actualString:String;
var i:int;
for(i = startIndex; i <= endIndex; ++i){
expectedSubString = "Items: " + i.toString() + " through " + i.toString();
try{
alv.list.getItemAt(i);
}catch(e:Error){
actualString = e.message;
}
if( actualString.indexOf(expectedSubString) == -1 ){
if(ret == "pass")
ret = "";
ret += expectedSubString + " not in " + actualString + ". ";
}
}
return ret;
}
// Verify the startIndex to endIndex items in the List's dataGroup elements.
public function verifyDataGroupItems(startIndex:int, endIndex:int, status:String, dataGroup:DataGroup, offset:int = 0):String{
var ret:String = "pass";
var expectedString:String;
var actualString:String;
var i:int;
//trace("numElements: " + dataGroup.numElements);
for(i = startIndex; i <= endIndex; ++i){
//trace("i: " + i);
expectedString = "item " + (i+offset).toString() + " " + status;
actualString = Object(dataGroup.getElementAt(i)).nameLabel.text;
if( expectedString != actualString ){
if(ret == "pass")
ret = "";
ret += " expected: " + expectedString + " got: " + actualString;
}
}
return ret;
}
public function verifySimulatorItems(startIndex:int, endIndex:int, status:String, sim:ItemPendingErrorSimulator, offset:int = 0):String{
var ret:String = "pass";
var expectedString:String;
var actualString:String;
var i:int;
for(i = startIndex; i <= endIndex; ++i){
expectedString = "item " + (i+offset).toString() + " " + status;
actualString = sim.source[i].info;
// trace("i=" + i + ", expected=" + expectedString + ", actual=" + actualString);
if( expectedString != actualString ){
if(ret == "pass")
ret = "";
ret += " expected: " + expectedString + " got: " + actualString;
}
}
return ret;
}
// Tests already verify getItemAt(). So now we just check that getItemIndex() calls work for all items.
public function verifyALVIndices(startIndex:int, endIndex:int, alv:AsyncListView):String{
var ret:String = "pass";
var i:int;
var actual:int;
for(i = startIndex; i <= endIndex; ++i){
actual = alv.getItemIndex(alv.getItemAt(i));
if( actual != i){
if(ret == "pass")
ret = "";
ret += " expected: " + i.toString() + " got: " + actual.toString();
}
}
return ret;
}
// Call getItemAt() for startIndex to endIndex.
public function callGetItemAtFor(startIndex:int, endIndex:int, alv:AsyncListView):void{
var i:int;
for(i = startIndex; i <= endIndex; ++i){
alv.getItemAt(i);
}
}
]]>
</fx:Script>
<!-- Embed fonts for cross platform compatibility of bitmap compares. -->
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
</fx:Style>
<s:HGroup>
<s:VGroup>
<assets:PagedDataComp7 id="obj7" />
</s:VGroup>
</s:HGroup>
</s:Application>