| <?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="gumbo/components/ButtonBar/Properties/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="ButtonBarApp1.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 spark.components.*; |
| |
| ]]> |
| </mx:Script> |
| |
| <testCases> |
| |
| <!-- |
| ======================================================== |
| selectedIndex |
| Verify that the correct button ends up in the selected |
| state and that selectedItem is correct. |
| ======================================================== |
| --> |
| |
| <TestCase testID="selectedIndex_test1" keywords="[ButtonBar,selectedIndex]" description="Use it to select the first item." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="0" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="one" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test2" keywords="[ButtonBar,selectedIndex]" description="Use it to select the middle item." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="1" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="two" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test3" keywords="[ButtonBar,selectedIndex]" description="Use it to select the last item." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="2" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="three" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test4" keywords="[ButtonBar,selectedIndex]" description="Set to -1 to deselect all." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="1" waitEvent="updateComplete" /> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="-1" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="null" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test5" keywords="[ButtonBar,selectedIndex]" description="Set to -2." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="-2" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="null" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test6" keywords="[ButtonBar,selectedIndex]" description="Set to 3 (out of bounds)." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="3" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="three" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test7" keywords="[ButtonBar,selectedIndex]" description="Use it to select an item which is already selected." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="2" waitEvent="updateComplete" /> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="2" /> |
| <SetProperty target="bb1" propertyName="width" valueExpression="value=application.bb1.width + 1" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="three" /> |
| </body> |
| </TestCase> |
| |
| <!-- Bug SDK-18389. --> |
| <TestCase testID="selectedIndex_test8" keywords="[ButtonBar,selectedIndex]" description="Set it to -1 when requireSelection is true (not allowed)." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="bb1" propertyName="requireSelection" value="true" waitEvent="updateComplete" /> |
| <SetProperty target="bb1" propertyName="selectedIndex" value="-1" /> |
| <SetProperty target="bb1" propertyName="width" valueExpression="value=application.bb1.width + 1" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="true" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedItem" value="one" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test9" keywords="[ButtonBar,selectedIndex]" description="Get it when the first item is selected." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <DispatchMouseClickEvent target="bb1.dataGroup.getElementAt(0)" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedIndex" value="0" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test10" keywords="[ButtonBar,selectedIndex]" description="Get it when the middle item is selected." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <DispatchMouseClickEvent target="bb1.dataGroup.getElementAt(1)" localX="10" localY="5" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedIndex" value="1" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test11" keywords="[ButtonBar,selectedIndex]" description="Get it when the last item is selected." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <DispatchMouseClickEvent target="bb1.dataGroup.getElementAt(2)" localX="10" localY="5" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedIndex" value="2" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="selectedIndex_test12" keywords="[ButtonBar,selectedIndex]" description="Get it when nothing is selected (standard default state)." > |
| <setup> |
| <ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" /> |
| <RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" /> |
| </setup> |
| <body> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(1)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1.dataGroup.getElementAt(2)" propertyName="selected" value="false" /> |
| <AssertPropertyValue target="bb1" propertyName="selectedIndex" value="-1" /> |
| </body> |
| </TestCase> |
| |
| </testCases> |
| </UnitTester> |