Skip to content

Commit

Permalink
[basic-card] Make PaymentRequestShowTwiceTest not depend on basic card
Browse files Browse the repository at this point in the history
This test was missed in the earlier test migrations on Android. Fixing
it is straight-forward; instead of opening a basic-card payment method
up, we use two URL methods (to avoid skip-the-sheet).

Bug: 1209835
Change-Id: I2c582cfe80f5270187a9009978d943f0404974de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3794768
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
Auto-Submit: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1030089}
  • Loading branch information
stephenmcgruer authored and Chromium LUCI CQ committed Aug 1, 2022
1 parent 2ee8671 commit b3ee1fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
import org.chromium.chrome.R;
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.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.AppPresence;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.FactorySpeed;
import org.chromium.chrome.browser.payments.PaymentRequestTestRule.MainActivityStartCallback;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.components.payments.NotShownReason;
Expand All @@ -43,9 +44,6 @@ public void onMainActivityStarted() throws TimeoutException {
String billingAddressId = helper.setProfile(new AutofillProfile("", "https://example.com",
true, "" /* honorific prefix */, "Jon Doe", "Google", "340 Main St", "CA",
"Los Angeles", "", "90291", "", "US", "555-555-5555", "", "en-US"));
helper.setCreditCard(new CreditCard("", "https://example.com", true, true, "Jon Doe",
"4111111111111111", "1111", "12", "2050", "visa", R.drawable.visa_card,
billingAddressId, "" /* serverId */));
}

/**
Expand Down Expand Up @@ -75,8 +73,13 @@ private String runJavaScriptWithUserGestureAndWaitForPromise(String promiseCode)
@Test
@MediumTest
@Feature({"Payments"})
@CommandLineFlags.Add({"enable-features=PaymentRequestBasicCard"})
public void testSecondShowRequestCancelled() throws TimeoutException {
// Install two payment apps, so that the PaymentRequest UI is shown rather than skipped.
mPaymentRequestTestRule.addPaymentAppFactory(
"https://bobpay.com", AppPresence.HAVE_APPS, FactorySpeed.FAST_FACTORY);
mPaymentRequestTestRule.addPaymentAppFactory(
"https://alicepay.com", AppPresence.HAVE_APPS, FactorySpeed.FAST_FACTORY);

mPaymentRequestTestRule.openPage();
runJavascriptAndWaitFor("showFirst()", mPaymentRequestTestRule.getReadyToPay());
Assert.assertEquals(
Expand Down
4 changes: 2 additions & 2 deletions components/test/data/payments/show_twice.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
function showFirst() { // eslint-disable-line no-unused-vars
const request1 = new PaymentRequest(
[{supportedMethods: 'basic-card', data: {supportedNetworks: ['visa']}}],
[{supportedMethods: 'https://bobpay.com'}, {supportedMethods: 'https://alicepay.com'}],
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
request1.show();
}
Expand All @@ -20,7 +20,7 @@ function showFirst() { // eslint-disable-line no-unused-vars
*/
async function showSecond() { // eslint-disable-line no-unused-vars
const request2 = new PaymentRequest(
[{supportedMethods: 'basic-card', data: {supportedNetworks: ['visa']}}],
[{supportedMethods: 'https://bobpay.com'}],
{total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
// We already have a PaymentRequest showing, so this should fail.
try {
Expand Down

0 comments on commit b3ee1fc

Please sign in to comment.