Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppAndCardsTest.java

Issue 2179703002: [Merge M-53] Autofill cards at the bottom of the PaymentRequest UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 payment via Bob Pay o r cards.
20 */
21 public class PaymentRequestPaymentAppAndCardsTest extends PaymentRequestTestBase {
22 public PaymentRequestPaymentAppAndCardsTest() {
23 super("payment_request_bobpay_and_cards_test.html");
24 }
25
26 @Override
27 public void onMainActivityStarted() throws InterruptedException, ExecutionEx ception,
28 TimeoutException {
29 AutofillTestHelper helper = new AutofillTestHelper();
30 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt ps://example.com",
31 true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", " ", "90291", "",
32 "US", "310-310-6000", "jon.doe@gmail.com", "en-US"));
33 // Mastercard card without a billing address.
34 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru e, "Jon Doe",
35 "5454545454545454", "", "12", "2050", "mastercard", R.drawable.p r_mc,
36 ""));
37 // Visa card with complete set of information.
38 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru e, "Jon Doe",
39 "4111111111111111", "", "12", "2050", "visa", R.drawable.pr_visa ,
40 billingAddressId));
41 }
42
43 /**
44 * If Bob Pay does not have any instruments, show [visa, mastercard]. Here t he payment app
45 * responds quickly.
46 */
47 @MediumTest
48 public void testNoInstrumentsInFastBobPay() throws InterruptedException, Exe cutionException,
49 TimeoutException {
50 runTest(NO_INSTRUMENTS, IMMEDIATE_RESPONSE);
51 }
52
53 /**
54 * If Bob Pay does not have any instruments, show [visa, mastercard]. Here t he payment app
55 * responds slowly.
56 */
57 @MediumTest
58 public void testNoInstrumentsInSlowBobPay() throws InterruptedException, Exe cutionException,
59 TimeoutException {
60 runTest(NO_INSTRUMENTS, DELAYED_RESPONSE);
61 }
62
63 /**
64 * If Bob Pay has instruments, show [bobpay, visa, mastercard]. Here the pay ment app responds
65 * quickly.
66 */
67 @MediumTest
68 public void testHaveInstrumentsInFastBobPay() throws InterruptedException, E xecutionException,
69 TimeoutException {
70 runTest(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE);
71 }
72
73 /**
74 * If Bob Pay has instruments, show [bobpay, visa, mastercard]. Here the pay ment app responds
75 * slowly.
76 */
77 @MediumTest
78 public void testHaveInstrumentsInSlowBobPay() throws InterruptedException, E xecutionException,
79 TimeoutException {
80 runTest(HAVE_INSTRUMENTS, DELAYED_RESPONSE);
81 }
82
83 private void runTest(int instrumentPresence, int responseSpeed) throws Inter ruptedException,
84 ExecutionException, TimeoutException {
85 installPaymentApp(instrumentPresence, responseSpeed);
86 triggerUIAndWait(mReadyToPay);
87 clickInPaymentMethodAndWait(R.id.payments_section, mReadyForInput);
88
89 // Check the number of instruments.
90 assertEquals(
91 instrumentPresence == HAVE_INSTRUMENTS ? 3 : 2, getNumberOfPayme ntInstruments());
92
93 // Check the labesl of the instruments.
94 int i = 0;
95 if (instrumentPresence == HAVE_INSTRUMENTS) {
96 assertEquals("Bob Pay", getPaymentInstrumentLabel(i++));
97 }
98 // \u00A0\u22EF is a non-breaking space followed by a midline ellipsis.
99 assertEquals("Visa\u00A0\u22EF1111\nJon Doe", getPaymentInstrumentLabel( i++));
100 assertEquals("MasterCard\u00A0\u22EF5454\nJon Doe", getPaymentInstrument Label(i++));
101
102 // Check the output of the selected instrument.
103 if (instrumentPresence == HAVE_INSTRUMENTS) {
104 clickAndWait(R.id.button_primary, mDismissed);
105 expectResultContains(new String[]{"https://bobpay.com", "\"transacti on\"", "1337"});
106 } else {
107 clickAndWait(R.id.button_primary, mReadyForUnmaskInput);
108 setTextInCardUnmaskDialogAndWait(R.id.card_unmask_input, "123", mRea dyToUnmask);
109 clickCardUnmaskButtonAndWait(DialogInterface.BUTTON_POSITIVE, mDismi ssed);
110 expectResultContains(new String[] {"Jon Doe", "4111111111111111", "1 2", "2050", "visa",
111 "123"});
112 }
113 }
114 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698