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

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

Issue 2885443003: enable modifiers for native apps (Closed)
Patch Set: more beautify Created 3 years, 7 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 static junit.framework.Assert.assertEquals;
8 import static junit.framework.Assert.assertFalse;
9 import static junit.framework.Assert.assertTrue;
gogerald1 2017/05/18 21:57:33 nit: you may consider use "import junit.framework.
wuandy1 2017/05/19 01:59:57 I personally like to keep the code shorter and add
10
11 import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.DELAYE D_RESPONSE;
12 import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.HAVE_I NSTRUMENTS;
13 import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.IMMEDI ATE_RESPONSE;
14
15 import android.support.test.filters.MediumTest;
16
17 import org.junit.Rule;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20
21 import org.chromium.base.test.util.CommandLineFlags;
22 import org.chromium.base.test.util.Feature;
23 import org.chromium.chrome.R;
24 import org.chromium.chrome.browser.ChromeSwitches;
25 import org.chromium.chrome.browser.autofill.AutofillTestHelper;
26 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
27 import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
28 import org.chromium.chrome.test.ChromeActivityTestRule;
29 import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
30
31 import java.util.concurrent.ExecutionException;
32 import java.util.concurrent.TimeoutException;
33
34 /**
35 * A payment integration test for a merchant that requests payment via Bob Pay o r cards with
gogerald1 2017/05/18 21:57:33 basic-card
wuandy1 2017/05/19 01:59:57 Done.
36 * modifiers.
37 */
38 @RunWith(ChromeJUnit4ClassRunner.class)
39 @CommandLineFlags.Add({
40 ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
41 ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
42 })
43 public class PaymentRequestPaymentAppAndCardsWithModifiersTest {
gogerald1 2017/05/18 21:57:33 You may want to rename it to "PaymentRequestPaymen
wuandy1 2017/05/19 01:59:57 Done.
44 @Rule
45 public PaymentRequestTestRule mPaymentRequestTestRule = new PaymentRequestTe stRule(
46 "payment_request_bobpay_and_cards_with_modifiers_test.html",
47 new PaymentRequestTestRule.MainActivityStartCallback() {
gogerald1 2017/05/18 21:57:33 you can implement MainActivityStartCallback in Pay
wuandy1 2017/05/19 01:59:57 Done.
48 @Override
49 public void onMainActivityStarted()
50 throws InterruptedException, ExecutionException, Timeout Exception {
51 AutofillTestHelper helper = new AutofillTestHelper();
52 String billingAddressId = helper.setProfile(
53 new AutofillProfile("", "https://example.com", true, "Jon Doe",
54 "Google", "340 Main St", "CA", "Los Angeles" , "", "90291", "",
55 "US", "310-310-6000", "jon.doe@gmail.com", " en-US"));
56 // Mastercard card without a billing address.
57 helper.setCreditCard(new CreditCard("", "https://example.com ", true, true,
58 "Jon Doe", "5454545454545454", "", "12", "2050", "ma stercard",
59 R.drawable.pr_mc, "" /* billingAddressId */, "" /* s erverId */));
60 // Visa card with complete set of information.
61 helper.setCreditCard(new CreditCard("", "https://example.com ", true, true,
62 "Jon Doe", "4111111111111111", "", "12", "2050", "vi sa",
63 R.drawable.pr_visa, billingAddressId, "" /* serverId */));
64 }
65 });
66
67 /**
68 * If Bob Pay has instruments, verify modifier for bobpay is applied when it is selected,
69 * and modifier is not applied when other methods are selected.
70 */
71 @Test
72 @MediumTest
73 @Feature({"Payments"})
74 public void testUpdateTotalAndInstrumentLabelWithModifiers()
75 throws InterruptedException, ExecutionException, TimeoutException {
76 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RE SPONSE);
77 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay());
78
79 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith(
80 "https://bobpay.com"));
81 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() );
82
83 // select other payment method and verify modifier for bobpay is not app lied
84 mPaymentRequestTestRule.clickOnPaymentMethodSuggestionOptionAndWait(
85 2, mPaymentRequestTestRule.getReadyForInput());
86 assertFalse(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel(). startsWith(
87 "https://bobpay.com"));
88 assertEquals("USD $5.00", mPaymentRequestTestRule.getOrderSummaryTotal() );
89 }
90
91 /**
92 * Verify native app can pay as expected when modifier is applied.
93 */
94 @Test
95 @MediumTest
96 @Feature({"Payments"})
97 public void testPaymentAppCanPayWithModifiers()
gogerald1 2017/05/18 21:57:33 please help remove this test file PaymentRequestMo
wuandy1 2017/05/19 01:59:57 My repository does not have this file while code s
98 throws InterruptedException, ExecutionException, TimeoutException {
99 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESP ONSE);
100 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay());
101
102 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith(
103 "https://bobpay.com"));
104 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() );
105
106 mPaymentRequestTestRule.clickAndWait(
107 R.id.button_primary, mPaymentRequestTestRule.getDismissed());
108
109 mPaymentRequestTestRule.expectResultContains(
110 new String[] {"https://bobpay.com", "\"transaction\"", "1337"});
111 }
112
113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698