Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestIncompleteContactDetailsTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestIncompleteContactDetailsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestIncompleteContactDetailsTest.java |
index 1766dc51dc4125dccb986f7b8d74f05d20098a95..bad5a2a5de9dd0630f733bd59f70f623bd72613f 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestIncompleteContactDetailsTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestIncompleteContactDetailsTest.java |
@@ -4,15 +4,13 @@ |
package org.chromium.chrome.browser.payments; |
-import android.content.DialogInterface; |
import android.test.suitebuilder.annotation.MediumTest; |
import org.chromium.base.test.util.Feature; |
-import org.chromium.base.test.util.FlakyTest; |
import org.chromium.chrome.R; |
import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
-import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
+import org.chromium.chrome.browser.payments.ui.PaymentRequestSection; |
import java.util.concurrent.ExecutionException; |
import java.util.concurrent.TimeoutException; |
@@ -23,7 +21,8 @@ import java.util.concurrent.TimeoutException; |
*/ |
public class PaymentRequestIncompleteContactDetailsTest extends PaymentRequestTestBase { |
public PaymentRequestIncompleteContactDetailsTest() { |
- // This merchant requests both a phone number and an email address. |
+ // This merchant requests both a phone number and an email address. We set the user's email |
+ // address as invalid, so all tests start in "ready for input" state. |
super("payment_request_contact_details_test.html"); |
} |
@@ -32,26 +31,57 @@ public class PaymentRequestIncompleteContactDetailsTest extends PaymentRequestTe |
throws InterruptedException, ExecutionException, TimeoutException { |
AutofillTestHelper helper = new AutofillTestHelper(); |
// The user has an invalid email address on disk. |
- String billingAddressId = helper.setProfile(new AutofillProfile("", "https://example.com", |
- true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "", |
- "US", "333-333-3333", "jon.doe" /* invalid email address */, "en-US")); |
- helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe", |
- "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa, |
- billingAddressId, "" /* serverId */)); |
+ helper.setProfile(new AutofillProfile("", "https://example.com", true, "Jon Doe", "Google", |
+ "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "333-333-3333", |
+ "jon.doe" /* invalid email address */, "en-US")); |
+ |
+ installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE); |
} |
/** Attempt to update the contact information with invalid data and cancel the transaction. */ |
@MediumTest |
- @FlakyTest(message = "crbug.com/673371") |
@Feature({"Payments"}) |
public void testEditIncompleteContactAndCancel() |
throws InterruptedException, ExecutionException, TimeoutException { |
+ // Not ready to pay since Contact email is invalid. |
triggerUIAndWait(mReadyForInput); |
+ // Check that there is a selected payment method (makes sure we are not ready to pay because |
+ // of the Contact Details). |
+ expectPaymentMethodRowIsSelected(0); |
+ // Updating contact with an invalid value and cancelling means we're still not |
+ // ready to pay (the value is still the original value). |
clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
clickInContactInfoAndWait(R.id.payments_first_radio_button, mReadyToEdit); |
setTextInEditorAndWait(new String[] {"", "---", "jane.jones"}, mEditorTextUpdate); |
clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationError); |
- clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToPay); |
+ // The section collapses and the [SELECT] button is active. |
+ clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); |
+ assertEquals(PaymentRequestSection.EDIT_BUTTON_SELECT, getContactDetailsButtonState()); |
+ |
+ clickAndWait(R.id.close_button, mDismissed); |
+ expectResultContains(new String[] {"Request cancelled"}); |
+ } |
+ |
+ /** Attempt to add invalid contact info alongside the already invalid info, and cancel. */ |
+ @MediumTest |
+ @Feature({"Payments"}) |
+ public void testAddIncompleteContactAndCancel() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ // Not ready to pay since Contact email is invalid. |
+ triggerUIAndWait(mReadyForInput); |
+ // Check that there is a selected payment method (makes sure we are not ready to pay because |
+ // of the Contact Details). |
+ expectPaymentMethodRowIsSelected(0); |
+ // Adding contact with an invalid value and cancelling means we're still not |
+ // ready to pay (the value is still the original value). |
+ clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
+ clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit); |
+ setTextInEditorAndWait(new String[] {"", "---", "jane.jones"}, mEditorTextUpdate); |
+ clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationError); |
+ // The section collapses and the [SELECT] button is active. |
+ clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyForInput); |
+ assertEquals(PaymentRequestSection.EDIT_BUTTON_SELECT, getContactDetailsButtonState()); |
+ |
clickAndWait(R.id.close_button, mDismissed); |
expectResultContains(new String[] {"Request cancelled"}); |
} |
@@ -67,9 +97,7 @@ public class PaymentRequestIncompleteContactDetailsTest extends PaymentRequestTe |
setTextInEditorAndWait(new String[] {"Jon Doe", "555-555-5555", "jon.doe@google.com"}, |
mEditorTextUpdate); |
clickInEditorAndWait(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); |
+ clickAndWait(R.id.button_primary, mDismissed); |
expectResultContains(new String[] {"Jon Doe", "555-555-5555", "jon.doe@google.com"}); |
} |
} |