| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.payments; |
| 6 |
| 7 import android.content.DialogInterface; |
| 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 |
| 10 import org.chromium.chrome.R; |
| 11 import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| 12 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 13 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| 14 |
| 15 import java.util.concurrent.ExecutionException; |
| 16 import java.util.concurrent.TimeoutException; |
| 17 |
| 18 /** |
| 19 * A payment integration test for a merchant that requests phone number. |
| 20 */ |
| 21 public class PaymentRequestPhoneTest extends PaymentRequestTestBase { |
| 22 public PaymentRequestPhoneTest() { |
| 23 super("payment_request_phone_test.html"); |
| 24 } |
| 25 |
| 26 @Override |
| 27 public void onMainActivityStarted() |
| 28 throws InterruptedException, ExecutionException, TimeoutException { |
| 29 AutofillTestHelper helper = new AutofillTestHelper(); |
| 30 helper.setProfile(new AutofillProfile("", "https://example.com", true, "
Jon Doe", "Google", |
| 31 "340 Main St", "CA", "Los Angeles", "", "90291", "", "US", "555-
555-5555", |
| 32 "jon.doe@google.com", "en-US")); |
| 33 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru
e, "Jon Doe", |
| 34 "4111111111111111", "1111", "12", "2050", "visa", R.drawable.pr_
visa)); |
| 35 } |
| 36 |
| 37 @MediumTest |
| 38 public void testPay() throws InterruptedException, ExecutionException, Timeo
utException { |
| 39 triggerUIAndWait(mReadyToPay); |
| 40 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 41 typeInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", |
| 42 mReadyForUnmaskInput.getTarget(), mReadyToUnmask); |
| 43 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, |
| 44 mReadyToUnmask.getTarget(), mDismissed); |
| 45 expectResultContains(new String[] {"555-555-5555"}); |
| 46 } |
| 47 |
| 48 @MediumTest |
| 49 public void testAddInvalidPhoneAndCancel() |
| 50 throws InterruptedException, ExecutionException, TimeoutException { |
| 51 triggerUIAndWait(mReadyToPay); |
| 52 clickAndWait(CONSTRAINT_CONTACT_DETAILS, R.id.payments_section, mReadyFo
rInput); |
| 53 clickAndWait(CONSTRAINT_CONTACT_DETAILS, R.id.payments_add_option_button
, mReadyToEdit); |
| 54 typeInEditDialog(R.id.payments_edit_phone_input, "+++"); |
| 55 clickAndWait( |
| 56 CONSTRAINT_EDIT_DIALOG, R.id.payments_edit_done_button, mEditorV
alidationError); |
| 57 clickAndWait(CONSTRAINT_EDIT_DIALOG, R.id.payments_edit_cancel_button, m
EditorDismissed); |
| 58 clickAndWait(R.id.close_button, mDismissed); |
| 59 expectResultContains(new String[] {"Request cancelled"}); |
| 60 } |
| 61 |
| 62 @MediumTest |
| 63 public void testAddPhoneAndPay() |
| 64 throws InterruptedException, ExecutionException, TimeoutException { |
| 65 triggerUIAndWait(mReadyToPay); |
| 66 clickAndWait(CONSTRAINT_CONTACT_DETAILS, R.id.payments_section, mReadyFo
rInput); |
| 67 clickAndWait(CONSTRAINT_CONTACT_DETAILS, R.id.payments_add_option_button
, mReadyToEdit); |
| 68 typeInEditDialog(R.id.payments_edit_phone_input, "999-999-9999"); |
| 69 clickAndWait(CONSTRAINT_EDIT_DIALOG, R.id.payments_edit_done_button, mRe
adyToPay); |
| 70 clickAndWait(R.id.button_primary, mReadyForUnmaskInput); |
| 71 typeInCardUnmaskDialogAndWait( |
| 72 R.id.card_unmask_input, "123", mReadyForUnmaskInput.getTarget(),
mReadyToUnmask); |
| 73 clickCardUnmaskButtonAndWait( |
| 74 DialogInterface.BUTTON_POSITIVE, mReadyToUnmask.getTarget(), mDi
smissed); |
| 75 expectResultContains(new String[] {"999-999-9999"}); |
| 76 } |
| 77 } |
| OLD | NEW |