blob: 620be7e89ced95b09e6c37529ec39ba6ca74be82 [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/ComboBox/Properties/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="ComboBoxMain.mxml">
<mx:Script>
<![CDATA[
public static function init(o:DisplayObject):void
{
}
]]>
</mx:Script>
<mx:Metadata>
<![CDATA[
[Mixin]
]]>
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.styles.StyleManager;
import mx.managers.SystemManager;
private var arr1:Array = [{slno:"1",name:"Joseph",data:"23"},{slno:"2",name:"Jeena",data:"21"},{slno:"3",name:"Jerry",data:"4"}
,{slno:"4",name:"Tom",data:"1"},{slno:"5",name:"Rick",data:"12"},{slno:"6",name:"John",data:"52"}];
private var arr2:Array = [{slno:"1",label:"Joseph",age:"23"},{slno:"2",label:"Jeena",age:"21"},{slno:"3",label:"Jerry",age:"4"}
,{slno:"4",label:"Tom",age:"1"},{slno:"5",label:"Rick",age:"12"},{slno:"6",label:"John",age:"52"}];
public function addItems():void
{
for(var i:int=0;i<15;i++)
{
var obj:Object={slno:i,name:"Added Item",age:100+i}
application.mybox.myCB.dataProvider.addItem(obj);
}
}
public function addLongItem():void
{
var obj:Object={slno:0,name:"Added Looooooooooooooooooooooooooooooooooooooooooooooooooooooooong Item",age:100}
application.mybox.myCB.dataProvider.addItemAt(obj,0);
}
public function myCBLabelFunction(obj:Object):String
{
return(obj.name + "[check]");
}
public function remove_and_repopulate():void
{
application.mybox.myCB.dataProvider.removeAll();
application.mybox.myCB.dataProvider=[{slno:"1",label:"Joseph",age:"23"},{slno:"2",label:"Jeena",age:"21"},{slno:"3",label:"Jerry",age:"4"}
,{slno:"4",label:"Tom",age:"1"},{slno:"5",label:"Rick",age:"12"},{slno:"6",label:"John",age:"52"}];
}
]]>
</mx:Script>
<testCases>
<TestCase testID="Spark_combobase_properties_editable" keywords="[comboBase, properties, editable]">
<setup>
<ResetComponent target="mybox" className="ComboBoxComp" waitEvent="updateComplete" waitTarget="mybox"/>
</setup>
<body>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="2" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="selectedIndex" value="2"/>
<CompareBitmap target="mybox" url="../Properties/Baselines/cb_properties_selectedIndex_spark.png" />
</body>
</TestCase>
<TestCase testID="Spark_combobase_properties_text" keywords="[comboBase, properties, text]">
<setup>
<ResetComponent target="mybox" className="ComboBoxComp" waitEvent="updateComplete" waitTarget="mybox"/>
</setup>
<body>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="3" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="text" value="Tom"/>
</body>
</TestCase>
<TestCase testID="Spark_combobase_properties_selectedIndex" keywords="[comboBase, properties, selectedIndex]">
<setup>
<ResetComponent target="mybox" className="ComboBoxComp" waitEvent="updateComplete" waitTarget="mybox"/>
</setup>
<body>
<SetProperty target="mybox.myCB" propertyName="editable" value="true" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="editable" value="true"/>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="2" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<CompareBitmap target="mybox" url="../Properties/Baselines/cb_properties_editable_spark.png" />
</body>
</TestCase>
<TestCase testID="Spark_combobase_properties_value" keywords="[comboBase, properties, value]">
<setup>
<ResetComponent target="mybox" className="ComboBoxComp" waitEvent="updateComplete" waitTarget="mybox"/>
</setup>
<body>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="2" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="value" value="null"/>
<RunCode code=" application.mybox.myCB.dataProvider = arr1"/>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="1" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="value" value="21"/>
<RunCode code=" application.mybox.myCB.dataProvider = arr2"/>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="4" waitEvent="updateComplete" waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB" propertyName ="value" value="Rick"/>
</body>
</TestCase>
<TestCase testID="Spark_combobase_properties_selectedItem" keywords="[comboBase, properties, selectedItem]">
<setup>
<ResetComponent target="mybox" className="ComboBoxComp" waitEvent="updateComplete" waitTarget="mybox"/>
</setup>
<body>
<SetProperty target="mybox.myCB" propertyName="selectedIndex" value="2" waitEvent="updateComplete"
waitTarget="mybox.myCB"/>
<AssertPropertyValue target="mybox.myCB.selectedItem" propertyName ="age" value="4"/>
<AssertPropertyValue target="mybox.myCB.selectedItem" propertyName ="slno" value="3"/>
<AssertPropertyValue target="mybox.myCB.selectedItem" propertyName ="name" value="Jerry"/>
</body>
</TestCase>
</testCases>
</UnitTester>