Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppAndCardsWithModifiersTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppAndCardsWithModifiersTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppAndCardsWithModifiersTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6b0b9bf1d1f650b63c4532bae9aac4531cc0348 |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/payments/PaymentRequestPaymentAppAndCardsWithModifiersTest.java |
| @@ -0,0 +1,113 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.payments; |
| + |
| +import static junit.framework.Assert.assertEquals; |
| +import static junit.framework.Assert.assertFalse; |
| +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
|
| + |
| +import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.DELAYED_RESPONSE; |
| +import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.HAVE_INSTRUMENTS; |
| +import static org.chromium.chrome.browser.payments.PaymentRequestTestRule.IMMEDIATE_RESPONSE; |
| + |
| +import android.support.test.filters.MediumTest; |
| + |
| +import org.junit.Rule; |
| +import org.junit.Test; |
| +import org.junit.runner.RunWith; |
| + |
| +import org.chromium.base.test.util.CommandLineFlags; |
| +import org.chromium.base.test.util.Feature; |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.ChromeSwitches; |
| +import org.chromium.chrome.browser.autofill.AutofillTestHelper; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard; |
| +import org.chromium.chrome.test.ChromeActivityTestRule; |
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| + |
| +import java.util.concurrent.ExecutionException; |
| +import java.util.concurrent.TimeoutException; |
| + |
| +/** |
| + * A payment integration test for a merchant that requests payment via Bob Pay or cards with |
|
gogerald1
2017/05/18 21:57:33
basic-card
wuandy1
2017/05/19 01:59:57
Done.
|
| + * modifiers. |
| + */ |
| +@RunWith(ChromeJUnit4ClassRunner.class) |
| +@CommandLineFlags.Add({ |
| + ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, |
| +}) |
| +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.
|
| + @Rule |
| + public PaymentRequestTestRule mPaymentRequestTestRule = new PaymentRequestTestRule( |
| + "payment_request_bobpay_and_cards_with_modifiers_test.html", |
| + new PaymentRequestTestRule.MainActivityStartCallback() { |
|
gogerald1
2017/05/18 21:57:33
you can implement MainActivityStartCallback in Pay
wuandy1
2017/05/19 01:59:57
Done.
|
| + @Override |
| + public void onMainActivityStarted() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + AutofillTestHelper helper = new AutofillTestHelper(); |
| + String billingAddressId = helper.setProfile( |
| + new AutofillProfile("", "https://example.com", true, "Jon Doe", |
| + "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "", |
| + "US", "310-310-6000", "jon.doe@gmail.com", "en-US")); |
| + // Mastercard card without a billing address. |
| + helper.setCreditCard(new CreditCard("", "https://example.com", true, true, |
| + "Jon Doe", "5454545454545454", "", "12", "2050", "mastercard", |
| + R.drawable.pr_mc, "" /* billingAddressId */, "" /* serverId */)); |
| + // Visa card with complete set of information. |
| + helper.setCreditCard(new CreditCard("", "https://example.com", true, true, |
| + "Jon Doe", "4111111111111111", "", "12", "2050", "visa", |
| + R.drawable.pr_visa, billingAddressId, "" /* serverId */)); |
| + } |
| + }); |
| + |
| + /** |
| + * If Bob Pay has instruments, verify modifier for bobpay is applied when it is selected, |
| + * and modifier is not applied when other methods are selected. |
| + */ |
| + @Test |
| + @MediumTest |
| + @Feature({"Payments"}) |
| + public void testUpdateTotalAndInstrumentLabelWithModifiers() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, IMMEDIATE_RESPONSE); |
| + mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyToPay()); |
| + |
| + assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().startsWith( |
| + "https://bobpay.com")); |
| + assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal()); |
| + |
| + // select other payment method and verify modifier for bobpay is not applied |
| + mPaymentRequestTestRule.clickOnPaymentMethodSuggestionOptionAndWait( |
| + 2, mPaymentRequestTestRule.getReadyForInput()); |
| + assertFalse(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().startsWith( |
| + "https://bobpay.com")); |
| + assertEquals("USD $5.00", mPaymentRequestTestRule.getOrderSummaryTotal()); |
| + } |
| + |
| + /** |
| + * Verify native app can pay as expected when modifier is applied. |
| + */ |
| + @Test |
| + @MediumTest |
| + @Feature({"Payments"}) |
| + 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
|
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + mPaymentRequestTestRule.installPaymentApp(HAVE_INSTRUMENTS, DELAYED_RESPONSE); |
| + mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyToPay()); |
| + |
| + assertTrue(mPaymentRequestTestRule.getSelectedPaymentInstrumentLabel().startsWith( |
| + "https://bobpay.com")); |
| + assertEquals("USD $4.00", mPaymentRequestTestRule.getOrderSummaryTotal()); |
| + |
| + mPaymentRequestTestRule.clickAndWait( |
| + R.id.button_primary, mPaymentRequestTestRule.getDismissed()); |
| + |
| + mPaymentRequestTestRule.expectResultContains( |
| + new String[] {"https://bobpay.com", "\"transaction\"", "1337"}); |
| + } |
| + |
| +} |