| <?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="collections/ArrayCollection/Methods/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="ArrayCollectionMain.mxml"> |
| <mx:Script> |
| <![CDATA[ |
| |
| public static function init(o:DisplayObject):void |
| { |
| |
| } |
| ]]> |
| </mx:Script> |
| <mx:Metadata> |
| <![CDATA[ |
| [Mixin] |
| ]]> |
| </mx:Metadata> |
| |
| |
| |
| <mx:Script> |
| <![CDATA[ |
| import mx.collections.*; |
| public var obj1:Object = {abbreviation:"WIN", name:"Winnipeg", international:false}; |
| public var obj2:Object = {abbreviation:"SAC", name:"Sacramento", international:true}; |
| public var obj3:Object = {abbreviation:"SEA", name:"Seattle", international:true}; |
| public var colLength:int; |
| ]]> |
| </mx:Script> |
| |
| <testCases> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemAtEnd" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <AssertMethodValue method="value = 0; try |
| { application.airportCollection.setItemAt(obj1, application.airportCollection.length); } |
| catch (e:Error) { value = e.message }" |
| value="Index '12' specified is out of bounds." /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemAtEndPastOne" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <AssertMethodValue method="value = 0; try |
| { application.airportCollection.setItemAt(obj1, application.airportCollection.length+1); } |
| catch (e:Error) { value = e.message }" |
| value="Index '13' specified is out of bounds." /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemBeforeEnd" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <RunCode code="colLength = application.airportCollection.length; |
| application.airportCollection.setItemAt(obj1, colLength -1);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(application.airportCollection.length-1).abbreviation == |
| obj1.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_AddItemAtEnd" keywords="[ArrayCollection, Method, addItemAt]"> |
| <body> |
| <RunCode code="colLength = application.airportCollection.length; |
| application.airportCollection.addItemAt(obj2, colLength);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(colLength).abbreviation == |
| obj2.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_AddItemAtEndPastOne" keywords="[ArrayCollection, Method, addItemAt]"> |
| <body> |
| <AssertMethodValue method="value = 0; try |
| { application.airportCollection.addItemAt(obj1, application.airportCollection.length+1); } |
| catch (e:Error) { value = e.message }" |
| value="Index '14' specified is out of bounds." /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemAt0" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <RunCode code="application.airportCollection.setItemAt(obj1, 0);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(0).abbreviation == |
| obj1.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemAtBeforeBeginning" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <AssertMethodValue method="value = 0; try |
| { application.airportCollection.setItemAt(obj2, -1); } |
| catch (e:Error) { value = e.message }" |
| value="Index '-1' specified is out of bounds." /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_SetItemAt1" keywords="[ArrayCollection, Method, setItemAt]"> |
| <body> |
| <RunCode code="application.airportCollection.setItemAt(obj3, 1);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(1).abbreviation == |
| obj3.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_AddItemAt0" keywords="[ArrayCollection, Method, addItemAt]"> |
| <body> |
| <RunCode code="application.airportCollection.addItemAt(obj1, 0);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(0).abbreviation == |
| obj1.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_AddItemAt1" keywords="[ArrayCollection, Method, addItemAt]"> |
| <body> |
| <RunCode code="application.airportCollection.addItemAt(obj2, 1);" /> |
| <AssertMethodValue method="value = (application.airportCollection.getItemAt(1).abbreviation == |
| obj2.abbreviation )" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_AddItemAtBeforeBeginning" keywords="[ArrayCollection, Method, addItemAt]"> |
| <body> |
| <AssertMethodValue method="value = 0; try |
| { application.airportCollection.addItemAt(obj2, -1); } |
| catch (e:Error) { value = e.message }" |
| value="Index '-1' specified is out of bounds." /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_removeItemAt" keywords="[ArrayCollection, Method, removeItemAt]"> |
| <body> |
| <AssertPropertyValue target="airportCollection" propertyName ="length" value="15"/> |
| <AssertMethodValue method="var obj:Object = application.airportCollection.getItemAt(3); |
| value = (application.airportCollection.removeItemAt(3).abbreviation == |
| obj.abbreviation )" value="true" /> |
| <AssertPropertyValue target="airportCollection" propertyName ="length" value="14"/> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_contains" keywords="[ArrayCollection, Method, contains]"> |
| <setup> |
| <RunCode code ="application.ready()" /> |
| </setup> |
| <body> |
| <AssertPropertyValue target="ac" propertyName ="length" value="4"/> |
| <AssertMethodValue method="value = application.ac.contains(application.players[1])" value="false" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_itemUpdated" keywords="[ArrayCollection, Method, itemUpdated]"> |
| <setup> |
| <RunCode code ="application.ready(); |
| var oldValue:Number = application.players[1].jerseyNumber; |
| application.players[1].jerseyNumber = 13; |
| application.ac.itemUpdated(application.players[1], 'jerseyNumber', oldValue, 13);" |
| /> |
| </setup> |
| <body> |
| <AssertPropertyValue target="ac" propertyName ="length" value="5"/> |
| <AssertMethodValue method="value = application.ac.contains(application.players[1])" value="true" /> |
| <AssertMethodValue method="value = application.players[1].jerseyNumber==application.ac[2].jerseyNumber" value="true" /> |
| <AssertMethodValue method="value = application.players[1].lastName==application.ac[2].lastName" value="true" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="ArrayCollection_Method_itemUpdated_contains" keywords="[ArrayCollection, Method, itemUpdated,contains]"> |
| <setup> |
| <RunCode code ="application.ready(); |
| var oldValue:Number = application.players[2].jerseyNumber; |
| application.players[2].jerseyNumber = 80; |
| application.ac.itemUpdated(application.players[2], 'jerseyNumber', oldValue, 80);" |
| /> |
| </setup> |
| <body> |
| <AssertPropertyValue target="ac" propertyName ="length" value="4"/> |
| <AssertMethodValue method="value = application.ac.contains(application.players[11])" value="false" /> |
| |
| </body> |
| </TestCase> |
| |
| </testCases> |
| </UnitTester> |