OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
please use gerrit instead
2017/05/22 13:17:10
2017
wuandy1
2017/05/23 15:46:58
Done.
| |
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; | |
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 basic-card with | |
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 PaymentRequestPaymentAppAndBasicCardWithModifiersTest | |
44 implements PaymentRequestTestRule.MainActivityStartCallback { | |
45 @Rule | |
46 public PaymentRequestTestRule mPaymentRequestTestRule = new PaymentRequestTe stRule( | |
47 "payment_request_bobpay_and_basic_card_with_modifiers_test.html", th is); | |
48 | |
49 @Override | |
50 public void onMainActivityStarted() | |
51 throws InterruptedException, ExecutionException, TimeoutException { | |
52 AutofillTestHelper helper = new AutofillTestHelper(); | |
53 String billingAddressId = helper.setProfile(new AutofillProfile("", "htt ps://example.com", | |
54 true, "Jon Doe", "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, tru e, "Jon Doe", | |
58 "5454545454545454", "", "12", "2050", "mastercard", R.drawable.p r_mc, | |
59 "" /* billingAddressId */, "" /* serverId */)); | |
60 // Visa card with complete set of information. | |
61 helper.setCreditCard(new CreditCard("", "https://example.com", true, tru e, "Jon Doe", | |
62 "4111111111111111", "", "12", "2050", "visa", R.drawable.pr_visa , billingAddressId, | |
63 "" /* serverId */)); | |
64 } | |
65 | |
66 /** | |
67 * Verify modifier for Bobpay is only applied for Bobpay. | |
68 */ | |
69 @Test | |
70 @MediumTest | |
71 @Feature({"Payments"}) | |
72 public void testUpdateTotalAndInstrumentLabelWithModifiers() | |
73 throws InterruptedException, ExecutionException, TimeoutException { | |
74 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RE SPONSE); | |
75 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay()); | |
76 | |
77 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith( | |
78 "https://bobpay.com")); | |
79 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
80 | |
81 // select other payment method and verify modifier for bobpay is not app lied | |
82 mPaymentRequestTestRule.clickOnPaymentMethodSuggestionOptionAndWait( | |
83 1, mPaymentRequestTestRule.getReadyForInput()); | |
84 assertFalse(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel(). startsWith( | |
85 "https://bobpay.com")); | |
86 assertEquals("USD $5.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
87 } | |
88 | |
89 /** | |
90 * Verify native app can pay as expected when modifier is applied. | |
91 */ | |
92 @Test | |
93 @MediumTest | |
94 @Feature({"Payments"}) | |
95 public void testPaymentAppCanPayWithModifiers() | |
96 throws InterruptedException, ExecutionException, TimeoutException { | |
97 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESP ONSE); | |
98 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay()); | |
99 | |
100 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith( | |
101 "https://bobpay.com")); | |
102 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
103 | |
104 mPaymentRequestTestRule.clickAndWait( | |
105 R.id.button_primary, mPaymentRequestTestRule.getDismissed()); | |
106 | |
107 mPaymentRequestTestRule.expectResultContains( | |
108 new String[] {"https://bobpay.com", "\"transaction\"", "1337"}); | |
109 } | |
110 } | |
OLD | NEW |