| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.content.DialogInterface; | 7 import android.content.DialogInterface; |
| 8 import android.test.suitebuilder.annotation.MediumTest; | 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
| 11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; | 11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; | 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 14 | 14 |
| 15 import java.util.concurrent.ExecutionException; | 15 import java.util.concurrent.ExecutionException; |
| 16 import java.util.concurrent.TimeoutException; | 16 import java.util.concurrent.TimeoutException; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * A payment integration test for a merchant that requests contact details. | 19 * A payment integration test for a merchant that requests contact details. |
| 20 */ | 20 */ |
| 21 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase { | 21 public class PaymentRequestContactDetailsTest extends PaymentRequestTestBase { |
| 22 public PaymentRequestContactDetailsTest() { | 22 public PaymentRequestContactDetailsTest() { |
| 23 // The merchant requests both a phone number and an email address. |
| 23 super("payment_request_contact_details_test.html"); | 24 super("payment_request_contact_details_test.html"); |
| 24 } | 25 } |
| 25 | 26 |
| 26 @Override | 27 @Override |
| 27 public void onMainActivityStarted() | 28 public void onMainActivityStarted() |
| 28 throws InterruptedException, ExecutionException, TimeoutException { | 29 throws InterruptedException, ExecutionException, TimeoutException { |
| 29 AutofillTestHelper helper = new AutofillTestHelper(); | 30 AutofillTestHelper helper = new AutofillTestHelper(); |
| 31 // The user has valid phone number and email address on disk. |
| 30 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
Jon Doe", "Google", | 32 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
Jon Doe", "Google", |
| 31 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-
555-5555", | 33 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-
555-5555", |
| 32 "jon.doe@google.com", "en-US")); | 34 "jon.doe@google.com", "en-US")); |
| 33 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", | 35 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 34 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa)); | 36 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa)); |
| 35 } | 37 } |
| 36 | 38 |
| 39 /** Provide the existing valid phone number and email address to the merchan
t. */ |
| 37 @MediumTest | 40 @MediumTest |
| 38 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { | 41 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
| 39 triggerUIAndWait(mReadyToPay); | 42 triggerUIAndWait(mReadyToPay); |
| 40 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); | 43 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 41 typeInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", | 44 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 42 mReadyForUnmaskInput.getTarget(), mReadyToUnmask); | 45 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 43 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, | |
| 44 mReadyToUnmask.getTarget(), mDismissed); | |
| 45 expectResultContains(new String[] {"555-555-5555", "jon.doe@google.com"}
); | 46 expectResultContains(new String[] {"555-555-5555", "jon.doe@google.com"}
); |
| 46 } | 47 } |
| 48 |
| 49 /** Attempt to add invalid phone number and email address and cancel the tra
nsaction. */ |
| 50 @MediumTest |
| 51 public void testAddInvalidContactAndCancel() |
| 52 throws InterruptedException, ExecutionException, TimeoutException { |
| 53 triggerUIAndWait(mReadyToPay); |
| 54 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
| 55 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; |
| 56 setTextInEditor(R.id.payments_edit_phone_input, "+++"); |
| 57 setTextInEditor(R.id.payments_edit_email_input, "jane.jones"); |
| 58 clickInEditorAndWait(R.id.payments_edit_done_button, mEditorValidationEr
ror); |
| 59 clickInEditorAndWait(R.id.payments_edit_cancel_button, mEditorDismissed)
; |
| 60 clickAndWait(R.id.close_button, mDismissed); |
| 61 expectResultContains(new String[] {"Request cancelled"}); |
| 62 } |
| 63 |
| 64 /** Add new phone number and email address and provide that to the merchant.
*/ |
| 65 @MediumTest |
| 66 public void testAddContactAndPay() |
| 67 throws InterruptedException, ExecutionException, TimeoutException { |
| 68 triggerUIAndWait(mReadyToPay); |
| 69 clickInContactInfoAndWait(R.id.payments_section, mReadyForInput); |
| 70 clickInContactInfoAndWait(R.id.payments_add_option_button, mReadyToEdit)
; |
| 71 setTextInEditor(R.id.payments_edit_phone_input, "999-999-9999"); |
| 72 setTextInEditor(R.id.payments_edit_email_input, "jane.jones@google.com")
; |
| 73 clickInEditorAndWait(R.id.payments_edit_done_button, mReadyToPay); |
| 74 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 75 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mReadyTo
Unmask); |
| 76 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismissed
); |
| 77 expectResultContains(new String[] {"999-999-9999", "jane.jones@google.co
m"}); |
| 78 } |
| 47 } | 79 } |
| OLD | NEW |