| <?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="Validators/CreditCardValidator/Properties/" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" testSWF="Validators_CreditCard_Basic_spark.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 mx.controls.TextInput; |
| import mx.validators.CreditCardValidator; |
| import mx.validators.CreditCardValidatorCardType; |
| import mx.validators.ValidationResult; |
| import mx.managers.SystemManager; |
| |
| ]]> |
| </mx:Script> |
| |
| <testCases> |
| |
| <TestCase testID="CreditCardValidator_allowedFormatChars_default_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207734009977262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="valid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="invalid" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_allowedFormatChars_percentsign_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.myCCV" propertyName="allowedFormatChars" value="%" /> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207%7340%0997%7262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="valid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="invalid" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_allowedFormatChars_blank_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.myCCV" propertyName="allowedFormatChars" value=" " /> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207 7340 0997 7262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="valid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="invalid" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_allowedFormatChars_abcd_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.myCCV" propertyName="allowedFormatChars" value="abcd" /> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207abcd7340abcd0997abcd7262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="valid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="invalid" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_allowedFormatChars_hiascii_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.myCCV" propertyName="allowedFormatChars" value="?" /> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207?7340?0997?7262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="valid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="invalid" /> |
| </body> |
| </TestCase> |
| |
| <TestCase testID="CreditCardValidator_InvalidCharError_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="CreditCard1" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207734009977262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti1" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/invalidCardType_spark.png" /> |
| |
| </body> |
| </TestCase> |
| |
| <TestCase testID="CreditCardValidator_invalidNumberError_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207?734009977262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti2" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown" waitTarget="myCustomCCV.ti2"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/invalidCardNumber_spark.png" timeout="5000" numColorVariances="4" ignoreMaxColorVariance="true" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_wrongLengthError_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value=" " waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| <SetProperty target="myCustomCCV.myCCV" propertyName="noNumError" value="Please enter the number!"/> |
| |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti2" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown" waitTarget="myCustomCCV.ti2"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/wrongLengthError_spark.png" timeout="5000" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_wrongTypeError_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value=" " waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207734009977262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti1" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown" waitTarget="myCustomCCV.ti1"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/wrongTypeError_spark.png" timeout="5000" /> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_TypeRequired_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti2" propertyName="text" value="4207734009977262" waitEvent="updateComplete" waitTarget="myCustomCCV.ti2"/> |
| |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti1" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown" waitTarget="myCustomCCV.ti1"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/TypeRequired_spark.png" timeout="5000" numColorVariances="10" ignoreMaxColorVariance="true"/> |
| </body> |
| </TestCase> |
| <TestCase testID="CreditCardValidator_NumberRequired_spark" keywords="[allowedFormatChars, CreditCardValidator]"> |
| <setup> |
| |
| <ResetComponent target="myCustomCCV" className="CustomCCV" waitEvent="updateComplete" waitTarget="myCustomCCV"/> |
| <SetProperty target="myCustomCCV.ti1" propertyName="text" value="{CreditCardValidatorCardType.VISA}" waitEvent="updateComplete" waitTarget="myCustomCCV.ti1"/> |
| </setup> |
| <body> |
| <RunCode code="application.myCustomCCV.myCCV.validate(application.myCustomCCV.def)"/> |
| <AssertEvent target="myCustomCCV.myCCV" eventName="invalid" eventClass="mx.events::ValidationResultEvent" /> |
| <AssertNoEvent target="myCustomCCV.myCCV" eventName="valid" /> |
| <Pause timeout="20"/> |
| <DispatchMouseEvent target="myCustomCCV.ti2" type="mouseOver" localX="10" localY="10" waitEvent="toolTipShown" waitTarget="myCustomCCV.ti2"/> |
| <WaitForEffectsToEnd /> |
| <CompareBitmap target="" url="../Properties/baselines/NumberRequired_spark.png" timeout="5000" numColorVariances="10" ignoreMaxColorVariance="true" /> |
| </body> |
| </TestCase> |
| |
| </testCases> |
| </UnitTester> |