Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestNoShippingTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestNoShippingTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestNoShippingTest.java |
index c7646003006daccc1c99ffdab0bf385bd5ce9a8e..e5413d27d1e315d5dd150d2ee1824205b5527bd6 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestNoShippingTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestNoShippingTest.java |
@@ -35,6 +35,7 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
billingAddressId)); |
} |
+ /** Click [X] to cancel payment. */ |
@MediumTest |
public void testCloseDialog() throws InterruptedException, ExecutionException, |
TimeoutException { |
@@ -43,6 +44,7 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
expectResultContains(new String[] {"Request cancelled"}); |
} |
+ /** Click [EDIT] to expand the dialog, then click [X] to cancel payment. */ |
@MediumTest |
public void testEditAndCloseDialog() throws InterruptedException, ExecutionException, |
TimeoutException { |
@@ -52,6 +54,7 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
expectResultContains(new String[] {"Request cancelled"}); |
} |
+ /** Click [EDIT] to expand the dialog, then click [CANCEL] to cancel payment. */ |
@MediumTest |
public void testEditAndCancelDialog() throws InterruptedException, ExecutionException, |
TimeoutException { |
@@ -61,6 +64,7 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
expectResultContains(new String[] {"Request cancelled"}); |
} |
+ /** Click [PAY] and dismiss the card unmask dialog. */ |
@MediumTest |
public void testPayAndCancelDialog() throws InterruptedException, ExecutionException, |
TimeoutException { |
@@ -71,6 +75,7 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
expectResultContains(new String[] {"Request cancelled"}); |
} |
+ /** Click [PAY], type in "123" into the CVC dialog, then submit the payment. */ |
@MediumTest |
public void testPay() throws InterruptedException, ExecutionException, TimeoutException { |
triggerUIAndWait(mReadyToPay); |
@@ -80,4 +85,103 @@ public class PaymentRequestNoShippingTest extends PaymentRequestTestBase { |
expectResultContains(new String[] {"Jon Doe", "4111111111111111", "12", "2050", "visa", |
"123"}); |
} |
+ |
+ /** Attempt to add an invalid credit card and cancel payment. */ |
+ @MediumTest |
+ public void testAddInvalidCardAndCancel() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ triggerUIAndWait(mReadyToPay); |
+ clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
+ clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdit); |
+ setTextInCardEditorAndWait(new String[] {"123", "Bob"}, mEditorTextUpdate); |
+ clickInCardEditorAndWait(R.id.payments_edit_done_button, mEditorValidationError); |
+ clickInCardEditorAndWait(R.id.payments_edit_cancel_button, mEditorDismissed); |
+ clickAndWait(R.id.close_button, mDismissed); |
+ expectResultContains(new String[] {"Request cancelled"}); |
+ } |
+ |
+ /** Use a temporary credit card to complete payment. */ |
+ @MediumTest |
+ public void testAddTemporaryCardAndPay() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ triggerUIAndWait(mReadyToPay); |
+ clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
+ clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdit); |
+ setTextInCardEditorAndWait(new String[] {"5454545454545454", "Bob"}, mEditorTextUpdate); |
+ |
+ // Select December of next year for expiration and a complete billing address. |
+ int december = 11; |
+ int nextYear = 1; |
+ int firstCompleteBillingAddress = 1; |
+ setSpinnerSelectionsInCardEditorAndWait( |
+ new int[] {december, nextYear, firstCompleteBillingAddress}, |
+ mProcessBillingAddressChange); |
+ |
+ // Do not check the "Save this card on this device" checkbox, so the card is temporary. |
+ |
+ clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
+ clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
+ setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask); |
+ clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed); |
+ expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); |
+ } |
+ |
+ /** Save a new card on disk and pay. */ |
+ @MediumTest |
+ public void testSaveNewCardAndPay() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ triggerUIAndWait(mReadyToPay); |
+ clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
+ clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdit); |
+ setTextInCardEditorAndWait(new String[] {"5454545454545454", "Bob"}, mEditorTextUpdate); |
+ |
+ // Select December of next year for expiration and a complete billing address. |
+ int december = 11; |
+ int nextYear = 1; |
+ int firstCompleteBillingAddress = 1; |
+ setSpinnerSelectionsInCardEditorAndWait( |
+ new int[] {december, nextYear, firstCompleteBillingAddress}, |
+ mProcessBillingAddressChange); |
+ |
+ // Check the "Save this card on this device" checkbox, so the card is saved on disk. |
+ selectCheckboxAndWait(R.id.payments_edit_checkbox, true, mReadyToEdit); |
+ |
+ clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
+ clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
+ setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask); |
+ clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed); |
+ expectResultContains(new String[] {"5454545454545454", "12", "Bob"}); |
+ } |
+ |
+ /** Add a new card together with a new billing address and pay. */ |
+ @MediumTest |
+ public void testSaveNewCardAndNewBillingAddressAndPay() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ triggerUIAndWait(mReadyToPay); |
+ clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput); |
+ clickInPaymentMethodAndWait(R.id.payments_add_option_button, mReadyToEdit); |
+ setTextInCardEditorAndWait(new String[] {"5454545454545454", "Bob"}, mEditorTextUpdate); |
+ |
+ // Select December of next year for expiration and [Add address] in the billing address |
+ // dropdown. |
+ int december = 11; |
+ int nextYear = 1; |
+ int addBillingAddress = 2; |
+ setSpinnerSelectionsInCardEditorAndWait(new int[] {december, nextYear, addBillingAddress}, |
+ mReadyToEdit); |
+ |
+ setTextInEditorAndWait(new String[] {"Bob", "Google", "1600 Amphitheatre Pkwy", |
+ "Mountain View", "CA", "94043", "999-999-9999"}, mEditorTextUpdate); |
+ clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToEdit); |
+ |
+ // Check the "Save this card on this device" checkbox, so the card is saved on disk. |
+ selectCheckboxAndWait(R.id.payments_edit_checkbox, true, mReadyToEdit); |
+ |
+ clickInCardEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
+ clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
+ setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask); |
+ clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed); |
+ expectResultContains(new String[] {"5454545454545454", "12", "Bob", "Google", |
+ "1600 Amphitheatre Pkwy", "Mountain View", "CA", "94043", "999-999-9999"}); |
+ } |
} |