Commit 2f32a659 authored by sebsg's avatar sebsg Committed by Commit bot

[Payments] Move focus to next field in expired cvc unmask prompt.

Moves the focus to the expiration year field when the expiration month
field gets filled with a second character and move the focus to the
cvc input field when the expiration year field gets filled with a
second character.

Also adds more detailed error messages for invalid expiration month and
year.

BUG=671762

Review-Url: https://codereview.chromium.org/2557873002
Cr-Commit-Position: refs/heads/master@{#437571}
parent 7fa1b1d3
...@@ -91,7 +91,7 @@ public class PaymentRequestExpiredLocalCardTest extends PaymentRequestTestBase { ...@@ -91,7 +91,7 @@ public class PaymentRequestExpiredLocalCardTest extends PaymentRequestTestBase {
public void testCannotAddExpiredCard() public void testCannotAddExpiredCard()
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
// If the current date is in January skip this test. It is not possible to select an expired // If the current date is in January skip this test. It is not possible to select an expired
// data in the card editor in January. // date in the card editor in January.
Calendar now = Calendar.getInstance(); Calendar now = Calendar.getInstance();
if (now.get(Calendar.MONTH) == 0) return; if (now.get(Calendar.MONTH) == 0) return;
...@@ -130,25 +130,34 @@ public class PaymentRequestExpiredLocalCardTest extends PaymentRequestTestBase { ...@@ -130,25 +130,34 @@ public class PaymentRequestExpiredLocalCardTest extends PaymentRequestTestBase {
new String[] {"10", "26", "123"}, mUnmaskValidationDone); new String[] {"10", "26", "123"}, mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals("")); assertTrue(getUnmaskPromptErrorMessage().equals(""));
// Set an invalid expiration date. // Set an invalid expiration month.
setTextInExpiredCardUnmaskDialogAndWait( setTextInExpiredCardUnmaskDialogAndWait(
new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input}, new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input},
new String[] {"10", "14", "123"}, mUnmaskValidationDone); new String[] {"99", "25", "123"}, mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals( assertTrue(getUnmaskPromptErrorMessage().equals(
"Check your expiration date and try again")); "Check your expiration month and try again"));
// Set an invalid CVC and expiration date. // Set an invalid expiration year.
setTextInExpiredCardUnmaskDialogAndWait( setTextInExpiredCardUnmaskDialogAndWait(
new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input}, new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input},
new String[] {"10", "14", "12312"}, mUnmaskValidationDone); new String[] {"10", "14", "123"}, mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals( assertTrue(getUnmaskPromptErrorMessage().equals(
"Check your expiration date and CVC and try again")); "Check your expiration year and try again"));
// Set an invalid CVC. // If the current date is in January skip this test. It is not possible to select an expired
setTextInExpiredCardUnmaskDialogAndWait( // date in January.
new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input}, Calendar now = Calendar.getInstance();
new String[] {"10", "26", "12312"}, mUnmaskValidationDone); if (now.get(Calendar.MONTH) != 0) {
assertTrue(getUnmaskPromptErrorMessage().equals("Check your CVC and try again")); String twoDigitsYear = Integer.toString(now.get(Calendar.YEAR)).substring(2);
// Set an invalid expiration year.
setTextInExpiredCardUnmaskDialogAndWait(
new int[] {R.id.expiration_month, R.id.expiration_year, R.id.card_unmask_input},
new String[] {Integer.toString(now.get(Calendar.MONTH) - 1), twoDigitsYear,
"123"}, mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals(
"Check your expiration date and try again"));
}
// Set valid arguments again. // Set valid arguments again.
setTextInExpiredCardUnmaskDialogAndWait( setTextInExpiredCardUnmaskDialogAndWait(
......
...@@ -218,28 +218,4 @@ public class PaymentRequestFreeShippingTest extends PaymentRequestTestBase { ...@@ -218,28 +218,4 @@ public class PaymentRequestFreeShippingTest extends PaymentRequestTestBase {
"PaymentRequest.RequestedInformation", i)); "PaymentRequest.RequestedInformation", i));
} }
} }
/**
* Tests the different card unmask error messages for a non expired card.
*/
@MediumTest
@Feature({"Payments"})
public void testPromptErrorMessages()
throws InterruptedException, ExecutionException, TimeoutException {
// Click pay to get to the card unmask prompt.
triggerUIAndWait(mReadyToPay);
clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
// Set valid arguments.
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals(""));
// Set an invalid CVC.
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123123", mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals("Check your CVC and try again"));
// Set valid arguments again.
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mUnmaskValidationDone);
assertTrue(getUnmaskPromptErrorMessage().equals(""));
}
} }
...@@ -233,12 +233,18 @@ ...@@ -233,12 +233,18 @@
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_CVC" desc="Error message that encourages the user to try to re-enter their credit card CVC after a previous failed attempt." formatter_data="android_java"> <message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_CVC" desc="Error message that encourages the user to try to re-enter their credit card CVC after a previous failed attempt." formatter_data="android_java">
Check your CVC and try again Check your CVC and try again
</message> </message>
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_EXPIRATION" desc="Error message that encourages the user to try to re-enter their credit card expiration date after a previous failed attempt." formatter_data="android_java"> <message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_EXPIRATION_DATE" desc="Error message that encourages the user to try to re-enter their credit card expiration date after a previous failed attempt." formatter_data="android_java">
Check your expiration date and try again Check your expiration date and try again
</message> </message>
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_CVC_AND_EXPIRATION" desc="Error message that encourages the user to try to re-enter their credit card expiration date and CVC after a previous failed attempt." formatter_data="android_java"> <message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_CVC_AND_EXPIRATION" desc="Error message that encourages the user to try to re-enter their credit card expiration date and CVC after a previous failed attempt." formatter_data="android_java">
Check your expiration date and CVC and try again Check your expiration date and CVC and try again
</message> </message>
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_EXPIRATION_MONTH" desc="Error message that encourages the user to try to re-enter their credit card expiration month after a previous failed attempt." formatter_data="android_java">
Check your expiration month and try again
</message>
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_TRY_AGAIN_EXPIRATION_YEAR" desc="Error message that encourages the user to try to re-enter their credit card expiration year after a previous failed attempt." formatter_data="android_java">
Check your expiration year and try again
</message>
<if expr="_google_chrome"> <if expr="_google_chrome">
<message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_PERMANENT" desc="Error message to show when a credit card cannot be verified and the user isn't allowed to retry."> <message name="IDS_AUTOFILL_CARD_UNMASK_PROMPT_ERROR_PERMANENT" desc="Error message to show when a credit card cannot be verified and the user isn't allowed to retry.">
Chrome was unable to confirm your card at this time. Please try again later. Chrome was unable to confirm your card at this time. Please try again later.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment