Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndPhoneTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndPhoneTest.java |
similarity index 57% |
copy from chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailTest.java |
copy to chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndPhoneTest.java |
index 9b5e47b251c6bd2df5292e3715f7549991f6c9dc..a96781f49261c7586d853be3a369070b1d53b3e3 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestEmailAndPhoneTest.java |
@@ -19,12 +19,12 @@ import java.util.concurrent.ExecutionException; |
import java.util.concurrent.TimeoutException; |
/** |
- * A payment integration test for a merchant that requests email address. |
+ * A payment integration test for a merchant that requests email address and a phone number. |
*/ |
-public class PaymentRequestEmailTest extends PaymentRequestTestBase { |
- public PaymentRequestEmailTest() { |
- // This merchant request an email address. |
- super("payment_request_email_test.html"); |
+public class PaymentRequestEmailAndPhoneTest extends PaymentRequestTestBase { |
+ public PaymentRequestEmailAndPhoneTest() { |
+ // This merchant request an email address and a phone number. |
+ super("payment_request_email_and_phone_test.html"); |
} |
@Override |
@@ -38,9 +38,29 @@ public class PaymentRequestEmailTest extends PaymentRequestTestBase { |
helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe", |
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_visa, |
billingAddressId, "" /* serverId */)); |
+ |
+ // Add the same profile but with a different address. |
+ helper.setProfile(new AutofillProfile("", "https://example.com", true, "", "Google", |
+ "999 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-555-5555", |
+ "jon.doe@google.com", "en-US")); |
+ |
+ // Add the same profile but without a phone number. |
+ helper.setProfile(new AutofillProfile("", "https://example.com", true, "Jon Doe", "Google", |
+ "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "", "jon.doe@google.com", |
please use gerrit instead
2016/12/16 20:34:51
Ditto
sebsg
2016/12/19 20:56:30
Done.
|
+ "en-US")); |
+ |
+ // Add the same profile but without an email. |
+ helper.setProfile(new AutofillProfile("", "https://example.com", true, "Jon Doe", "Google", |
+ "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-555-5555", "", |
please use gerrit instead
2016/12/16 20:34:51
Ditto
sebsg
2016/12/19 20:56:30
Done.
|
+ "en-US")); |
+ |
+ // Add the same profile but without a name. |
+ helper.setProfile(new AutofillProfile("", "https://example.com", true, "", "Google", |
please use gerrit instead
2016/12/16 20:34:51
Ditto
sebsg
2016/12/19 20:56:30
Done.
|
+ "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-555-5555", |
+ "jon.doe@google.com", "en-US")); |
} |
- /** Provide the existing valid email address to the merchant. */ |
+ /** Provide the existing valid email address and phone number to the merchant. */ |
@MediumTest |
@Feature({"Payments"}) |
public void testPay() throws InterruptedException, ExecutionException, TimeoutException { |
@@ -48,10 +68,10 @@ public class PaymentRequestEmailTest extends PaymentRequestTestBase { |
clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyToUnmask); |
clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed); |
- expectResultContains(new String[] {"jon.doe@google.com"}); |
+ expectResultContains(new String[] {"555-555-5555", "jon.doe@google.com"}); |
} |
- /** Attempt to add an invalid email address and cancel the transaction. */ |
+ /** Attempt to add an invalid email address and phone number and cancel the transaction. */ |
@MediumTest |
@FlakyTest(message = "crbug.com/673371") |
@Feature({"Payments"}) |
@@ -60,27 +80,41 @@ public class PaymentRequestEmailTest extends PaymentRequestTestBase { |
triggerUIAndWait(mReadyToPay); |
clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit); |
- setTextInEditorAndWait(new String[] {"jane.jones"}, mEditorTextUpdate); |
+ setTextInEditorAndWait(new String[] {"-1-", "jane.jones"}, mEditorTextUpdate); |
clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationError); |
clickInEditorAndWait(R.id.payments_edit_cancel_button, mReadyToPay); |
clickAndWait(R.id.close_button, mDismissed); |
expectResultContains(new String[] {"Request cancelled"}); |
} |
- /** Add a new email address and provide that to the merchant. */ |
+ /** Add a new email address and phone number and provide that to the merchant. */ |
@MediumTest |
@Feature({"Payments"}) |
- public void testAddEmailAndPay() |
+ public void testAddEmailAndPhoneAndPay() |
throws InterruptedException, ExecutionException, TimeoutException { |
triggerUIAndWait(mReadyToPay); |
clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit); |
- setTextInEditorAndWait(new String[] {"jane.jones@google.com"}, mEditorTextUpdate); |
+ setTextInEditorAndWait( |
+ new String[] {"555-555-5555", "jane.jones@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); |
- expectResultContains(new String[] {"jane.jones@google.com"}); |
+ expectResultContains(new String[] {"555-555-5555", "jane.jones@google.com"}); |
+ } |
+ |
+ /** |
+ * Makes sure that suggestions that are equal to or subsets of other suggestions are not shown |
+ * to the user. |
+ */ |
+ @MediumTest |
+ @Feature({"Payments"}) |
+ public void testSuggestionsDeduped() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
+ triggerUIAndWait(mReadyToPay); |
+ clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
+ assertEquals(1, getNumberOfContactDetailSuggestions()); |
} |
/** |
@@ -89,14 +123,17 @@ public class PaymentRequestEmailTest extends PaymentRequestTestBase { |
*/ |
@MediumTest |
@Feature({"Payments"}) |
- public void testRequestedInformationMetric() throws InterruptedException, ExecutionException, |
- TimeoutException { |
+ public void testRequestedInformationMetric() |
+ throws InterruptedException, ExecutionException, TimeoutException { |
// Start the Payment Request. |
triggerUIAndWait(mReadyToPay); |
// Make sure that only the appropriate enum value was logged. |
for (int i = 0; i < PaymentRequestMetrics.REQUESTED_INFORMATION_MAX; ++i) { |
- assertEquals((i == PaymentRequestMetrics.REQUESTED_INFORMATION_EMAIL ? 1 : 0), |
+ assertEquals((i == (PaymentRequestMetrics.REQUESTED_INFORMATION_EMAIL |
please use gerrit instead
2016/12/16 20:34:51
Nit: Could not hurt to break this 6 line statement
sebsg
2016/12/19 20:56:30
Done.
|
+ | PaymentRequestMetrics.REQUESTED_INFORMATION_PHONE) |
+ ? 1 |
+ : 0), |
RecordHistogram.getHistogramValueCountForTesting( |
"PaymentRequest.RequestedInformation", i)); |
} |