Chromium Code Reviews| 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 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 * If Bob Pay has instruments, verify modifier for bobpay is applied when it is selected, | |
|
gogerald1
2017/05/19 19:22:48
Might clear this like "Verify modifier for Bobpay
wuandy1
2017/05/19 20:03:49
Done.
| |
| 68 * and modifier is not applied when other methods are selected. | |
| 69 */ | |
| 70 @Test | |
| 71 @MediumTest | |
| 72 @Feature({"Payments"}) | |
| 73 public void testUpdateTotalAndInstrumentLabelWithModifiers() | |
| 74 throws InterruptedException, ExecutionException, TimeoutException { | |
| 75 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RE SPONSE); | |
| 76 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay()); | |
| 77 | |
| 78 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith( | |
| 79 "https://bobpay.com")); | |
| 80 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
| 81 | |
| 82 // select other payment method and verify modifier for bobpay is not app lied | |
| 83 mPaymentRequestTestRule.clickOnPaymentMethodSuggestionOptionAndWait( | |
| 84 1, mPaymentRequestTestRule.getReadyForInput()); | |
| 85 assertFalse(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel(). startsWith( | |
| 86 "https://bobpay.com")); | |
| 87 assertEquals("USD $5.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
| 88 } | |
| 89 | |
| 90 /** | |
| 91 * Verify native app can pay as expected when modifier is applied. | |
| 92 */ | |
| 93 @Test | |
| 94 @MediumTest | |
| 95 @Feature({"Payments"}) | |
| 96 public void testPaymentAppCanPayWithModifiers() | |
| 97 throws InterruptedException, ExecutionException, TimeoutException { | |
| 98 mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESP ONSE); | |
| 99 mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getRead yToPay()); | |
| 100 | |
| 101 assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().s tartsWith( | |
| 102 "https://bobpay.com")); | |
| 103 assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal() ); | |
| 104 | |
| 105 mPaymentRequestTestRule.clickAndWait( | |
| 106 R.id.button_primary, mPaymentRequestTestRule.getDismissed()); | |
| 107 | |
| 108 mPaymentRequestTestRule.expectResultContains( | |
| 109 new String[] {"https://bobpay.com", "\"transaction\"", "1337"}); | |
| 110 } | |
| 111 } | |
| OLD | NEW |