You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/04/26 09:32:38 UTC

[1/2] git commit: [flex-sdk] - Added support for single digit dates and months

Updated Branches:
  refs/heads/develop 4388da8f2 -> d7c12ee5a


Added support for single digit dates and months


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/98606965
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/98606965
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/98606965

Branch: refs/heads/develop
Commit: 9860696583d06aa67010d016dbdcca676c20aab2
Parents: 4388da8
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Apr 26 17:30:46 2013 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Apr 26 17:30:46 2013 +1000

----------------------------------------------------------------------
 .../framework/src/mx/validators/DateValidator.as   |  213 ++++++++-------
 1 files changed, 115 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/98606965/frameworks/projects/framework/src/mx/validators/DateValidator.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/validators/DateValidator.as b/frameworks/projects/framework/src/mx/validators/DateValidator.as
index 0e19258..80ac323 100644
--- a/frameworks/projects/framework/src/mx/validators/DateValidator.as
+++ b/frameworks/projects/framework/src/mx/validators/DateValidator.as
@@ -146,10 +146,16 @@ public class DateValidator extends Validator
 		var dateObj:Object = {day:"", month:"", year:""};
 		
 		var dayProp:String = baseField;
-		var yearProp:String = baseField;
 		var monthProp:String = baseField;
+		var yearProp:String = baseField;
+		
+		var dateParts:Array = [];
+		var formatParts:Array = [];
+		
+		var dayPart:String = "";
+		var monthPart:String = "";
+		var yearPart:String = "";
 
-		var advanceValueCounter:Boolean = true;
 		var monthRequired:Boolean = false;
 		var dayRequired:Boolean = false
 		var yearRequired:Boolean = false;
@@ -164,18 +170,48 @@ public class DateValidator extends Validator
 		var i:int;
 		var temp:String;
 		
+		var part:int = -1;
+		var lastFormatChar:String = "";
 		
-		if (allowedFormatChars != null)
-			n = allowedFormatChars.length;
-		
+		n = inputFormat.length;
 		for (i = 0; i < n; i++)
 		{
-			if (DECIMAL_DIGITS.indexOf(allowedFormatChars.charAt(i)) != -1)
+			var formatChar:String = inputFormat.charAt(i);
+			
+			if (lastFormatChar != formatChar)
+			{
+				part++;
+				formatParts[part] = "";
+			}
+			
+			if (formatChar == "D" || formatChar == "d")
+			{
+				dayRequired = true;
+				formatParts[part] += "D"
+			}
+			else if (formatChar == "M" || formatChar == "m")
+			{
+				monthRequired = true;
+				formatParts[part] += "M"
+			}
+			else if (formatChar == "Y" || formatChar == "y")
+			{
+				yearRequired = true;
+				formatParts[part] += "Y"
+			}
+			else if (allowedFormatChars.indexOf(formatChar) == -1)
+			{
+				results.push(new ValidationResult(
+					true, baseField, "invalidChar", 
+					validator.invalidCharError));
+				return results;
+			}
+			else
 			{
-				var message:String = resourceManager.getString(
-					"validators", "invalidFormatChars");
-				throw new Error(message);
+				formatParts[part] = formatChar;
 			}
+			
+			lastFormatChar = formatChar;
 		}
 		
 		if (value is String)
@@ -280,79 +316,95 @@ public class DateValidator extends Validator
 			}
 			else
 			{
-				var len:Number = stringValue.length;
-				if (len < inputFormat.length - 2 || len > inputFormat.length + 2)
-				{
-					results.push(new ValidationResult(
-						true, baseField, "wrongLength",
-						validator.wrongLengthError + " " + inputFormat));
-					return results;
-				}
- 
- 				var j:int = 0;
-				n = inputFormat.length;
+				var lastStringChar:String = "";
+				n = stringValue.length;
+				part = -1;
 				for (i = 0; i < n; i++)
 				{
-					temp = "" + stringValue.substring(j, j + 1);
-					var mask:String = "" + inputFormat.substring(i, i + 1);
+					var stringChar:String = stringValue.charAt(i);
+					var lastIsDigit:Boolean = (DECIMAL_DIGITS.indexOf(lastStringChar) >= 0)
+						&& (lastStringChar != "");
+					var curentIsDigit:Boolean = (DECIMAL_DIGITS.indexOf(stringChar) >= 0);
 					
-					// Check each character to see if it is allowed.
-					if (validInput.indexOf(temp) == -1)
+					if (lastIsDigit != curentIsDigit)
+					{
+						part++;
+						dateParts[part] = stringChar;
+					}
+					else if (validInput.indexOf(stringChar) == -1)
 					{
 						results.push(new ValidationResult(
-							true, baseField, "invalidChar",
+							true, baseField, "invalidChar", 
 							validator.invalidCharError));
 						return results;
 					}
-					if (mask == "m" || mask == "M")
+					else
 					{
-						monthRequired = true;
-						if (isNaN(Number(temp)))
-							advanceValueCounter = false;
-						else
-							dateObj.month += temp;
+						dateParts[part] += stringChar;
 					}
-					else if (mask == "d" || mask == "D")
+
+					lastStringChar = stringChar;
+				}
+				
+				if (formatParts.length != dateParts.length)
+				{
+					results.push(new ValidationResult(
+						true, baseField, "wrongLength", 
+						validator.wrongLengthError + " " + inputFormat));
+					return results;
+				}
+
+				var j:int = 0;
+				n = formatParts.length;
+				for (part = 0; part < n; part++)
+				{
+					var mask:String = formatParts[part].charAt(0);
+
+					if ( mask == "D")
 					{
-						dayRequired = true;
-						if (isNaN(Number(temp)))
-							advanceValueCounter = false;
-						else
-							dateObj.day += temp;
+						dateObj.day = dateParts[part];
+						dayPart = formatParts[part];
 					}
-					else if (mask == "y" || mask == "Y")
+					else if (mask == "M")
 					{
-						yearRequired = true;
-						if (isNaN(Number(temp)))
-						{
-							results.push(new ValidationResult(
-								true, baseField, "wrongLength", 
-								validator.wrongLengthError + " " +
-								inputFormat));
-							return results;
-						}
-						else
-						{
-							dateObj.year += temp;
-						}
+						dateObj.month = dateParts[part];
+						monthPart = formatParts[part];
 					}
-					else if (allowedFormatChars.indexOf(temp) == -1)
+					else if (mask == "Y")
 					{
-						results.push(new ValidationResult(
-							true, baseField, "invalidChar", 
-							validator.invalidCharError));
-						return results;
+						dateObj.year = dateParts[part];
+						yearPart = formatParts[part];
 					}
-					
-					if (advanceValueCounter)
-						j++;
-					advanceValueCounter = true;	
 				}
 				
+				// DD or D format
+				if ((dayRequired && dayPart.length == 2 && dateObj.day.length != 2)
+					|| (dayRequired && dayPart.length == 1 && dateObj.day.length > 2))
+				{
+					results.push(new ValidationResult(
+						true, baseField, "wrongLength", 
+						validator.wrongLengthError + " " + inputFormat));	
+				}
+				// MM or M format
+				if ((monthRequired && monthPart.length == 2 && dateObj.month.length != 2)
+					|| (monthRequired && monthPart.length == 1 && dateObj.month.length > 2))
+				{
+					results.push(new ValidationResult(
+						true, baseField, "wrongLength", 
+						validator.wrongLengthError + " " + inputFormat));	
+				}
+				// YY or YYYY format
+				if ((yearRequired && yearPart.length == 2 && dateObj.year.length != 2)
+					|| (yearRequired && yearPart.length == 4 && dateObj.year.length != 4))
+				{
+					results.push(new ValidationResult(
+						true, baseField, "wrongLength", 
+						validator.wrongLengthError + " " + inputFormat));	
+				}
+						
 				if ((monthRequired && dateObj.month == "") ||
 					(dayRequired && dateObj.day == "") ||
-					(yearRequired && dateObj.year == "") ||
-					(j != len))
+					(yearRequired && dateObj.year == ""))
 				 {
 				 	results.push(new ValidationResult(
 						true, baseField, "wrongLength", 
@@ -363,47 +415,12 @@ public class DateValidator extends Validator
 			}
 		}
 
-		// Now, validate the sub-elements, which may have been set directly.
-		n = dateObj.month.length;
-		for (i = 0; i < n; i++)
-		{
-			temp = "" + dateObj.month.substring(i, i + 1);
-			if (DECIMAL_DIGITS.indexOf(temp) == -1)
-			{
-				results.push(new ValidationResult(
-					true, monthProp, "invalidChar",
-					validator.invalidCharError));
-			}
-		}
-		n = dateObj.day.length;
-		for (i = 0; i < n; i++)
-		{
-			temp = "" + dateObj.day.substring(i, i + 1);
-			if (DECIMAL_DIGITS.indexOf(temp) == -1)
-			{
-				results.push(new ValidationResult(
-					true, dayProp, "invalidChar",
-					validator.invalidCharError));
-			}
-		}
-		n = dateObj.year.length;
-		for (i = 0; i < n; i++)
-		{
-			temp = "" + dateObj.year.substring(i, i + 1);
-			if (DECIMAL_DIGITS.indexOf(temp) == -1)
-			{
-				results.push(new ValidationResult(
-					true, yearProp, "invalidChar",
-					validator.invalidCharError));
-			}
-		}
-
 		if (results.length > 0)
 			return results;
 		
 		var monthNum:Number = Number(dateObj.month);
 		var dayNum:Number = Number(dateObj.day);
-		var yearNum:Number = Number(dateObj.year).valueOf();
+		var yearNum:Number = Number(dateObj.year);
 
 		if (monthNum > 12 || monthNum < 1)
 		{


Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Apr 26, 2013 7:49 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>
> HI,
>
> > Why not add a detailed JIRA ticket for this so that we don't forget
this?
> There's an existing JIRA issue. I will get around to trying to fixing it
in the next week - unless someone else does.
>
> Justin

Just to be clear, I am not complaining about the broken test.  I just want
the to the test runs to finish cleanly.

I have too many things on my plate currently, otherwise I would take a shot
at it.

Thanks,
Om

Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by Justin Mclean <ju...@classsoftware.com>.
HI,

> Why not add a detailed JIRA ticket for this so that we don't forget this?
There's an existing JIRA issue. I will get around to trying to fixing it in the next week - unless someone else does.

Justin

Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Apr 26, 2013 7:06 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>
> Hi,
>
> > I don't like the sound of this.
> So fix them :-)
>

Sure, I would fix it by commenting it out :-)

> > We should either fix them or comment then out.
> The issues I see with commenting them out is that:
> a) they may be forgotten about
> b) unrun test may hide other introduced issues.
> c) It may encourage other people to fix them
>

Why not add a detailed JIRA ticket for this so that we don't forget this?

> Justin
>

Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> I don't like the sound of this.  
So fix them :-)

> We should either fix them or comment then out.  
The issues I see with commenting them out is that:
a) they may be forgotten about
b) unrun test may hide other introduced issues.
c) It may encourage other people to fix them

Justin


Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Apr 26, 2013 6:15 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>
> HI,
>
> > Thanks for grinding through these.  But are you saying if I run these
tests
> > I will get failures.
> 2 tests report bit map failure but the tests themselves pass. Issue is
that only one error is displayed when there could actually be more than one
so in a way the test were wrong but and incorrectly passing.
>
> I see if I can fix but the best solution may be the replace the bitmaps.
>
> Another one of the tests is probably displaying the wrong error message
but treats that as a success (5 digit year test).
>
> > At minimum, disable the tests and remember to come back and look at
them (or
> > file a JIRA to remind us).
> Personally I think it better to least the tests as failures so we know
there a (minor) issue there.

I don't like the sound of this.  We should either fix them or comment then
out.  We don't want to start collecting a list of failures as we go.

Thanks,
Om

Thanks,
Om

>
> Thanks,
> Justin

Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by Justin Mclean <ju...@classsoftware.com>.
HI,

> Thanks for grinding through these.  But are you saying if I run these tests
> I will get failures.
2 tests report bit map failure but the tests themselves pass. Issue is that only one error is displayed when there could actually be more than one so in a way the test were wrong but and incorrectly passing.

I see if I can fix but the best solution may be the replace the bitmaps. 

Another one of the tests is probably displaying the wrong error message but treats that as a success (5 digit year test).

> At minimum, disable the tests and remember to come back and look at them (or
> file a JIRA to remind us).
Personally I think it better to least the tests as failures so we know there a (minor) issue there.

Thanks,
Justin

Re: [2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by Alex Harui <ah...@adobe.com>.
Hi Justin,

Thanks for grinding through these.  But are you saying if I run these tests
I will get failures.  If so, were these test failing before your change?  If
you check in with new failures, it just makes more work for everyone else.
At minimum, disable the tests and remember to come back and look at them (or
file a JIRA to remind us).

Thanks,
-Alex

On 4/26/13 12:32 AM, "jmclean@apache.org" <jm...@apache.org> wrote:

> Added single digit day and month tests. Fixed broken tests (state remembers
> date format). Two test currently fail bitmaps as different error is show. Not
> clear what order validation errors should show in.
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/d7c12ee5
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/d7c12ee5
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/d7c12ee5
> 
> Branch: refs/heads/develop
> Commit: d7c12ee5a241db331ef47182339ac3a95dd29cda
> Parents: 9860696
> Author: Justin Mclean <jm...@apache.org>
> Authored: Fri Apr 26 17:32:16 2013 +1000
> Committer: Justin Mclean <jm...@apache.org>
> Committed: Fri Apr 26 17:32:16 2013 +1000
> 
> ----------------------------------------------------------------------
>  .../Properties/Validators_Date_Properties.mxml     |    3 +
>  .../Validators_Date_Properties_spark.mxml          |   86 ++++++++++++++-
>  2 files changed, 86 insertions(+), 3 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7c12ee5/mustella/tests/V
> alidators/DateValidator/Properties/Validators_Date_Properties.mxml
> ----------------------------------------------------------------------
> diff --git 
> a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s.mxml 
> b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s.mxml
> index e00298a..1432fb6 100644
> --- 
> a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s.mxml
> +++ 
> b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s.mxml
> @@ -125,6 +125,7 @@
> <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> 
> <SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="MM-DD-YYYY"/>
> <SetProperty target="myCustomDt.ti1" propertyName="text" value="12-31-2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> <WaitForEffectsToEnd />
> </setup>
> @@ -141,6 +142,7 @@
> 
> <SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
> <SetProperty target="myCustomDt.myDt" propertyName="allowedFormatChars"
> value="#"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="MM#DD#YYYY"/>
> <SetProperty target="myCustomDt.ti1" propertyName="text" value="12#31#2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> <WaitForEffectsToEnd />
> </setup>
> @@ -207,6 +209,7 @@
> 
> <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> <SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="MM/DD/YYYY"/>
> <SetProperty target="myCustomDt.ti1" propertyName="text" value="31$12/2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> <WaitForEffectsToEnd />
> </setup>
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7c12ee5/mustella/tests/V
> alidators/DateValidator/Properties/Validators_Date_Properties_spark.mxml
> ----------------------------------------------------------------------
> diff --git 
> a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s_spark.mxml 
> b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s_spark.mxml
> index 79aec02..997f492 100644
> --- 
> a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s_spark.mxml
> +++ 
> b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Propertie
> s_spark.mxml
> @@ -99,7 +99,22 @@
> <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> 
> </body>  
> -  </TestCase>  
> +  </TestCase> 
> +  <TestCase 
> testID="DateValidator_allowedFormatChars_ForwardSlash_SingleDateAndMonth_spark
> " keywords="[DateSymbol, DateValidator]">
> +   <setup>
> +    <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="property"
> value="text"/>
> +    
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="YYYY/M/D"/>
> +   </setup>
> +   <body>
> +    <SetProperty target="myCustomDt.ti1" propertyName="text"
> value="2006/7/17" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> +    <DispatchKeyEvent keys="[TAB, TAB]" />
> +    <AssertEvent target="myCustomDt.myDt" eventName="valid"
> eventClass="mx.events::ValidationResultEvent" />
> +    <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> +    
> +   </body>  
> +  </TestCase>
> <TestCase testID="DateValidator_allowedFormatChars_BackwardSlash_spark"
> keywords="[DateSymbol, DateValidator]">
> <setup>
> <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> @@ -116,6 +131,22 @@
> 
> </body>  
> </TestCase>
> +  <TestCase 
> testID="DateValidator_allowedFormatChars_SingleDateAndMonth_spark"
> keywords="[DateSymbol, DateValidator]">
> +   <setup>
> +    <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> +    
> +    <SetProperty target="myCustomDt.myDt" propertyName="property"
> value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="D/M/YYYY"/>
> +    
> +   </setup>
> +   <body>
> +    <SetProperty target="myCustomDt.ti1" propertyName="text"
> valueExpression="value='3\\12\\2006'" waitEvent="updateComplete"
> waitTarget="myCustomDt.ti1"/>
> +    <DispatchKeyEvent keys="[TAB, TAB]" />
> +    <AssertEvent target="myCustomDt.myDt" eventName="valid"
> eventClass="mx.events::ValidationResultEvent" />
> +    <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> +    
> +   </body>  
> +  </TestCase>
> <TestCase testID="DateValidator_allowedFormatChars_Hyphen_Invalid_spark"
> keywords="[DateSymbol, DateValidator]">
> <setup>
> 
> @@ -131,6 +162,22 @@
> <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> </body>  
> </TestCase>
> +  <TestCase 
> testID="DateValidator_allowedFormatChars_Hyphen_SingleMonthAndDate_spark"
> keywords="[DateSymbol, DateValidator]">
> +   <setup>
> +    
> +    <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> +    
> +    <SetProperty target="myCustomDt.myDt" propertyName="property"
> value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="m-d-yyyy"/>
> +    <SetProperty target="myCustomDt.ti1" propertyName="text" value="1-1-2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> +    <WaitForEffectsToEnd />
> +   </setup>
> +   <body>
> +    <DispatchKeyEvent keys="[TAB, TAB]" />
> +    <AssertEvent target="myCustomDt.myDt" eventName="valid"
> eventClass="mx.events::ValidationResultEvent" />
> +    <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> +   </body>  
> +  </TestCase>
> <TestCase testID="DateValidator_allowedFormatChars_Hyphen_hash_spark"
> keywords="[DateSymbol, DateValidator]">
> <setup>
> 
> @@ -138,6 +185,7 @@
> 
> <SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
> <SetProperty target="myCustomDt.myDt" propertyName="allowedFormatChars"
> value="#"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="MM#DD#YYYY"/>
> <SetProperty target="myCustomDt.ti1" propertyName="text" value="12#31#2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> <WaitForEffectsToEnd />
> </setup>
> @@ -163,6 +211,22 @@
> <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> </body>  
> </TestCase>
> +  <TestCase testID="DateValidator_inputFormat_d_m_spark"
> keywords="[DateSymbol, DateValidator]">
> +   <setup>
> +    
> +    <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> +    
> +    <SetProperty target="myCustomDt.myDt" propertyName="property"
> value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="d/m"/>
> +    <SetProperty target="myCustomDt.ti1" propertyName="text" value="1/7"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> +    <WaitForEffectsToEnd />
> +   </setup>
> +   <body>
> +    <DispatchKeyEvent keys="[TAB, TAB]" />
> +    <AssertEvent target="myCustomDt.myDt" eventName="valid"
> eventClass="mx.events::ValidationResultEvent" />
> +    <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> +   </body>  
> +  </TestCase>
> <TestCase testID="DateValidator_inputFormat_dd_mm_spark"
> keywords="[DateSymbol, DateValidator]">
> <setup>
> 
> @@ -179,7 +243,22 @@
> <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> </body>  
> </TestCase>
> -
> +  <TestCase testID="DateValidator_inputFormat_d_m_spark"
> keywords="[DateSymbol, DateValidator]">
> +   <setup>
> +    
> +    <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> +    
> +    <SetProperty target="myCustomDt.myDt" propertyName="property"
> value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="D/M"/>
> +    <SetProperty target="myCustomDt.ti1" propertyName="text" value="31/12"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> +    <WaitForEffectsToEnd />
> +   </setup>
> +   <body>
> +    <DispatchKeyEvent keys="[TAB, TAB]" />
> +    <AssertEvent target="myCustomDt.myDt" eventName="valid"
> eventClass="mx.events::ValidationResultEvent" />
> +    <AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
> +   </body>  
> +  </TestCase>
> <TestCase testID="DateValidator_formatError_spark" keywords="[DateSymbol,
> DateValidator]">
> <setup>
> 
> @@ -201,6 +280,7 @@
> 
> <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> <SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
> +    <SetProperty target="myCustomDt.myDt" propertyName="inputFormat"
> value="MM/DD/YYYY"/>
> <SetProperty target="myCustomDt.ti1" propertyName="text" value="31$12/2006"
> waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
> <WaitForEffectsToEnd />
> </setup>
> @@ -263,7 +343,7 @@
> <CompareBitmap target=""
> url="../Properties/baselines/wrongYearError_spark.png" timeout="5000" />    
> </body>  
> </TestCase>
> -  <TestCase testID="DateValidator_dateFormat_spark" keywords="[DateSymbol,
> DateValidator]">
> +  <TestCase testID="DateValidator_dateFormat_YearDateWrongWayAbout_spark"
> keywords="[DateSymbol, DateValidator]">
> <setup>
> 
> <ResetComponent target="myCustomDt" className="CustomDt"
> waitEvent="updateComplete" waitTarget="myCustomDt"/>
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


[2/2] git commit: [flex-sdk] - Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.

Posted by jm...@apache.org.
Added single digit day and month tests. Fixed broken tests (state remembers date format). Two test currently fail bitmaps as different error is show. Not clear what order validation errors should show in.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/d7c12ee5
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/d7c12ee5
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/d7c12ee5

Branch: refs/heads/develop
Commit: d7c12ee5a241db331ef47182339ac3a95dd29cda
Parents: 9860696
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Apr 26 17:32:16 2013 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Apr 26 17:32:16 2013 +1000

----------------------------------------------------------------------
 .../Properties/Validators_Date_Properties.mxml     |    3 +
 .../Validators_Date_Properties_spark.mxml          |   86 ++++++++++++++-
 2 files changed, 86 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7c12ee5/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties.mxml
----------------------------------------------------------------------
diff --git a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties.mxml b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties.mxml
index e00298a..1432fb6 100644
--- a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties.mxml
+++ b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties.mxml
@@ -125,6 +125,7 @@
 				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
 				
 				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="MM-DD-YYYY"/>
 				<SetProperty target="myCustomDt.ti1" propertyName="text" value="12-31-2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
 				<WaitForEffectsToEnd />
 			</setup>
@@ -141,6 +142,7 @@
 				
 				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
 				<SetProperty target="myCustomDt.myDt" propertyName="allowedFormatChars" value="#"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="MM#DD#YYYY"/>
 				<SetProperty target="myCustomDt.ti1" propertyName="text" value="12#31#2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
 				<WaitForEffectsToEnd />
 			</setup>
@@ -207,6 +209,7 @@
 				
 				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
 				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="MM/DD/YYYY"/>
 				<SetProperty target="myCustomDt.ti1" propertyName="text" value="31$12/2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
 				<WaitForEffectsToEnd />
 			</setup>

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/d7c12ee5/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties_spark.mxml
----------------------------------------------------------------------
diff --git a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties_spark.mxml b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties_spark.mxml
index 79aec02..997f492 100644
--- a/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties_spark.mxml
+++ b/mustella/tests/Validators/DateValidator/Properties/Validators_Date_Properties_spark.mxml
@@ -99,7 +99,22 @@
 				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
 				
 			</body>  
-		</TestCase>		
+		</TestCase>	
+		<TestCase testID="DateValidator_allowedFormatChars_ForwardSlash_SingleDateAndMonth_spark" keywords="[DateSymbol, DateValidator]">
+			<setup>
+				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/> 
+				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="YYYY/M/D"/>
+			</setup>
+			<body>
+				<SetProperty target="myCustomDt.ti1" propertyName="text" value="2006/7/17" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
+				<DispatchKeyEvent keys="[TAB, TAB]" />
+				<AssertEvent target="myCustomDt.myDt" eventName="valid" eventClass="mx.events::ValidationResultEvent" />
+				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
+				
+			</body>  
+		</TestCase>
 		<TestCase testID="DateValidator_allowedFormatChars_BackwardSlash_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/> 
@@ -116,6 +131,22 @@
 				
 			</body>  
 		</TestCase>
+		<TestCase testID="DateValidator_allowedFormatChars_SingleDateAndMonth_spark" keywords="[DateSymbol, DateValidator]">
+			<setup>
+				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/> 
+				
+				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="D/M/YYYY"/>
+				
+			</setup>
+			<body>
+				<SetProperty target="myCustomDt.ti1" propertyName="text" valueExpression="value='3\\12\\2006'" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
+				<DispatchKeyEvent keys="[TAB, TAB]" />
+				<AssertEvent target="myCustomDt.myDt" eventName="valid" eventClass="mx.events::ValidationResultEvent" />
+				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
+				
+			</body>  
+		</TestCase>
 		<TestCase testID="DateValidator_allowedFormatChars_Hyphen_Invalid_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				
@@ -131,6 +162,22 @@
 				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
 			</body>  
 		</TestCase>
+		<TestCase testID="DateValidator_allowedFormatChars_Hyphen_SingleMonthAndDate_spark" keywords="[DateSymbol, DateValidator]">
+			<setup>
+				
+				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
+				
+				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="m-d-yyyy"/>
+				<SetProperty target="myCustomDt.ti1" propertyName="text" value="1-1-2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
+				<WaitForEffectsToEnd />
+			</setup>
+			<body>
+				<DispatchKeyEvent keys="[TAB, TAB]" />
+				<AssertEvent target="myCustomDt.myDt" eventName="valid" eventClass="mx.events::ValidationResultEvent" />
+				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
+			</body>  
+		</TestCase>
 		<TestCase testID="DateValidator_allowedFormatChars_Hyphen_hash_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				
@@ -138,6 +185,7 @@
 				
 				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
 				<SetProperty target="myCustomDt.myDt" propertyName="allowedFormatChars" value="#"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="MM#DD#YYYY"/>
 				<SetProperty target="myCustomDt.ti1" propertyName="text" value="12#31#2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
 				<WaitForEffectsToEnd />
 			</setup>
@@ -163,6 +211,22 @@
 				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
 			</body>  
 		</TestCase>
+		<TestCase testID="DateValidator_inputFormat_d_m_spark" keywords="[DateSymbol, DateValidator]">
+			<setup>
+				
+				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
+				
+				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="d/m"/>
+				<SetProperty target="myCustomDt.ti1" propertyName="text" value="1/7" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
+				<WaitForEffectsToEnd />
+			</setup>
+			<body>
+				<DispatchKeyEvent keys="[TAB, TAB]" />
+				<AssertEvent target="myCustomDt.myDt" eventName="valid" eventClass="mx.events::ValidationResultEvent" />
+				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
+			</body>  
+		</TestCase>
 		<TestCase testID="DateValidator_inputFormat_dd_mm_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				
@@ -179,7 +243,22 @@
 				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
 			</body>  
 		</TestCase>
-
+		<TestCase testID="DateValidator_inputFormat_d_m_spark" keywords="[DateSymbol, DateValidator]">
+			<setup>
+				
+				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
+				
+				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="D/M"/>
+				<SetProperty target="myCustomDt.ti1" propertyName="text" value="31/12" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
+				<WaitForEffectsToEnd />
+			</setup>
+			<body>
+				<DispatchKeyEvent keys="[TAB, TAB]" />
+				<AssertEvent target="myCustomDt.myDt" eventName="valid" eventClass="mx.events::ValidationResultEvent" />
+				<AssertNoEvent target="myCustomDt.myDt" eventName="invalid" />
+			</body>  
+		</TestCase>
 		<TestCase testID="DateValidator_formatError_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				
@@ -201,6 +280,7 @@
 				
 				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>
 				<SetProperty target="myCustomDt.myDt" propertyName="property" value="text"/>
+				<SetProperty target="myCustomDt.myDt" propertyName="inputFormat" value="MM/DD/YYYY"/>
 				<SetProperty target="myCustomDt.ti1" propertyName="text" value="31$12/2006" waitEvent="updateComplete" waitTarget="myCustomDt.ti1"/>
 				<WaitForEffectsToEnd />
 			</setup>
@@ -263,7 +343,7 @@
 				<CompareBitmap target="" url="../Properties/baselines/wrongYearError_spark.png" timeout="5000" />				
 			</body>  
 		</TestCase>
-		<TestCase testID="DateValidator_dateFormat_spark" keywords="[DateSymbol, DateValidator]">
+		<TestCase testID="DateValidator_dateFormat_YearDateWrongWayAbout_spark" keywords="[DateSymbol, DateValidator]">
 			<setup>
 				
 				<ResetComponent target="myCustomDt" className="CustomDt"  waitEvent="updateComplete" waitTarget="myCustomDt"/>