Commit 1ea1bcb3 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

Revert "[Reland][ExpandablePaymentHandler] Test UI appearance and user interaction"

This reverts commit 098a1118.

Reason for revert: This reland CL is still flaky[1].

[1] https://test-results.appspot.com/dashboards/flakiness_dashboard.html#testType=chrome_public_test_apk%20(with%20patch)&tests=org.chromium.chrome.browser.payments.ExpandablePaymentHandlerTest

Original change's description:
> [Reland][ExpandablePaymentHandler] Test UI appearance and user interaction
>
> original CL: crrev.com/c/2227512
> revert CL: crrev.com/c/2231122
> revert reason:
> showPaymentHandlerUi was flaky. It's very likely because the animation
> took so long to finish that that it hits the timeout. Many screenshots
> prove that because the payment sheet still had a thin scrim on it.
>
> change:
> Compared to the original CL, the new one removes the animation.
>
> Bug: 1042892, 1084705, 1084707, 1084708, 1084711, 1084721, 1068741
> Change-Id: Ib3401e3e422e37a733f85eb56e6d08598d3ade1f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2232679
> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
> Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#775685}

TBR=rouslan@chromium.org,maxlg@chromium.org

Change-Id: I59ddce5a193b105e8d2e9f99a3891efbf6a0f178
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1042892, 1084705, 1084707, 1084708, 1084711, 1084721, 1068741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233682
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775762}
parent 2a8eb85c
......@@ -328,7 +328,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderTest.java",
"javatests/src/org/chromium/chrome/browser/payments/CurrencyFormatterTest.java",
"javatests/src/org/chromium/chrome/browser/payments/ExpandablePaymentHandlerChangePaymentMethodTest.java",
"javatests/src/org/chromium/chrome/browser/payments/ExpandablePaymentHandlerCoordinatorTest.java",
"javatests/src/org/chromium/chrome/browser/payments/ExpandablePaymentHandlerTest.java",
"javatests/src/org/chromium/chrome/browser/payments/IsReadyToPayServiceHelperTest.java",
"javatests/src/org/chromium/chrome/browser/payments/MockPackageManagerDelegate.java",
......
// Copyright 2020 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.SmallTest;
import org.junit.Before;
import org.junit.ClassRule;
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.browser.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator.PaymentHandlerUiObserver;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.ui.test.util.DisableAnimationsTestRule;
import org.chromium.url.GURL;
/**
* An integration test for {@link PaymentHandlerCoordinator}.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ExpandablePaymentHandlerCoordinatorTest {
// Disable animations to reduce flakiness.
@ClassRule
public static DisableAnimationsTestRule sNoAnimationsRule = new DisableAnimationsTestRule();
@Rule
public ChromeActivityTestRule<ChromeActivity> mRule =
new ChromeActivityTestRule<>(ChromeActivity.class);
private boolean mUiShown = false;
@Before
public void setUp() {
mRule.startMainActivityOnBlankPage();
}
@Test
@SmallTest
@Feature({"Payments"})
public void testShow() throws Throwable {
PaymentHandlerCoordinator paymentHandler = new PaymentHandlerCoordinator();
PaymentHandlerUiObserver uiObserver = new PaymentHandlerUiObserver() {
@Override
public void onPaymentHandlerUiClosed() {}
@Override
public void onPaymentHandlerUiShown() {
mUiShown = true;
}
};
mRule.runOnUiThread(
()
-> paymentHandler.show(mRule.getActivity(),
new GURL("https://maxpay.com/pay"), /*isIncognito=*/false,
/*webContentsObserver=*/(webContents) -> {}, uiObserver));
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
return mUiShown;
}
});
mRule.runOnUiThread(() -> paymentHandler.hide());
}
}
\ No newline at end of file
package org.chromium.chrome.browser.payments;
// Copyright 2020 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 android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import android.support.test.filters.MediumTest;
import static org.hamcrest.Matchers.startsWith;
import android.os.RemoteException;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
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.browser.ChromeActivity;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator.PaymentHandlerUiObserver;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.components.payments.PaymentFeatureList;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.net.test.EmbeddedTestServer;
import org.chromium.net.test.ServerCertificate;
import org.chromium.ui.test.util.DisableAnimationsTestRule;
import java.util.concurrent.TimeoutException;
import org.chromium.url.GURL;
/**
* A test for the Expandable PaymentHandler {@link PaymentHandlerCoordinator}.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"enable-features=" + PaymentFeatureList.SCROLL_TO_EXPAND_PAYMENT_HANDLER})
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ExpandablePaymentHandlerTest {
private static final long MAX_WAIT_DURATION_MS = 3000L;
// Disable animations to reduce flakiness.
@ClassRule
public static DisableAnimationsTestRule sNoAnimationsRule = new DisableAnimationsTestRule();
// Open a tab on the blank page first to initiate the native bindings required by the test
// server.
@Rule
public PaymentRequestTestRule mRule = new PaymentRequestTestRule("about:blank");
// Host the tests on https://127.0.0.1, because file:// URLs cannot have service workers.
private EmbeddedTestServer mServer;
public ChromeActivityTestRule<ChromeActivity> mRule =
new ChromeActivityTestRule<>(ChromeActivity.class);
private UiDevice mDevice;
private boolean mUiShown = false;
@Before
public void setUp() throws Throwable {
mServer = EmbeddedTestServer.createAndStartHTTPSServer(
InstrumentationRegistry.getContext(), ServerCertificate.CERT_OK);
mRule.startMainActivityWithURL(
mServer.getURL("/components/test/data/payments/maxpay.com/merchant.html"));
// Find the web contents where JavaScript will be executed and instrument the browser
// payment sheet.
mRule.openPage();
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
}
private UiObject showPaymentHandlerUi() throws TimeoutException {
mRule.clickNode("launch");
UiObject bottomSheet = mDevice.findObject(
new UiSelector().description("Payment handler sheet. Swipe down to close."));
Assert.assertTrue(bottomSheet.waitForExists(MAX_WAIT_DURATION_MS));
return bottomSheet;
}
private UiObject waitForTitleExists() {
UiObject title = mDevice.findObject(new UiSelector().text("Max Pay"));
Assert.assertTrue(title.waitForExists(MAX_WAIT_DURATION_MS));
return title;
}
private void clickCloseButton() {
onView(withId(org.chromium.chrome.R.id.close)).perform(click());
}
@Test
@SmallTest
@Feature({"Payments"})
public void testCloseButtonCloseUi() throws TimeoutException {
UiObject bottomSheet = showPaymentHandlerUi();
Assert.assertTrue(bottomSheet.exists());
clickCloseButton();
Assert.assertFalse(bottomSheet.exists());
}
@Test
@SmallTest
@Feature({"Payments"})
public void testSwipeDownCloseUi() throws TimeoutException, UiObjectNotFoundException {
UiObject bottomSheet = showPaymentHandlerUi();
UiObject title = waitForTitleExists();
Assert.assertTrue(bottomSheet.exists());
title.swipeDown(/*steps=*/10);
Assert.assertFalse(bottomSheet.exists());
public void setUp() {
mRule.startMainActivityOnBlankPage();
}
@Test
@SmallTest
@MediumTest
@Feature({"Payments"})
public void testPressSystemBackAtFirstPageNotCloseUi() throws TimeoutException {
UiObject bottomSheet = showPaymentHandlerUi();
waitForTitleExists();
Assert.assertTrue(bottomSheet.exists());
Assert.assertFalse(mDevice.pressBack());
mDevice.waitForIdle();
Assert.assertTrue(bottomSheet.exists());
clickCloseButton();
}
@Test
@SmallTest
@Feature({"Payments"})
public void testOrientationChange() throws TimeoutException, RemoteException {
UiObject bottomSheet = showPaymentHandlerUi();
waitForTitleExists();
Assert.assertTrue(bottomSheet.exists());
mDevice.setOrientationLeft();
mDevice.waitForIdle();
Assert.assertTrue(bottomSheet.exists());
clickCloseButton();
}
@Test
@SmallTest
@Feature({"Payments"})
public void testWebContentsExist() throws TimeoutException {
showPaymentHandlerUi();
CriteriaHelper.pollUiThread(
() -> PaymentRequestImpl.getPaymentHandlerWebContentsForTest() != null);
clickCloseButton();
CriteriaHelper.pollUiThread(
() -> PaymentRequestImpl.getPaymentHandlerWebContentsForTest() == null);
}
@Test
@SmallTest
@Feature({"Payments"})
public void testUiElementsExist() throws TimeoutException {
showPaymentHandlerUi();
waitForTitleExists();
Assert.assertNotNull(PaymentRequestImpl.getPaymentHandlerWebContentsForTest());
onView(withId(org.chromium.chrome.R.id.title))
.check(matches(isDisplayed()))
.check(matches(withText("Max Pay")));
onView(withId(org.chromium.chrome.R.id.bottom_sheet))
.check(matches(isDisplayed()))
.check(matches(
withContentDescription("Payment handler sheet. Swipe down to close.")));
onView(withId(org.chromium.chrome.R.id.close))
.check(matches(isDisplayed()))
.check(matches(withContentDescription("Close")));
onView(withId(org.chromium.chrome.R.id.security_icon))
.check(matches(isDisplayed()))
.check(matches(withContentDescription("Connection is secure. Site information")));
// Not verifying the port number because it's indefinite in tests.
onView(withId(org.chromium.chrome.R.id.origin))
.check(matches(isDisplayed()))
.check(matches(withText(startsWith("127.0.0.1:"))));
clickCloseButton();
}
@Test
@SmallTest
@Feature({"Payments"})
public void testPageInfoButtonClickable() throws TimeoutException {
UiObject bottomSheet = showPaymentHandlerUi();
waitForTitleExists();
onView(withId(org.chromium.chrome.R.id.security_icon)).perform(click());
String paymentAppUrl = mServer.getURL(
"/components/test/data/payments/maxpay.com/payment_handler_window.html");
onView(withId(org.chromium.chrome.R.id.page_info_url))
.check(matches(isDisplayed()))
.check(matches(withText(paymentAppUrl)));
Assert.assertFalse(bottomSheet.exists());
mDevice.pressBack();
Assert.assertTrue(bottomSheet.waitForExists(MAX_WAIT_DURATION_MS));
clickCloseButton();
public void testShow() throws Throwable {
PaymentHandlerCoordinator paymentHandler = new PaymentHandlerCoordinator();
PaymentHandlerUiObserver uiObserver = new PaymentHandlerUiObserver() {
@Override
public void onPaymentHandlerUiClosed() {}
@Override
public void onPaymentHandlerUiShown() {
mUiShown = true;
}
};
mRule.runOnUiThread(
()
-> paymentHandler.show(mRule.getActivity(),
new GURL("https://maxpay.com/pay"), /*isIncognito=*/false,
/*webContentsObserver=*/(webContents) -> {}, uiObserver));
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
return mUiShown;
}
});
mRule.runOnUiThread(() -> paymentHandler.hide());
}
}
{
"name": "Max Pay",
"icons": [{
"src": "../icon.png",
"sizes": "40x40",
"type": "image/png"
}],
"serviceworker": {
"src": "payment_handler_sw.js"
}
}
......@@ -4,8 +4,7 @@
* found in the LICENSE file.
*/
const methodName = window.location.origin +
'/components/test/data/payments/maxpay.com/payment_method.json';
const methodName = window.location.origin + '/pay';
const swSrcUrl = './payment_handler_sw.js';
let resultPromise;
......
......@@ -47,9 +47,9 @@ found in the LICENSE file.
</script>
<h1>Use Max Pay</h1>
<div id="controllers">
<button id="install" onclick="onInstallClicked()">Install</button>
<button id="uninstall" onclick="onUninstallClicked()">Uninstall</button>
<button id="launch" onclick="onLaunchClicked()">Launch</button>
<button onclick="onInstallClicked()">Install</button>
<button onclick="onUninstallClicked()">Uninstall</button>
<button onclick="onLaunchClicked()">Launch</button>
<button onclick="onLaunchClicked('http://info.cern.ch')">Launch http app</button>
</div>
<div>
......
......@@ -4,13 +4,9 @@ Copyright 2020 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.
-->
<head>
<meta charset="utf-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<title>Max Pay</title>
</head>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<body>
<button onclick="confirm()">confirm</button>
<button onclick="cancel()">cancel</button>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment