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 = [ ...@@ -328,7 +328,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/payments/AndroidPaymentAppFinderTest.java", "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/CurrencyFormatterTest.java",
"javatests/src/org/chromium/chrome/browser/payments/ExpandablePaymentHandlerChangePaymentMethodTest.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/ExpandablePaymentHandlerTest.java",
"javatests/src/org/chromium/chrome/browser/payments/IsReadyToPayServiceHelperTest.java", "javatests/src/org/chromium/chrome/browser/payments/IsReadyToPayServiceHelperTest.java",
"javatests/src/org/chromium/chrome/browser/payments/MockPackageManagerDelegate.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. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.payments; import android.support.test.filters.MediumTest;
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 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.Before;
import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; 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.flags.ChromeSwitches;
import org.chromium.chrome.browser.payments.handler.PaymentHandlerCoordinator; 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.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.content_public.browser.test.util.CriteriaHelper;
import org.chromium.net.test.EmbeddedTestServer; import org.chromium.url.GURL;
import org.chromium.net.test.ServerCertificate;
import org.chromium.ui.test.util.DisableAnimationsTestRule;
import java.util.concurrent.TimeoutException;
/** /**
* A test for the Expandable PaymentHandler {@link PaymentHandlerCoordinator}. * A test for the Expandable PaymentHandler {@link PaymentHandlerCoordinator}.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
"enable-features=" + PaymentFeatureList.SCROLL_TO_EXPAND_PAYMENT_HANDLER})
public class ExpandablePaymentHandlerTest { 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 @Rule
public PaymentRequestTestRule mRule = new PaymentRequestTestRule("about:blank"); public ChromeActivityTestRule<ChromeActivity> mRule =
new ChromeActivityTestRule<>(ChromeActivity.class);
// Host the tests on https://127.0.0.1, because file:// URLs cannot have service workers.
private EmbeddedTestServer mServer;
private UiDevice mDevice; private boolean mUiShown = false;
@Before @Before
public void setUp() throws Throwable { public void setUp() {
mServer = EmbeddedTestServer.createAndStartHTTPSServer( mRule.startMainActivityOnBlankPage();
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());
} }
@Test @Test
@SmallTest @MediumTest
@Feature({"Payments"}) @Feature({"Payments"})
public void testPressSystemBackAtFirstPageNotCloseUi() throws TimeoutException { public void testShow() throws Throwable {
UiObject bottomSheet = showPaymentHandlerUi(); PaymentHandlerCoordinator paymentHandler = new PaymentHandlerCoordinator();
waitForTitleExists(); PaymentHandlerUiObserver uiObserver = new PaymentHandlerUiObserver() {
@Override
Assert.assertTrue(bottomSheet.exists()); public void onPaymentHandlerUiClosed() {}
Assert.assertFalse(mDevice.pressBack());
mDevice.waitForIdle(); @Override
public void onPaymentHandlerUiShown() {
Assert.assertTrue(bottomSheet.exists()); mUiShown = true;
clickCloseButton(); }
} };
mRule.runOnUiThread(
@Test ()
@SmallTest -> paymentHandler.show(mRule.getActivity(),
@Feature({"Payments"}) new GURL("https://maxpay.com/pay"), /*isIncognito=*/false,
public void testOrientationChange() throws TimeoutException, RemoteException { /*webContentsObserver=*/(webContents) -> {}, uiObserver));
UiObject bottomSheet = showPaymentHandlerUi(); CriteriaHelper.pollInstrumentationThread(new Criteria() {
waitForTitleExists(); @Override
Assert.assertTrue(bottomSheet.exists()); public boolean isSatisfied() {
return mUiShown;
mDevice.setOrientationLeft(); }
mDevice.waitForIdle(); });
Assert.assertTrue(bottomSheet.exists());
mRule.runOnUiThread(() -> paymentHandler.hide());
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();
} }
} }
{
"name": "Max Pay",
"icons": [{
"src": "../icon.png",
"sizes": "40x40",
"type": "image/png"
}],
"serviceworker": {
"src": "payment_handler_sw.js"
}
}
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
* found in the LICENSE file. * found in the LICENSE file.
*/ */
const methodName = window.location.origin + const methodName = window.location.origin + '/pay';
'/components/test/data/payments/maxpay.com/payment_method.json';
const swSrcUrl = './payment_handler_sw.js'; const swSrcUrl = './payment_handler_sw.js';
let resultPromise; let resultPromise;
......
...@@ -47,9 +47,9 @@ found in the LICENSE file. ...@@ -47,9 +47,9 @@ found in the LICENSE file.
</script> </script>
<h1>Use Max Pay</h1> <h1>Use Max Pay</h1>
<div id="controllers"> <div id="controllers">
<button id="install" onclick="onInstallClicked()">Install</button> <button onclick="onInstallClicked()">Install</button>
<button id="uninstall" onclick="onUninstallClicked()">Uninstall</button> <button onclick="onUninstallClicked()">Uninstall</button>
<button id="launch" onclick="onLaunchClicked()">Launch</button> <button onclick="onLaunchClicked()">Launch</button>
<button onclick="onLaunchClicked('http://info.cern.ch')">Launch http app</button> <button onclick="onLaunchClicked('http://info.cern.ch')">Launch http app</button>
</div> </div>
<div> <div>
......
...@@ -4,13 +4,9 @@ Copyright 2020 The Chromium Authors. All rights reserved. ...@@ -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 Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
<head> <meta
<meta charset="utf-8"> name="viewport"
<meta content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<title>Max Pay</title>
</head>
<body> <body>
<button onclick="confirm()">confirm</button> <button onclick="confirm()">confirm</button>
<button onclick="cancel()">cancel</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