| <?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/RadioButton/states/" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:m="http://ns.adobe.com/mxml/2009" xmlns="*" testSWF="FxRadioButtonStates.mxml"> |
| |
| <!-- this set of lines form a template that must be in each unit test --> |
| <fx:Script> |
| <![CDATA[ |
| public static function init(o:DisplayObject):void { } |
| ]]> |
| </fx:Script> |
| <fx:Metadata> |
| <![CDATA[ |
| [Mixin] |
| ]]> |
| </fx:Metadata> |
| <!-- end of set of lines that must be in each unit test --> |
| <fx:Script> |
| <![CDATA[ |
| |
| import spark.layouts.*; |
| import mx.controls.Label; |
| import comps.*; |
| import mx.core.ClassFactory; |
| import mx.collections.ArrayCollection; |
| import mx.graphics.*; |
| import spark.skins.*; |
| import mx.core.mx_internal; |
| |
| ]]> |
| </fx:Script> |
| <testCases> |
| |
| |
| <!-- |
| |
| ======================= |
| FxRadioButton States Tests |
| ======================= |
| |
| Some basic tests to make sure that RadioButton works properly when changing states. This covers changing properties through the new syntax |
| as well as basic test that RadioButton respects includeIn/excludeFrom. |
| |
| [Note that many tests don't define target or waitTarget, this is because the default if not defined is the application. This could also be done via {FlexGlobals.topLevelApplication}, but you will get compiler binding warnings using that.] |
| |
| + Ensure that includeIn and excludeFrom works in MXML |
| + Ensure selection is persistant across state changes |
| + Check that selected property change across states |
| test FxRadioButtons can exist in one RadioButtonGroup but across multiple states |
| --> |
| |
| <TestCase testID="FxRadioButton_states_persist_selection" keywords="[FxRadioButton, states, selected]" description="select a rb, change states, change back, should still be selected (SDK-17424)"> |
| <setup> |
| <ResetComponent target="rb1" className="spark.components.RadioButton" waitEvent="updateComplete" waitTarget="rb1" /> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <SetProperty target="rb1" propertyName="selected" value="true" waitTarget="rb1" waitEvent="updateComplete" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty propertyName="currentState" value="state1" waitEvent="updateComplete" waitTarget="skin"/> |
| <AssertPropertyValue propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="rb1" propertyName="selected" value="true" /> |
| |
| <SetProperty propertyName="currentState" value="state2" waitEvent="updateComplete" waitTarget="skin"/> |
| <AssertPropertyValue propertyName="currentState" value="state2" /> |
| <AssertPropertyValue target="rb1" propertyName="selected" value="true" /> |
| <CompareBitmap url="../states/baselines/fxradiobutton_states_persist_selection.png" target="rb1" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_states_includeExclude" keywords="[FxRadioButton, states, includeIn, excludeFrom]" description="check includeIn and excludeFrom work on a FxRadioButton"> |
| <setup> |
| <ResetComponent target="rb1" className="spark.components.RadioButton" waitEvent="updateComplete" waitTarget="rb1" /> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty propertyName="currentState" value="state1" waitEvent="currentStateChange" /> |
| <AssertPropertyValue propertyName="currentState" value="state1" /> |
| |
| <CompareBitmap url="../states/baselines/fxradiobutton_states_includeExclude_a.png" target="" timeout="2000" /> |
| |
| <SetProperty propertyName="currentState" value="state2" waitEvent="currentStateChange" /> |
| <AssertPropertyValue propertyName="currentState" value="state2" /> |
| |
| <CompareBitmap url="../states/baselines/fxradiobutton_states_includeExclude_z.png" target="" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButtonGroup_states_includeExclude" keywords="[FxRadioButton, states, includeIn, excludeFrom]" description="check includeIn and excludeFrom work on a FxRadioButton"> |
| <setup> |
| <ResetComponent target="rb1" className="spark.components.RadioButton" waitEvent="updateComplete" waitTarget="rb1" /> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty propertyName="currentState" value="state4" waitEvent="updateComplete" waitTarget="skin" /> |
| <AssertPropertyValue propertyName="currentState" value="state4" /> |
| <Pause timeout="1000"/> |
| <CompareBitmap url="../states/baselines/$testID.png" target="" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_states_SDK_18468" keywords="[FxRadioButton, states, includeIn, excludeFrom]" description="check RadioButton can exist in multiple states and still only one RadioButton is selected per group"> |
| <setup> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state1" /> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state2" waitTarget="stateRBG.s3" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state2" /> |
| |
| <!-- Verify all the appropriate FxRadioButtons appear--> |
| <CompareBitmap url="../states/baselines/fxradiobutton_SDK18468_state2.png" target="stateRBG" /> |
| |
| <!-- Select new in this state RadioButton --> |
| <DispatchMouseClickEvent target="stateRBG.s3" localX="4" localY="8" waitEvent="updateComplete" waitTarget="stateRBG.s3"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s3" value="true"/> |
| <CompareBitmap url="../states/baselines/fxradiobutton_SDK18468_selected_new.png" target="stateRBG" /> |
| |
| <!--Select already existing RadioButton --> |
| <DispatchMouseClickEvent target="stateRBG.s1" localX="4" localY="8" waitEvent="updateComplete" waitTarget="stateRBG.s3"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s1" value="true"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s3" value="false"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s2" value="false"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s4" value="false"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s5" value="false"/> |
| |
| <CompareBitmap url="../states/baselines/$testID.png" target="stateRBG" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_states_selectedValue_FxRadioButtonGroup" keywords="[FxRadioButton, states, selectedValue]" description="check selectedValue of RadioButtonGroup updates as FxRadioButtons are added and removed"> |
| <setup> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state1" /> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state2" waitTarget="stateRBG.s3" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state2" /> |
| |
| <!-- Select new in this state RadioButton --> |
| <DispatchMouseClickEvent target="stateRBG.s3" localX="4" localY="8" waitEvent="updateComplete" waitTarget="stateRBG.s3"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s3" value="true"/> |
| <AssertPropertyValue propertyName="selectedValue" target="stateRBG.sparkGrp" value="Spark 3"/> |
| <!--Select already existing RadioButton --> |
| <DispatchMouseClickEvent target="stateRBG.s1" localX="4" localY="8" waitEvent="updateComplete" waitTarget="stateRBG.s3"/> |
| <AssertPropertyValue propertyName="selectedValue" target="stateRBG.sparkGrp" value="Spark 1"/> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_selectedValue_FxRadioButtonGroup_removed_FxRadioButton" keywords="[FxRadioButton, states, selectedValue]" description="check selectedValue of RadioButtonGroup updates as FxRadioButtons are added and removed"> |
| <setup> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state1" /> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state2" waitTarget="stateRBG.s3" waitEvent="updateComplete" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state2" /> |
| |
| <!-- Select new in this state RadioButton --> |
| <DispatchMouseClickEvent target="stateRBG.s3" localX="4" localY="8" waitEvent="updateComplete" waitTarget="stateRBG.s3"/> |
| <AssertPropertyValue propertyName="selected" target="stateRBG.s3" value="true"/> |
| <AssertPropertyValue propertyName="selectedValue" target="stateRBG.sparkGrp" value="Spark 3"/> |
| <SetProperty target="stateRBG" propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="stateRBG" propertyName="currentState" value="state1" /> |
| <AssertPropertyValue propertyName="selectedValue" target="stateRBG.sparkGrp" value="null"/> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_different_parent_containers_FxRadioButton" keywords="[FxRadioButton, states, parent]" description="Verify RadioButtons in the same group with different parent containers do not RTE"> |
| <setup> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| </setup> |
| <body> |
| <SetProperty propertyName="currentState" value="rteState" waitEvent="currentStateChange" /> |
| <AssertPropertyValue propertyName="currentState" value="rteState" /> |
| <CompareBitmap url="../states/baselines/$testID.png" target="rteRBG" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="FxRadioButton_states_propertyChange_selected" keywords="[FxRadioButton, states, selected]" description="check that selected property can be toggled between states"> |
| <setup> |
| <ResetComponent target="rb1" className="spark.components.RadioButton" waitEvent="updateComplete" waitTarget="rb1" /> |
| <ResetComponent target="stateRBG" className="comps.StateRadioButtonGroup" waitEvent="updateComplete" waitTarget="stateRBG" /> |
| |
| <RunCode code="application.resetStateTest()" waitEvent="manualResetComplete" /> |
| <AssertMethodValue method="value=application.resetStatePropertyChange();" value="true" /> |
| |
| <AssertMethodValue method="value=application.addStatePropertyChange('state1', 'rb1', 'selected', true);" value="1" /> |
| <AssertMethodValue method="value=application.addStatePropertyChange('state2', 'rb1', 'selected', false);" value="1" /> |
| </setup> |
| <body> |
| <SetProperty propertyName="currentState" value="state1" waitEvent="currentStateChange" /> |
| <AssertPropertyValue propertyName="currentState" value="state1" /> |
| <AssertPropertyValue target="rb1" propertyName="selected" value="true" /> |
| |
| <SetProperty propertyName="currentState" value="state2" waitEvent="currentStateChange" /> |
| <AssertPropertyValue propertyName="currentState" value="state2" /> |
| <AssertPropertyValue target="rb1" propertyName="selected" value="false" /> |
| </body> |
| </TestCase> |
| |
| </testCases> |
| </UnitTester> |