blob: 5477b8f926e0534e9f6d1c854ad5c538d34f26f9 [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="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>
<!--
========================================================
selectedItem
Verify that the correct button ends up in the selected
state and that selectedIndex is correct.
========================================================
-->
<TestCase testID="selectedItem_sanityTest" keywords="[ButtonBar,selectedItem]" description="Make sure selection looks right." >
<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" />
<AssertPropertyValue target="bb1" propertyName="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(0)" />
<AssertPropertyValue target="bb1.dataGroup.getElementAt(0)" propertyName="selected" value="true" />
<CompareBitmap numColorVariances="4" maxColorVariance="8" url="../Properties/baselines/$testID.png" target="bb1" />
</body>
</TestCase>
<TestCase testID="selectedItem_test1" keywords="[ButtonBar,selectedItem]" 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="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(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="selectedIndex" value="0" />
</body>
</TestCase>
<TestCase testID="selectedItem_test2" keywords="[ButtonBar,selectedItem]" 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="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(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="selectedIndex" value="1" />
</body>
</TestCase>
<TestCase testID="selectedItem_test3" keywords="[ButtonBar,selectedItem]" 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="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(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="selectedIndex" value="2" />
</body>
</TestCase>
<TestCase testID="selectedItem_test4" keywords="[ButtonBar,selectedItem]" description="Use it to select an item which is not in the bar." >
<setup>
<ResetComponent target="bb1" className="spark.components::ButtonBar" waitEvent="updateComplete" />
<RunCode code="application.setDataProvider(application.bb1, 1)" waitTarget="bb1" waitEvent="updateComplete" />
<RunCode code="application.setDataProvider(application.bb2, 2)" waitTarget="bb2" waitEvent="updateComplete" />
</setup>
<body>
<SetProperty target="bb1" propertyName="selectedItem" valueExpression="value=application.bb2" 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="selectedIndex" value="-1" />
</body>
</TestCase>
<TestCase testID="selectedItem_test5" keywords="[ButtonBar,selectedItem]" description="Use it to select an item which is already selected. Just change the size instead of pausing." >
<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="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(2)" waitEvent="updateComplete" />
<SetProperty target="bb1" propertyName="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(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="selectedIndex" value="2" />
</body>
</TestCase>
<TestCase testID="selectedItem_test6" keywords="[ButtonBar,selectedItem]" description="Use it to select an item, then remove the item. Prop should then be null or undefined." >
<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="selectedItem" valueExpression="value=application.bb1.dataProvider.getItemAt(2)" waitEvent="updateComplete" />
<RunCode code="application.bb1.dataProvider.removeItemAt(2)" waitTarget="bb1" 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" propertyName="selectedIndex" value="-1" />
<AssertPropertyValue target="bb1" propertyName="selectedItem" valueExpression="value=undefined" />
</body>
</TestCase>
<TestCase testID="selectedItem_test7" keywords="[ButtonBar,selectedItem]" description="Set it to null." >
<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="selectedItem" valueExpression="value=null" />
<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="false" />
<AssertPropertyValue target="bb1" propertyName="selectedIndex" value="-1" />
</body>
</TestCase>
<TestCase testID="selectedItem_test8" keywords="[ButtonBar,selectedItem]" description="Set it to null when something is selected. Because deselecting a button does not dispatch an event (SDK-18305), change size and wait for updateComplete." >
<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="selectedItem" value="1" waitEvent="updateComplete" />
<SetProperty target="bb1" propertyName="selectedItem" valueExpression="value=null" />
<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="false" />
<AssertPropertyValue target="bb1" propertyName="selectedIndex" value="-1" />
</body>
</TestCase>
<!-- Bug SDK-18389. -->
<TestCase testID="selectedItem_test9" keywords="[ButtonBar,selectedItem]" description="Set it to null 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="selectedItem" value="null" />
<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="selectedIndex" value="0" />
</body>
</TestCase>
<TestCase testID="selectedItem_test10" keywords="[ButtonBar,selectedItem]" 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="selectedItem" value="one" />
</body>
</TestCase>
<TestCase testID="selectedItem_test11" keywords="[ButtonBar,selectedItem]" 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="selectedItem" value="two" />
</body>
</TestCase>
<TestCase testID="selectedItem_test12" keywords="[ButtonBar,selectedItem]" 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="selectedItem" value="three" />
</body>
</TestCase>
<TestCase testID="selectedItem_test13" keywords="[ButtonBar,selectedItem]" description="Get it when nothing 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>
<AssertPropertyValue target="bb1" propertyName="selectedItem" value="null" />
</body>
</TestCase>
</testCases>
</UnitTester>