blob: 5b90b579c78fa2d36e108d080c3e3cd6bfee55f0 [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="components/PopUpMenuButton/Properties/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="PopUpMenuButton_Basic.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
{
}
public function addData(bool:int):void
{
application.pumb.showRoot = false;
application.pumb.dataProvider = myDP;
if(bool ==0)
{
application.pumb.labelField="@label";
}
else
{
application.pumb.labelField="@data";
}
}
public function addObjData():void
{
application.pumb.showRoot = false;
application.pumb.dataProvider = iconDP;
//application.pumb.iconField = "icon";
}
public function changeDP(node:int, bool:String):void
{
myDP.node[node].@enabled = Boolean(bool);
}
[Bindable]
private var rootDP:Object= {label: "top", children: [
{label: "File", children: [
{label: "Open"},
{label: "New File"}
]},
{label: "Edit", children: [
{label: "Copy"},
{label: "Paste"},
{label: "Send"}
]},
{label: "Window"}
]};
[Bindable]
public var iconDP:Object = [
{label:"Toys", icon:"dinosaur", icon2: "bear", children: [
{ label:"Stuffed Animals", children: [
{label:"Teddy Bears"},
{label:"Dinosaur", icon: "dinosaur"}
]},
{label:"Cars", children: [
{label:"RacecarA"},
{label:"RacecarB"}
]}
]},
{label:"Games", icon:"t1120", children: [
{ label:"Age 6 and up", children: [
{label:"Board Games"},
{label:"Chance Games"},
{label:"PoolGames" }
]},
{label:"Video Games", children: [
{label:"Video Game A"},
{label:"Video Game B"}
]}
]}
];
public function labelFunc(item:Object):String
{
var newLabel:String = item[application.pumb.labelField].toUpperCase();
return newLabel;
}
public function testAddChildAt():void
{
var newChild:Object = <nodeitem label='France' data='FRANCE' />;
application.pumb.dataDescriptor.addChildAt(myDP.node[0], newChild, 2);
}
public function testGetChildren(): void
{
application.lengthValue = application.pumb.dataDescriptor.getChildren(myDP.node[1]).length;
}
public function testRemoveChildAt():void
{
var newChild:Object = <nodeitem label='France' data='FRANCE' />;
application.pumb.dataDescriptor.removeChildAt(myDP.node[0], newChild, 2);
}
public function testSetEnabled(bool:int): void
{
if(bool==0)
{
application.pumb.dataDescriptor.setEnabled(myDP.node[2], false);
}
else
{
application.pumb.dataDescriptor.setEnabled(myDP.node[1], true);
application.pumb.dataDescriptor.setEnabled(myDP.node[2], true);
}
}
public function testSetToggled(bool:int): void
{
if(bool==0)
{
application.pumb.dataDescriptor.setToggled(myDP.node[0].nodeitem[1], false);
}
else
{
application.pumb.dataDescriptor.setToggled(myDP.node[1].nodeitem[1], true);
}
}
]]>
</mx:Script>
<mx:Metadata>
<![CDATA[
[Mixin]
]]>
</mx:Metadata>
<!-- end of set of lines that must be in each unit test -->
<mx:Script>
<![CDATA[
import mx.controls.PopUpMenuButton;
import mx.styles.StyleManager;
import mx.managers.SystemManager;
import mx.events.MenuEvent;
[Bindable]
private var myDP:XML =
<topnode>
<node label="Europe" enabled="false" data="EUROPE">
<nodeitem type="check" label="Italy" enabled="false" data="ITALY" />
<nodeitem type="check" label="England" data="ENGLAND" toggled="true"/>
<nodeitem type="check" label="Slovenia" data="SLOVENIA" />
</node>
<node label="Asia" enabled="true" data="ASIA">
<nodeitem type="radio" groupName="group1" label="Phillipines" enabled="false" data="PHILIPPINES"/>
<nodeitem type="radio" groupName="group1" label="Japan" data="JAPAN"/>
<nodeitem type="radio" groupName="group1" label="China" data="CHINA"/>
</node>
<node label="Africa" data="AFRICA">
<nodeitem label="Uganda" enabled="false" data="UGANDA"/>
<nodeitem label="South Africa" data="SOUTH AFRICA"/>
<nodeitem label="Nigeria" data="NIGERIA"/>
</node>
</topnode>;
]]>
</mx:Script>
<testCases>
<TestCase testID="Enabled_false" description="PopUpMenuButton dataProvider item is set to false test." keywords="[enabled, PopUpMenuButton]">
<setup>
<RunCode code="addData(0);" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN, DOWN, RIGHT, DOWN, ENTER]" waitTarget="pumb" waitEvent="itemClick" />
<AssertPropertyValue target="pumb" propertyName="label" value="Africa" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="Enabled_falseToTrue" description="PopUpMenuButton dataProvider item is set to false and changed to true test." keywords="[keystroke, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addData(0);" />
<RunCode code="changeDP(0,'true');" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn"/>
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN, RIGHT, DOWN, ENTER]" waitTarget="pumb" waitEvent="itemClick" />
<!--DispatchKeyEvent key="DOWN" />
<DispatchKeyEvent key="RIGHT" />
<DispatchKeyEvent key="DOWN" />
<DispatchKeyEvent key="ENTER" /-->
<AssertPropertyValue target="pumb" propertyName="label" value="Africa" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="Enabled_trueToFalse" description="PopUpMenuButton dataProvider item is set to true and changed to false test." keywords="[enabled, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addData(0);" />
<RunCode code="changeDP(1, 'false');" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn"/>
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN, RIGHT, DOWN, ENTER]" />
<AssertPropertyValue target="pumb" propertyName="label" value="Africa" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="Disabled_PixelCheck" description="PopUpMenuButton visual test of disabled item." keywords="[enabled, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addData(0);" />
<RunCode code="changeDP(1, 'false');"/>
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn" />
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN, RIGHT, ENTER]" />
<AssertPropertyValue target="pumb" propertyName="label" value="Asia" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="LabelField_subMenu" description="PopUpMenuButton labelField is set to 'data'." keywords="[labelField, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addData(1)" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn" />
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN,RIGHT,DOWN,ENTER]" />
<AssertEvent target="pumb" eventName="itemClick" eventClass="mx.events::MenuEvent"/>
<AssertEventPropertyValue target="pumb" propertyName="label" value="SLOVENIA" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="Icon_Basic" description="PopUpMenuButton item icon is set at top level. bitmap test." keywords="[icon, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn" />
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN,RIGHT,DOWN,RIGHT,DOWN,ENTER]" />
<AssertPropertyValue target="pumb" propertyName="label" value="Games" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="IconField_Basic" description="PopUpMenuButton iconField is set. bitmap test." keywords="[iconField, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();application.pumb.iconField='icon2'" />
<DispatchKeyEvent keys="[TAB, TAB, TAB]" waitEvent="focusIn" waitTarget="pumb" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN,RIGHT,DOWN,RIGHT,ENTER]" />
<AssertPropertyValue target="pumb" propertyName="label" value="Toys" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="selectedIndex_Zero_Keys" description="PopUpMenuButton selectedIndex=0 test with keyboard interaction." keywords="[selectedIndex, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();" waitTarget="pumb" waitEvent="updateComplete" />
<DispatchKeyEvent keys="[TAB, TAB, TAB]" waitEvent="focusIn" waitTarget="pumb" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN,RIGHT,DOWN,RIGHT,DOWN,ENTER]" />
<AssertEvent target="pumb" eventName="itemClick" eventClass="mx.events::MenuEvent"/>
<AssertEventPropertyValue target="pumb" propertyName="label" value="RacecarB" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="selectedIndex_Num_Keys" description="PopUpMenuButton selectedIndex=1 test with keyboard interaction." keywords="[selectedIndex, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();" />
<DispatchKeyEvent key="TAB" />
<DispatchKeyEvent key="TAB" waitTarget="btn" waitEvent="focusIn" />
<DispatchKeyEvent key="TAB" waitTarget="pumb" waitEvent="focusIn" />
<DispatchKeyEvent key="DOWN" waitTarget="pumb" waitEvent="open" ctrlKey="true" />
</setup>
<body>
<DispatchKeyEvent keys="[DOWN,RIGHT, RIGHT,DOWN,ENTER]" />
<AssertEvent target="pumb" eventName="itemClick" eventClass="mx.events::MenuEvent"/>
<AssertEventPropertyValue target="pumb" propertyName="label" value="Dinosaur" />
<WaitForEffectsToEnd/>
</body>
</TestCase>
<TestCase testID="PUMB_properties_layoutDirection_RTL" description="PopUpMenuButton layoutDirection='rtl'." keywords="[Mirroring, layoutDirection, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();" waitTarget="pumb"
waitEvent="updateComplete"/>
<SetStyle styleName="layoutDirection" value="rtl" target="pumb" />
<SetStyle styleName="textFieldClass" valueExpression="value=mx.core.UIFTETextField" target="pumb" />
<SetStyle styleName="direction" value="rtl" target="pumb" waitTarget="pumb"
waitEvent="updateComplete"/>
</setup>
<body>
<CompareBitmap url="../Properties/baselines/$testID.png" target="pumb" numColorVariances="8" ignoreMaxColorVariance="true"/>
</body>
</TestCase>
<TestCase testID="PUMB_properties_layoutDirection_RTL_onParent" description="PopUpMenuButton layoutDirection='rtl'." keywords="[Mirroring, layoutDirection, PopUpMenuButton]">
<setup>
<ResetComponent target="pumb" className="mx.controls.PopUpMenuButton" />
<RunCode code="addObjData();" waitTarget="pumb"
waitEvent="updateComplete"/>
<SetStyle styleName="layoutDirection" value="rtl" target="menuBarParent" />
<SetStyle styleName="textFieldClass" valueExpression="value=mx.core.UIFTETextField" target="pumb" />
<SetStyle styleName="direction" value="rtl" target="menuBarParent" waitTarget="menuBarParent"
waitEvent="updateComplete"/>
</setup>
<body>
<CompareBitmap url="../Properties/baselines/$testID.png" target="pumb" numColorVariances="8" ignoreMaxColorVariance="true"/>
<SetStyle styleName="layoutDirection" value="ltr" target="menuBarParent" />
</body>
</TestCase>
</testCases>
</UnitTester>