blob: 0054b34b8e4a2e6f9788f9e718e7bb0fcb7acfd4 [file] [log] [blame]
// Copyright 2017 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 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.CardType;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/**
* A payment integration test for a merchant that requires shipping address, but always rejects all
* shipping addresses via updateWith({}), which is an "empty update."
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class PaymentRequestEmptyUpdateTest implements MainActivityStartCallback {
@Rule
public PaymentRequestTestRule mPaymentRequestTestRule =
new PaymentRequestTestRule("payment_request_empty_update_test.html", this);
@Override
public void onMainActivityStarted()
throws InterruptedException, ExecutionException, TimeoutException {
AutofillTestHelper helper = new AutofillTestHelper();
// The user has a shipping address on disk.
String billingAddressId = helper.setProfile(new AutofillProfile("", "https://example.com",
true, "Jon Doe", "Google", "340 Main St", "CA", "Los Angeles", "", "90291", "",
"US", "650-253-0000", "", "en-US"));
helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.visa_card,
CardType.UNKNOWN, billingAddressId, "" /* serverId */));
}
/** Expand the shipping address section and select a valid address. */
@Test
@MediumTest
@Feature({"Payments"})
public void testSelectValidAddress() throws Throwable {
mPaymentRequestTestRule.triggerUIAndWait(mPaymentRequestTestRule.getReadyForInput());
mPaymentRequestTestRule.clickInShippingAddressAndWait(
R.id.payments_section, mPaymentRequestTestRule.getReadyForInput());
mPaymentRequestTestRule.clickInShippingAddressAndWait(
R.id.payments_first_radio_button, mPaymentRequestTestRule.getDismissed());
mPaymentRequestTestRule.expectResultContains(new String[] {"Total required"});
}
}