Android: ExecutionException -> RuntimeException for runOnUiThreadBlocking
This makes the Callable and Runnable overloads behave in the same way. Bug: 353256113 Change-Id: I63a8a84edee0016840add4d13d6136e010a8068d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5707371 Commit-Queue: Andrew Grieve <agrieve@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Owners-Override: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Michael Thiessen <mthiesse@chromium.org> Cr-Commit-Position: refs/heads/main@{#1328354}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
199ae24a95
commit
031d159e55
android_webview/javatests/src/org/chromium/android_webview/test
base/android
chrome
android
features
start_surface
javatests
src
org
chromium
chrome
features
start_surface
javatests
src
org
chromium
chrome
browser
browser
selection
android
java
src
org
chromium
chrome
browser
selection
ui
android
hats
test
java
src
org
chromium
chrome
browser
signin
java
src
org
chromium
chrome
browser
test
android
javatests
src
org
chromium
chrome
content
public
android
javatests
src
org
chromium
content
browser
test
android
javatests
src
org
chromium
content_public
browser
shell
android
javatests
src
org
chromium
@@ -243,8 +243,7 @@ public class AwActivityTestRule extends BaseActivityTestRule<AwTestRunnerActivit
|
|||||||
() -> awContents.getSettings().setJavaScriptEnabled(true));
|
() -> awContents.getSettings().setJavaScriptEnabled(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getJavaScriptEnabledOnUiThread(final AwContents awContents)
|
private static boolean getJavaScriptEnabledOnUiThread(final AwContents awContents) {
|
||||||
throws ExecutionException {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> awContents.getSettings().getJavaScriptEnabled());
|
() -> awContents.getSettings().getJavaScriptEnabled());
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,6 @@ import org.chromium.net.test.util.TestWebServer;
|
|||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
/** Test suite for JavaScript Java interaction. */
|
/** Test suite for JavaScript Java interaction. */
|
||||||
@@ -528,9 +527,9 @@ public class JsJavaInteractionTest extends AwParameterizedTest {
|
|||||||
|
|
||||||
// Pass an URI instead of origin shouldn't work.
|
// Pass an URI instead of origin shouldn't work.
|
||||||
final String jsObjectName5 = JS_OBJECT_NAME + "5";
|
final String jsObjectName5 = JS_OBJECT_NAME + "5";
|
||||||
ExecutionException exception =
|
RuntimeException exception =
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() ->
|
() ->
|
||||||
addWebMessageListenerOnUiThread(
|
addWebMessageListenerOnUiThread(
|
||||||
mAwContents,
|
mAwContents,
|
||||||
@@ -548,9 +547,9 @@ public class JsJavaInteractionTest extends AwParameterizedTest {
|
|||||||
@Feature({"AndroidWebView", "JsJavaInteraction"})
|
@Feature({"AndroidWebView", "JsJavaInteraction"})
|
||||||
public void testDontAllowAddWebMessageLitenerWithTheSameJsObjectName() throws Throwable {
|
public void testDontAllowAddWebMessageLitenerWithTheSameJsObjectName() throws Throwable {
|
||||||
addWebMessageListenerOnUiThread(mAwContents, JS_OBJECT_NAME, new String[] {"*"}, mListener);
|
addWebMessageListenerOnUiThread(mAwContents, JS_OBJECT_NAME, new String[] {"*"}, mListener);
|
||||||
ExecutionException exception =
|
RuntimeException exception =
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() ->
|
() ->
|
||||||
addWebMessageListenerOnUiThread(
|
addWebMessageListenerOnUiThread(
|
||||||
mAwContents,
|
mAwContents,
|
||||||
@@ -1311,9 +1310,9 @@ public class JsJavaInteractionTest extends AwParameterizedTest {
|
|||||||
|
|
||||||
// Wrong origin rule.
|
// Wrong origin rule.
|
||||||
final String testObjectName5 = testObjectName + "5";
|
final String testObjectName5 = testObjectName + "5";
|
||||||
ExecutionException exception =
|
RuntimeException exception =
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() ->
|
() ->
|
||||||
addDocumentStartJavaScriptOnUiThread(
|
addDocumentStartJavaScriptOnUiThread(
|
||||||
mAwContents,
|
mAwContents,
|
||||||
|
@@ -15,7 +15,6 @@ import org.chromium.base.task.TaskTraits;
|
|||||||
import org.chromium.build.BuildConfig;
|
import org.chromium.build.BuildConfig;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
|
|
||||||
/** Helper methods to deal with threading related tasks. */
|
/** Helper methods to deal with threading related tasks. */
|
||||||
@@ -182,32 +181,27 @@ public class ThreadUtils {
|
|||||||
* Run the supplied Callable on the main thread, wrapping any exceptions in a RuntimeException.
|
* Run the supplied Callable on the main thread, wrapping any exceptions in a RuntimeException.
|
||||||
* The method will block until the Callable completes.
|
* The method will block until the Callable completes.
|
||||||
*
|
*
|
||||||
* Note that non-test usage of this function is heavily discouraged. For non-tests, use
|
* <p>Note that non-test usage of this function is heavily discouraged. For non-tests, use
|
||||||
* callbacks rather than blocking threads.
|
* callbacks rather than blocking threads.
|
||||||
*
|
*
|
||||||
* @param c The Callable to run
|
* @param c The Callable to run
|
||||||
* @return The result of the callable
|
* @return The result of the callable
|
||||||
*/
|
*/
|
||||||
public static <T> T runOnUiThreadBlockingNoException(Callable<T> c) {
|
public static <T> T runOnUiThreadBlockingNoException(Callable<T> c) {
|
||||||
try {
|
|
||||||
return runOnUiThreadBlocking(c);
|
return runOnUiThreadBlocking(c);
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw JavaUtils.throwUnchecked(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the supplied Callable on the main thread, The method will block until the Callable
|
* Run the supplied Callable on the main thread, The method will block until the Callable
|
||||||
* completes.
|
* completes.
|
||||||
*
|
*
|
||||||
* Note that non-test usage of this function is heavily discouraged. For non-tests, use
|
* <p>Note that non-test usage of this function is heavily discouraged. For non-tests, use
|
||||||
* callbacks rather than blocking threads.
|
* callbacks rather than blocking threads.
|
||||||
*
|
*
|
||||||
* @param c The Callable to run
|
* @param c The Callable to run
|
||||||
* @return The result of the callable
|
* @return The result of the callable
|
||||||
* @throws ExecutionException c's exception
|
|
||||||
*/
|
*/
|
||||||
public static <T> T runOnUiThreadBlocking(Callable<T> c) throws ExecutionException {
|
public static <T> T runOnUiThreadBlocking(Callable<T> c) {
|
||||||
return PostTask.runSynchronously(TaskTraits.UI_DEFAULT, c);
|
return PostTask.runSynchronously(TaskTraits.UI_DEFAULT, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@ import android.os.Handler;
|
|||||||
import org.jni_zero.CalledByNative;
|
import org.jni_zero.CalledByNative;
|
||||||
import org.jni_zero.JNINamespace;
|
import org.jni_zero.JNINamespace;
|
||||||
|
|
||||||
import org.chromium.base.JavaUtils;
|
|
||||||
import org.chromium.base.Log;
|
import org.chromium.base.Log;
|
||||||
import org.chromium.base.ResettersForTesting;
|
import org.chromium.base.ResettersForTesting;
|
||||||
import org.chromium.base.ThreadUtils;
|
import org.chromium.base.ThreadUtils;
|
||||||
@@ -127,15 +126,15 @@ public class PostTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function executes the task immediately if the current thread is the
|
* This function executes the task immediately if the current thread is the same as the one
|
||||||
* same as the one corresponding to the SingleThreadTaskRunner, otherwise it
|
* corresponding to the SingleThreadTaskRunner, otherwise it posts it and blocks until the task
|
||||||
* posts it and blocks until the task finishes.
|
* finishes.
|
||||||
*
|
*
|
||||||
* Usage outside of testing contexts is discouraged. Prefer callbacks in order
|
* <p>Usage outside of testing contexts is discouraged. Prefer callbacks in order to avoid
|
||||||
* to avoid blocking.
|
* blocking.
|
||||||
*
|
*
|
||||||
* @param taskTraits The TaskTraits that describe the desired TaskRunner.
|
* @param taskTraits The TaskTraits that describe the desired TaskRunner.
|
||||||
* @param task The task to be run with the specified traits.
|
* @param c The task to be run with the specified traits.
|
||||||
* @return The result of the callable
|
* @return The result of the callable
|
||||||
*/
|
*/
|
||||||
public static <T> T runSynchronously(@TaskTraits int taskTraits, Callable<T> c) {
|
public static <T> T runSynchronously(@TaskTraits int taskTraits, Callable<T> c) {
|
||||||
@@ -143,15 +142,15 @@ public class PostTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function executes the task immediately if the current thread is the
|
* This function executes the task immediately if the current thread is the same as the one
|
||||||
* same as the one corresponding to the SingleThreadTaskRunner, otherwise it
|
* corresponding to the SingleThreadTaskRunner, otherwise it posts it and blocks until the task
|
||||||
* posts it and blocks until the task finishes.
|
* finishes.
|
||||||
*
|
*
|
||||||
* Usage outside of testing contexts is discouraged. Prefer callbacks in order
|
* <p>Usage outside of testing contexts is discouraged. Prefer callbacks in order to avoid
|
||||||
* to avoid blocking.
|
* blocking.
|
||||||
*
|
*
|
||||||
* @param taskTraits The TaskTraits that describe the desired TaskRunner.
|
* @param taskTraits The TaskTraits that describe the desired TaskRunner.
|
||||||
* @param task The task to be run with the specified traits.
|
* @param r The task to be run with the specified traits.
|
||||||
*/
|
*/
|
||||||
public static void runSynchronously(@TaskTraits int taskTraits, Runnable r) {
|
public static void runSynchronously(@TaskTraits int taskTraits, Runnable r) {
|
||||||
runSynchronouslyInternal(taskTraits, new FutureTask<Void>(r, null));
|
runSynchronouslyInternal(taskTraits, new FutureTask<Void>(r, null));
|
||||||
@@ -162,7 +161,10 @@ public class PostTask {
|
|||||||
try {
|
try {
|
||||||
return task.get();
|
return task.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw JavaUtils.throwUnchecked(e);
|
// Use a RuntimeException rather than ExecutionException so that callers are not forced
|
||||||
|
// to add try/catch.
|
||||||
|
// Wrap the "caused by" rather than the ExecutionException to avoid excessive wrapping.
|
||||||
|
throw new RuntimeException(e.getCause());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@ import org.chromium.base.task.TaskTraits;
|
|||||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||||
import org.chromium.build.BuildConfig;
|
import org.chromium.build.BuildConfig;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Unit tests for ThreadUtils. */
|
/** Unit tests for ThreadUtils. */
|
||||||
@RunWith(BaseRobolectricTestRunner.class)
|
@RunWith(BaseRobolectricTestRunner.class)
|
||||||
@Config(manifest = Config.NONE)
|
@Config(manifest = Config.NONE)
|
||||||
@@ -33,9 +31,9 @@ public class ThreadUtilsTest {
|
|||||||
ThreadChecker checker = new ThreadChecker();
|
ThreadChecker checker = new ThreadChecker();
|
||||||
checker.assertOnValidThread();
|
checker.assertOnValidThread();
|
||||||
|
|
||||||
ExecutionException e =
|
RuntimeException e =
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() ->
|
() ->
|
||||||
PostTask.runSynchronously(
|
PostTask.runSynchronously(
|
||||||
TaskTraits.USER_BLOCKING, checker::assertOnValidThread));
|
TaskTraits.USER_BLOCKING, checker::assertOnValidThread));
|
||||||
|
@@ -10,7 +10,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
|||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import static org.chromium.chrome.browser.tasks.ReturnToChromeUtil.HOME_SURFACE_SHOWN_AT_STARTUP_UMA;
|
import static org.chromium.chrome.browser.tasks.ReturnToChromeUtil.HOME_SURFACE_SHOWN_AT_STARTUP_UMA;
|
||||||
import static org.chromium.chrome.browser.tasks.ReturnToChromeUtil.HOME_SURFACE_SHOWN_UMA;
|
import static org.chromium.chrome.browser.tasks.ReturnToChromeUtil.HOME_SURFACE_SHOWN_UMA;
|
||||||
@@ -69,7 +68,6 @@ import org.chromium.content_public.browser.test.util.JavaScriptUtils;
|
|||||||
import org.chromium.ui.test.util.UiRestriction;
|
import org.chromium.ui.test.util.UiRestriction;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/** Integration tests of showing a NTP with Start surface UI at startup. */
|
/** Integration tests of showing a NTP with Start surface UI at startup. */
|
||||||
@@ -394,12 +392,8 @@ public class ShowNtpAtStartupTest {
|
|||||||
cta, 2, UrlConstants.NTP_URL, /* expectHomeSurfaceUiShown= */ true);
|
cta, 2, UrlConstants.NTP_URL, /* expectHomeSurfaceUiShown= */ true);
|
||||||
waitForNtpLoaded(cta.getActivityTab());
|
waitForNtpLoaded(cta.getActivityTab());
|
||||||
|
|
||||||
try {
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> cta.findViewById(R.id.single_tab_view).performClick());
|
() -> cta.findViewById(R.id.single_tab_view).performClick());
|
||||||
} catch (ExecutionException e) {
|
|
||||||
Assert.fail("Failed to tap the single tab card " + e.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifies that the last active Tab is showing, and NTP home surface is closed.
|
// Verifies that the last active Tab is showing, and NTP home surface is closed.
|
||||||
verifyTabCountAndActiveTabUrl(cta, 1, TAB_URL, /* expectHomeSurfaceUiShown= */ null);
|
verifyTabCountAndActiveTabUrl(cta, 1, TAB_URL, /* expectHomeSurfaceUiShown= */ null);
|
||||||
@@ -465,12 +459,8 @@ public class ShowNtpAtStartupTest {
|
|||||||
+ "snapshot for the NTP.",
|
+ "snapshot for the NTP.",
|
||||||
ntp.getSnapshotSingleTabCardChangedForTesting());
|
ntp.getSnapshotSingleTabCardChangedForTesting());
|
||||||
|
|
||||||
try {
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> cta.findViewById(R.id.tab_switcher_button).performClick());
|
() -> cta.findViewById(R.id.tab_switcher_button).performClick());
|
||||||
} catch (ExecutionException e) {
|
|
||||||
fail("Failed to tap 'more tabs' " + e.toString());
|
|
||||||
}
|
|
||||||
LayoutTestUtils.waitForLayout(cta.getLayoutManager(), LayoutType.TAB_SWITCHER);
|
LayoutTestUtils.waitForLayout(cta.getLayoutManager(), LayoutType.TAB_SWITCHER);
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> {
|
() -> {
|
||||||
|
@@ -77,7 +77,6 @@ import org.chromium.url.Origin;
|
|||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -788,13 +787,8 @@ public class NavigateTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTabUrlOnUIThread(final Tab tab) {
|
private String getTabUrlOnUIThread(final Tab tab) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> ChromeTabUtils.getUrlStringOnUiThread(tab));
|
() -> ChromeTabUtils.getUrlStringOnUiThread(tab));
|
||||||
} catch (ExecutionException ex) {
|
|
||||||
assert false : "Unexpected ExecutionException";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTabBodyText(Tab tab) {
|
private String getTabBodyText(Tab tab) {
|
||||||
|
6
chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java
6
chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java
@@ -29,8 +29,6 @@ import org.chromium.content_public.browser.test.util.DOMUtils;
|
|||||||
import org.chromium.content_public.browser.test.util.WebContentsUtils;
|
import org.chromium.content_public.browser.test.util.WebContentsUtils;
|
||||||
import org.chromium.ui.base.ViewAndroidDelegate;
|
import org.chromium.ui.base.ViewAndroidDelegate;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Test the select popup and how it interacts with another WebContents. */
|
/** Test the select popup and how it interacts with another WebContents. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
||||||
@@ -54,14 +52,10 @@ public class SelectPopupOtherContentViewTest {
|
|||||||
+ "</body></html>");
|
+ "</body></html>");
|
||||||
|
|
||||||
private boolean isSelectPopupVisibleOnUiThread() {
|
private boolean isSelectPopupVisibleOnUiThread() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() ->
|
() ->
|
||||||
WebContentsUtils.isSelectPopupVisible(
|
WebContentsUtils.isSelectPopupVisible(
|
||||||
mActivityTestRule.getWebContents()));
|
mActivityTestRule.getWebContents()));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -64,8 +64,6 @@ import java.net.URL;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,21 +113,12 @@ public class NotificationPlatformBridgeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double getEngagementScoreBlocking() {
|
private double getEngagementScoreBlocking() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
|
||||||
new Callable<Double>() {
|
|
||||||
@Override
|
|
||||||
public Double call() {
|
|
||||||
// TODO (https://crbug.com/1063807): Add incognito mode tests.
|
// TODO (https://crbug.com/1063807): Add incognito mode tests.
|
||||||
return SiteEngagementService.getForBrowserContext(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
|
() ->
|
||||||
|
SiteEngagementService.getForBrowserContext(
|
||||||
ProfileManager.getLastUsedRegularProfile())
|
ProfileManager.getLastUsedRegularProfile())
|
||||||
.getScore(mPermissionTestRule.getOrigin());
|
.getScore(mPermissionTestRule.getOrigin()));
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (ExecutionException ex) {
|
|
||||||
assert false : "Unexpected ExecutionException";
|
|
||||||
}
|
|
||||||
return 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -58,7 +58,6 @@ import org.chromium.ui.permissions.AndroidPermissionDelegate;
|
|||||||
import org.chromium.ui.test.util.UiRestriction;
|
import org.chromium.ui.test.util.UiRestriction;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Unit tests for {@link LocationBarLayout}. */
|
/** Unit tests for {@link LocationBarLayout}. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@@ -102,12 +101,7 @@ public class LocationBarLayoutTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getUrlText(UrlBar urlBar) {
|
private String getUrlText(UrlBar urlBar) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(() -> urlBar.getText().toString());
|
return ThreadUtils.runOnUiThreadBlocking(() -> urlBar.getText().toString());
|
||||||
} catch (ExecutionException ex) {
|
|
||||||
throw new RuntimeException(
|
|
||||||
"Failed to get the UrlBar's text! Exception below:\n" + ex.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private UrlBar getUrlBar() {
|
private UrlBar getUrlBar() {
|
||||||
@@ -145,7 +139,6 @@ public class LocationBarLayoutTest {
|
|||||||
});
|
});
|
||||||
CriteriaHelper.pollUiThread(() -> urlBar.hasFocus());
|
CriteriaHelper.pollUiThread(() -> urlBar.hasFocus());
|
||||||
|
|
||||||
try {
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<Void>() {
|
new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -154,15 +147,12 @@ public class LocationBarLayoutTest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException("Failed to type \"" + text + "\" into the omnibox!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
|
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
|
||||||
public void testNotShowingVoiceSearchButtonIfUrlBarContainsText() throws ExecutionException {
|
public void testNotShowingVoiceSearchButtonIfUrlBarContainsText() {
|
||||||
// When there is text, the delete button should be visible.
|
// When there is text, the delete button should be visible.
|
||||||
setUrlBarTextAndFocus("testing");
|
setUrlBarTextAndFocus("testing");
|
||||||
|
|
||||||
@@ -173,7 +163,7 @@ public class LocationBarLayoutTest {
|
|||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
|
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
|
||||||
public void testShowingVoiceSearchButtonIfUrlBarIsEmpty() throws ExecutionException {
|
public void testShowingVoiceSearchButtonIfUrlBarIsEmpty() {
|
||||||
// When there's no text, the mic button should be visible.
|
// When there's no text, the mic button should be visible.
|
||||||
setUrlBarTextAndFocus("");
|
setUrlBarTextAndFocus("");
|
||||||
|
|
||||||
@@ -183,7 +173,7 @@ public class LocationBarLayoutTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testDeleteButton() throws ExecutionException {
|
public void testDeleteButton() {
|
||||||
setUrlBarTextAndFocus("testing");
|
setUrlBarTextAndFocus("testing");
|
||||||
CriteriaHelper.pollUiThread(
|
CriteriaHelper.pollUiThread(
|
||||||
() -> {
|
() -> {
|
||||||
|
@@ -36,7 +36,6 @@ import org.chromium.components.search_engines.TemplateUrlService;
|
|||||||
import org.chromium.components.search_engines.TemplateUrlService.LoadListener;
|
import org.chromium.components.search_engines.TemplateUrlService.LoadListener;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Tests for Search Engine Settings. */
|
/** Tests for Search Engine Settings. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@@ -208,8 +207,7 @@ public class SearchEngineSettingsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Preference waitForPreference(
|
private static Preference waitForPreference(
|
||||||
final PreferenceFragmentCompat prefFragment, final String preferenceKey)
|
final PreferenceFragmentCompat prefFragment, final String preferenceKey) {
|
||||||
throws ExecutionException {
|
|
||||||
CriteriaHelper.pollUiThread(
|
CriteriaHelper.pollUiThread(
|
||||||
() -> {
|
() -> {
|
||||||
Criteria.checkThat(
|
Criteria.checkThat(
|
||||||
|
@@ -32,8 +32,6 @@ import org.chromium.chrome.test.batch.BlankCTATabInitialStateRule;
|
|||||||
import org.chromium.chrome.test.util.ChromeTabUtils;
|
import org.chromium.chrome.test.util.ChromeTabUtils;
|
||||||
import org.chromium.net.test.util.TestWebServer;
|
import org.chromium.net.test.util.TestWebServer;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Tests related to the sad tab logic. */
|
/** Tests related to the sad tab logic. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@Batch(Batch.PER_CLASS)
|
@Batch(Batch.PER_CLASS)
|
||||||
@@ -52,11 +50,7 @@ public class SadTabTest {
|
|||||||
|
|
||||||
private static boolean isShowingSadTab(Tab tab) {
|
private static boolean isShowingSadTab(Tab tab) {
|
||||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(() -> SadTab.isShowing(tab));
|
return ThreadUtils.runOnUiThreadBlocking(() -> SadTab.isShowing(tab));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -217,11 +211,7 @@ public class SadTabTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean showSendFeedbackView(final Tab tab) {
|
private static boolean showSendFeedbackView(final Tab tab) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(() -> SadTab.from(tab).showSendFeedbackView());
|
return ThreadUtils.runOnUiThreadBlocking(() -> SadTab.from(tab).showSendFeedbackView());
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return false; // Make tests fail when an exception is thrown.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,11 +222,7 @@ public class SadTabTest {
|
|||||||
*/
|
*/
|
||||||
private static Button getSadTabButton(Tab tab) {
|
private static Button getSadTabButton(Tab tab) {
|
||||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> tab.getView().findViewById(R.id.sad_tab_button));
|
() -> tab.getView().findViewById(R.id.sad_tab_button));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@ import org.chromium.content_public.browser.LoadUrlParams;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Tests for the TabModelSelectorTabObserver. */
|
/** Tests for the TabModelSelectorTabObserver. */
|
||||||
@RunWith(BaseJUnit4ClassRunner.class)
|
@RunWith(BaseJUnit4ClassRunner.class)
|
||||||
@@ -211,11 +210,7 @@ public class TabModelSelectorTabObserverTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void closeTab(TabModel tabModel, Tab tab) {
|
private static void closeTab(TabModel tabModel, Tab tab) {
|
||||||
try {
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(() -> tabModel.closeTab(tab));
|
ThreadUtils.runOnUiThreadBlocking(() -> tabModel.closeTab(tab));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException("Error occurred waiting for runnable", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeTab(TabModel tabModel, Tab tab) {
|
private static void removeTab(TabModel tabModel, Tab tab) {
|
||||||
|
@@ -35,7 +35,6 @@ import org.chromium.content_public.browser.SelectionPopupController;
|
|||||||
import org.chromium.content_public.browser.test.util.DOMUtils;
|
import org.chromium.content_public.browser.test.util.DOMUtils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/** Test that verifies back press will dismiss the selection popup. */
|
/** Test that verifies back press will dismiss the selection popup. */
|
||||||
@@ -74,7 +73,7 @@ public class SelectionPopupBackPressTest {
|
|||||||
@MediumTest
|
@MediumTest
|
||||||
@Feature({"TextInput", "SmartSelection"})
|
@Feature({"TextInput", "SmartSelection"})
|
||||||
@EnableFeatures(ChromeFeatureList.BACK_GESTURE_REFACTOR)
|
@EnableFeatures(ChromeFeatureList.BACK_GESTURE_REFACTOR)
|
||||||
public void testBackPressHandlerOnTabSwitched() throws ExecutionException {
|
public void testBackPressHandlerOnTabSwitched() {
|
||||||
mActivityTestRule.startMainActivityOnBlankPage();
|
mActivityTestRule.startMainActivityOnBlankPage();
|
||||||
final ChromeTabbedActivity activity = mActivityTestRule.getActivity();
|
final ChromeTabbedActivity activity = mActivityTestRule.getActivity();
|
||||||
final BackPressHandler selectionPopupHandler =
|
final BackPressHandler selectionPopupHandler =
|
||||||
@@ -104,7 +103,7 @@ public class SelectionPopupBackPressTest {
|
|||||||
@MediumTest
|
@MediumTest
|
||||||
@Feature({"TextInput", "SmartSelection"})
|
@Feature({"TextInput", "SmartSelection"})
|
||||||
@EnableFeatures(ChromeFeatureList.BACK_GESTURE_REFACTOR)
|
@EnableFeatures(ChromeFeatureList.BACK_GESTURE_REFACTOR)
|
||||||
public void testBackPressHandlerOnWebContentChanged() throws ExecutionException {
|
public void testBackPressHandlerOnWebContentChanged() {
|
||||||
mActivityTestRule.startMainActivityOnBlankPage();
|
mActivityTestRule.startMainActivityOnBlankPage();
|
||||||
final ChromeTabbedActivity activity = mActivityTestRule.getActivity();
|
final ChromeTabbedActivity activity = mActivityTestRule.getActivity();
|
||||||
final SelectionPopupBackPressHandler selectionPopupHandler =
|
final SelectionPopupBackPressHandler selectionPopupHandler =
|
||||||
|
@@ -25,7 +25,6 @@ import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
|
|||||||
import org.chromium.chrome.browser.profiles.Profile;
|
import org.chromium.chrome.browser.profiles.Profile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Util class for survey related testing. */
|
/** Util class for survey related testing. */
|
||||||
public class TestSurveyUtils {
|
public class TestSurveyUtils {
|
||||||
@@ -67,7 +66,7 @@ public class TestSurveyUtils {
|
|||||||
SurveyClientImpl.setForceShowSurveyForTesting(doForce);
|
SurveyClientImpl.setForceShowSurveyForTesting(doForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TestSurveyFactory setUpTestSurveyFactory() throws ExecutionException {
|
static TestSurveyFactory setUpTestSurveyFactory() {
|
||||||
TestSurveyFactory factory = ThreadUtils.runOnUiThreadBlocking(TestSurveyFactory::new);
|
TestSurveyFactory factory = ThreadUtils.runOnUiThreadBlocking(TestSurveyFactory::new);
|
||||||
SurveyClientFactory.setInstanceForTesting(factory);
|
SurveyClientFactory.setInstanceForTesting(factory);
|
||||||
return factory;
|
return factory;
|
||||||
@@ -109,12 +108,8 @@ public class TestSurveyUtils {
|
|||||||
CommandLine.getInstance()
|
CommandLine.getInstance()
|
||||||
.appendSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE);
|
.appendSwitch(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE);
|
||||||
|
|
||||||
try {
|
|
||||||
mTestSurveyFactory = setUpTestSurveyFactory();
|
mTestSurveyFactory = setUpTestSurveyFactory();
|
||||||
base.evaluate();
|
base.evaluate();
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -7,8 +7,6 @@ package org.chromium.chrome.browser.ui.hats;
|
|||||||
import org.jni_zero.CalledByNative;
|
import org.jni_zero.CalledByNative;
|
||||||
import org.jni_zero.JNINamespace;
|
import org.jni_zero.JNINamespace;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class that C++ can setup the survey testing environment. Java tests should instead use the
|
* Helper class that C++ can setup the survey testing environment. Java tests should instead use the
|
||||||
* {@link TestSurveyUtils.TestSurveyComponentRule}.
|
* {@link TestSurveyUtils.TestSurveyComponentRule}.
|
||||||
@@ -16,7 +14,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
@JNINamespace("hats")
|
@JNINamespace("hats")
|
||||||
public class TestSurveyUtilsBridge {
|
public class TestSurveyUtilsBridge {
|
||||||
@CalledByNative
|
@CalledByNative
|
||||||
private static void setupTestSurveyFactory() throws ExecutionException {
|
private static void setupTestSurveyFactory() {
|
||||||
TestSurveyUtils.forceShowSurveyForTesting(true);
|
TestSurveyUtils.forceShowSurveyForTesting(true);
|
||||||
TestSurveyUtils.setUpTestSurveyFactory();
|
TestSurveyUtils.setUpTestSurveyFactory();
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,6 @@ import static androidx.test.espresso.matcher.RootMatchers.isDialog;
|
|||||||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
@@ -22,9 +21,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.MediumTest;
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
|
|
||||||
import org.hamcrest.MatcherAssert;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -67,7 +64,6 @@ import org.chromium.ui.test.util.BlankUiTestActivity;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Instrumentation tests for {@link SignOutDialogCoordinator}. */
|
/** Instrumentation tests for {@link SignOutDialogCoordinator}. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@@ -106,28 +102,6 @@ public class SignOutCoordinatorTest {
|
|||||||
mActivityTestRule.launchActivity(null);
|
mActivityTestRule.launchActivity(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@SmallTest
|
|
||||||
public void testNullOnSignOutCallback() {
|
|
||||||
try {
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
|
||||||
() -> {
|
|
||||||
SignOutCoordinator.startSignOutFlow(
|
|
||||||
mActivityTestRule.getActivity(),
|
|
||||||
mProfile,
|
|
||||||
mFragmentManager,
|
|
||||||
mActivityTestRule.getActivity().getModalDialogManager(),
|
|
||||||
mSnackbarManager,
|
|
||||||
SignoutReason.USER_CLICKED_SIGNOUT_SETTINGS,
|
|
||||||
/* showConfirmDialog= */ false,
|
|
||||||
null);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
} catch (ExecutionException ex) {
|
|
||||||
MatcherAssert.assertThat(ex.getCause(), instanceOf(AssertionError.class));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@MediumTest
|
@MediumTest
|
||||||
@DisableFeatures(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)
|
@DisableFeatures(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)
|
||||||
|
@@ -58,8 +58,6 @@ import org.chromium.components.user_prefs.UserPrefs;
|
|||||||
import org.chromium.components.user_prefs.UserPrefsJni;
|
import org.chromium.components.user_prefs.UserPrefsJni;
|
||||||
import org.chromium.ui.test.util.BlankUiTestActivity;
|
import org.chromium.ui.test.util.BlankUiTestActivity;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Instrumentation tests for {@link SignOutDialogCoordinator}. */
|
/** Instrumentation tests for {@link SignOutDialogCoordinator}. */
|
||||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||||
@Batch(Batch.PER_CLASS)
|
@Batch(Batch.PER_CLASS)
|
||||||
@@ -101,9 +99,9 @@ public class SignOutDialogTest {
|
|||||||
public void testRegularAccountCanNotRevokeSyncConsent() {
|
public void testRegularAccountCanNotRevokeSyncConsent() {
|
||||||
when(mProfile.isChild()).thenReturn(false);
|
when(mProfile.isChild()).thenReturn(false);
|
||||||
// ThreadUtils.runOnUiThreadBlocking() catches the IllegalArgumentException and throws it
|
// ThreadUtils.runOnUiThreadBlocking() catches the IllegalArgumentException and throws it
|
||||||
// wrapped inside a ExecutionException.
|
// wrapped inside a RuntimeException.
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() -> showSignOutDialog(SignoutReason.USER_CLICKED_REVOKE_SYNC_CONSENT_SETTINGS));
|
() -> showSignOutDialog(SignoutReason.USER_CLICKED_REVOKE_SYNC_CONSENT_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +110,9 @@ public class SignOutDialogTest {
|
|||||||
public void testChildAccountCanOnlyRevokeSyncConsent() {
|
public void testChildAccountCanOnlyRevokeSyncConsent() {
|
||||||
when(mProfile.isChild()).thenReturn(true);
|
when(mProfile.isChild()).thenReturn(true);
|
||||||
// ThreadUtils.runOnUiThreadBlocking() catches the IllegalArgumentException and throws it
|
// ThreadUtils.runOnUiThreadBlocking() catches the IllegalArgumentException and throws it
|
||||||
// wrapped inside a ExecutionException.
|
// wrapped inside a RuntimeException.
|
||||||
Assert.assertThrows(
|
Assert.assertThrows(
|
||||||
ExecutionException.class,
|
RuntimeException.class,
|
||||||
() -> showSignOutDialog(SignoutReason.USER_CLICKED_SIGNOUT_SETTINGS));
|
() -> showSignOutDialog(SignoutReason.USER_CLICKED_SIGNOUT_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,6 @@ import org.chromium.url.GURL;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@@ -342,21 +341,9 @@ public class ChromeActivityTestRule<T extends ChromeActivity> extends BaseActivi
|
|||||||
*/
|
*/
|
||||||
public Tab loadUrlInNewTab(
|
public Tab loadUrlInNewTab(
|
||||||
final String url, final boolean incognito, final @TabLaunchType int launchType) {
|
final String url, final boolean incognito, final @TabLaunchType int launchType) {
|
||||||
Tab tab;
|
Tab tab =
|
||||||
try {
|
|
||||||
tab =
|
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<Tab>() {
|
() -> getActivity().getTabCreator(incognito).launchUrl(url, launchType));
|
||||||
@Override
|
|
||||||
public Tab call() {
|
|
||||||
return getActivity()
|
|
||||||
.getTabCreator(incognito)
|
|
||||||
.launchUrl(url, launchType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new AssertionError("Failed to create new tab", e);
|
|
||||||
}
|
|
||||||
ChromeTabUtils.waitForTabPageLoaded(tab, url);
|
ChromeTabUtils.waitForTabPageLoaded(tab, url);
|
||||||
ChromeTabUtils.waitForInteractable(tab);
|
ChromeTabUtils.waitForInteractable(tab);
|
||||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
||||||
|
@@ -43,7 +43,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/** Integration tests for text input for Android L (or above) features. */
|
/** Integration tests for text input for Android L (or above) features. */
|
||||||
@@ -399,20 +398,8 @@ class ImeActivityTestRule extends ContentShellActivityTestRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChromiumBaseInputConnection getInputConnection() {
|
ChromiumBaseInputConnection getInputConnection() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<ChromiumBaseInputConnection>() {
|
() -> (ChromiumBaseInputConnection) getImeAdapter().getInputConnectionForTest());
|
||||||
@Override
|
|
||||||
public ChromiumBaseInputConnection call() {
|
|
||||||
return (ChromiumBaseInputConnection)
|
|
||||||
getImeAdapter().getInputConnectionForTest();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Assert.fail();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void restartInput() {
|
void restartInput() {
|
||||||
|
12
content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
12
content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
@@ -36,7 +36,6 @@ import org.chromium.content_shell_apk.ContentShellActivityTestRule;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test various Java WebContents specific features.
|
* Test various Java WebContents specific features.
|
||||||
@@ -56,12 +55,10 @@ public class WebContentsTest {
|
|||||||
* Check that {@link WebContents#isDestroyed()} works as expected.
|
* Check that {@link WebContents#isDestroyed()} works as expected.
|
||||||
* TODO(dtrainor): Test this using {@link WebContents#destroy()} instead once it is possible to
|
* TODO(dtrainor): Test this using {@link WebContents#destroy()} instead once it is possible to
|
||||||
* build a {@link WebContents} directly in the content/ layer.
|
* build a {@link WebContents} directly in the content/ layer.
|
||||||
*
|
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testWebContentsIsDestroyedMethod() throws ExecutionException {
|
public void testWebContentsIsDestroyedMethod() {
|
||||||
final ContentShellActivity activity =
|
final ContentShellActivity activity =
|
||||||
mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
||||||
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
||||||
@@ -227,11 +224,10 @@ public class WebContentsTest {
|
|||||||
/**
|
/**
|
||||||
* Check that serializing a destroyed WebContents always results in a null deserialized
|
* Check that serializing a destroyed WebContents always results in a null deserialized
|
||||||
* WebContents.
|
* WebContents.
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testSerializingADestroyedWebContentsDoesNotDeserialize() throws ExecutionException {
|
public void testSerializingADestroyedWebContentsDoesNotDeserialize() {
|
||||||
ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
||||||
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
||||||
WebContents webContents = activity.getActiveWebContents();
|
WebContents webContents = activity.getActiveWebContents();
|
||||||
@@ -261,12 +257,10 @@ public class WebContentsTest {
|
|||||||
/**
|
/**
|
||||||
* Check that destroying a WebContents after serializing it always results in a null
|
* Check that destroying a WebContents after serializing it always results in a null
|
||||||
* deserialized WebContents.
|
* deserialized WebContents.
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testDestroyingAWebContentsAfterSerializingDoesNotDeserialize()
|
public void testDestroyingAWebContentsAfterSerializingDoesNotDeserialize() {
|
||||||
throws ExecutionException {
|
|
||||||
ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
ContentShellActivity activity = mActivityTestRule.launchContentShellWithUrl(TEST_URL_1);
|
||||||
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
mActivityTestRule.waitForActiveShellToBeDoneLoading();
|
||||||
WebContents webContents = activity.getActiveWebContents();
|
WebContents webContents = activity.getActiveWebContents();
|
||||||
|
@@ -28,7 +28,6 @@ import org.chromium.content_public.browser.WebContents;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
@@ -659,12 +658,8 @@ public class DOMUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getMaybeTopControlsHeight(final WebContents webContents) {
|
private static int getMaybeTopControlsHeight(final WebContents webContents) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> DOMUtilsJni.get().getTopControlsShrinkBlinkHeight(webContents));
|
() -> DOMUtilsJni.get().getTopControlsShrinkBlinkHeight(webContents));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,9 +12,6 @@ import android.view.ViewConfiguration;
|
|||||||
|
|
||||||
import org.chromium.base.ThreadUtils;
|
import org.chromium.base.ThreadUtils;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Touch-related functionality reused across test cases.
|
* Touch-related functionality reused across test cases.
|
||||||
*
|
*
|
||||||
@@ -493,21 +490,11 @@ public class TouchCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static View getRootViewForActivity(final Activity activity) {
|
private static View getRootViewForActivity(final Activity activity) {
|
||||||
try {
|
|
||||||
View view =
|
View view =
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<View>() {
|
() -> activity.findViewById(android.R.id.content).getRootView());
|
||||||
@Override
|
|
||||||
public View call() {
|
|
||||||
return activity.findViewById(android.R.id.content)
|
|
||||||
.getRootView();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assert view != null : "Failed to find root view for activity";
|
assert view != null : "Failed to find root view for activity";
|
||||||
return view;
|
return view;
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException("Dispatching touch event failed", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -517,17 +504,7 @@ public class TouchCommon {
|
|||||||
* @param event The view to be dispatched.
|
* @param event The view to be dispatched.
|
||||||
*/
|
*/
|
||||||
public static boolean dispatchTouchEvent(final View view, final MotionEvent event) {
|
public static boolean dispatchTouchEvent(final View view, final MotionEvent event) {
|
||||||
try {
|
return ThreadUtils.runOnUiThreadBlocking(() -> view.dispatchTouchEvent(event));
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
|
||||||
new Callable<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public Boolean call() {
|
|
||||||
return view.dispatchTouchEvent(event);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw new RuntimeException("Dispatching touch event failed", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -25,7 +25,6 @@ import org.chromium.content_public.browser.ViewEventSink;
|
|||||||
import org.chromium.content_public.browser.WebContents;
|
import org.chromium.content_public.browser.WebContents;
|
||||||
import org.chromium.content_public.browser.WebContentsObserver;
|
import org.chromium.content_public.browser.WebContentsObserver;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/** Collection of test-only WebContents utilities. */
|
/** Collection of test-only WebContents utilities. */
|
||||||
@@ -77,11 +76,7 @@ public class WebContentsUtils {
|
|||||||
* @param webContents The WebContents in use.
|
* @param webContents The WebContents in use.
|
||||||
*/
|
*/
|
||||||
public static ImeAdapter getImeAdapter(WebContents webContents) {
|
public static ImeAdapter getImeAdapter(WebContents webContents) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(() -> ImeAdapter.fromWebContents(webContents));
|
return ThreadUtils.runOnUiThreadBlocking(() -> ImeAdapter.fromWebContents(webContents));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,12 +85,8 @@ public class WebContentsUtils {
|
|||||||
* @param webContents The WebContents in use.
|
* @param webContents The WebContents in use.
|
||||||
*/
|
*/
|
||||||
public static GestureListenerManager getGestureListenerManager(WebContents webContents) {
|
public static GestureListenerManager getGestureListenerManager(WebContents webContents) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> GestureListenerManager.fromWebContents(webContents));
|
() -> GestureListenerManager.fromWebContents(webContents));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,11 +95,7 @@ public class WebContentsUtils {
|
|||||||
* @param webContents The WebContents in use.
|
* @param webContents The WebContents in use.
|
||||||
*/
|
*/
|
||||||
public static ViewEventSink getViewEventSink(WebContents webContents) {
|
public static ViewEventSink getViewEventSink(WebContents webContents) {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(() -> ViewEventSink.from(webContents));
|
return ThreadUtils.runOnUiThreadBlocking(() -> ViewEventSink.from(webContents));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
40
content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellActivityTestRule.java
40
content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellActivityTestRule.java
@@ -16,7 +16,6 @@ import androidx.test.InstrumentationRegistry;
|
|||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
import org.chromium.base.Log;
|
|
||||||
import org.chromium.base.ThreadUtils;
|
import org.chromium.base.ThreadUtils;
|
||||||
import org.chromium.base.test.BaseActivityTestRule;
|
import org.chromium.base.test.BaseActivityTestRule;
|
||||||
import org.chromium.base.test.util.CallbackHelper;
|
import org.chromium.base.test.util.CallbackHelper;
|
||||||
@@ -43,7 +42,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +108,7 @@ public class ContentShellActivityTestRule extends BaseActivityTestRule<ContentSh
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the OnCursorUpdateHelper. */
|
/** Returns the OnCursorUpdateHelper. */
|
||||||
public OnCursorUpdateHelper getOnCursorUpdateHelper() throws ExecutionException {
|
public OnCursorUpdateHelper getOnCursorUpdateHelper() {
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<OnCursorUpdateHelper>() {
|
new Callable<OnCursorUpdateHelper>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -125,94 +123,61 @@ public class ContentShellActivityTestRule extends BaseActivityTestRule<ContentSh
|
|||||||
|
|
||||||
/** Returns the current {@link ViewEventSink} or null if there is none; */
|
/** Returns the current {@link ViewEventSink} or null if there is none; */
|
||||||
public ViewEventSink getViewEventSink() {
|
public ViewEventSink getViewEventSink() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> {
|
() -> {
|
||||||
return ViewEventSink.from(getActivity().getActiveShell().getWebContents());
|
return ViewEventSink.from(getActivity().getActiveShell().getWebContents());
|
||||||
});
|
});
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the WebContents of this Shell. */
|
/** Returns the WebContents of this Shell. */
|
||||||
public WebContents getWebContents() {
|
public WebContents getWebContents() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> {
|
() -> {
|
||||||
return getActivity().getActiveShell().getWebContents();
|
return getActivity().getActiveShell().getWebContents();
|
||||||
});
|
});
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link SelectionPopupControllerImpl} of the WebContents. */
|
/** Returns the {@link SelectionPopupControllerImpl} of the WebContents. */
|
||||||
public SelectionPopupControllerImpl getSelectionPopupController() {
|
public SelectionPopupControllerImpl getSelectionPopupController() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> {
|
() -> {
|
||||||
return SelectionPopupControllerImpl.fromWebContents(
|
return SelectionPopupControllerImpl.fromWebContents(
|
||||||
getActivity().getActiveShell().getWebContents());
|
getActivity().getActiveShell().getWebContents());
|
||||||
});
|
});
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link ImeAdapterImpl} of the WebContents. */
|
/** Returns the {@link ImeAdapterImpl} of the WebContents. */
|
||||||
public ImeAdapterImpl getImeAdapter() {
|
public ImeAdapterImpl getImeAdapter() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> ImeAdapterImpl.fromWebContents(getWebContents()));
|
() -> ImeAdapterImpl.fromWebContents(getWebContents()));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the {@link SelectPopup} of the WebContents. */
|
/** Returns the {@link SelectPopup} of the WebContents. */
|
||||||
public SelectPopup getSelectPopup() {
|
public SelectPopup getSelectPopup() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> SelectPopup.fromWebContents(getWebContents()));
|
() -> SelectPopup.fromWebContents(getWebContents()));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebContentsAccessibilityImpl getWebContentsAccessibility() {
|
public WebContentsAccessibilityImpl getWebContentsAccessibility() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> WebContentsAccessibilityImpl.fromWebContents(getWebContents()));
|
() -> WebContentsAccessibilityImpl.fromWebContents(getWebContents()));
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the RenderCoordinates of the WebContents. */
|
/** Returns the RenderCoordinates of the WebContents. */
|
||||||
public RenderCoordinatesImpl getRenderCoordinates() {
|
public RenderCoordinatesImpl getRenderCoordinates() {
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> ((WebContentsImpl) getWebContents()).getRenderCoordinates());
|
() -> ((WebContentsImpl) getWebContents()).getRenderCoordinates());
|
||||||
} catch (ExecutionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the current container view or null if there is no WebContents. */
|
/** Returns the current container view or null if there is no WebContents. */
|
||||||
public View getContainerView() {
|
public View getContainerView() {
|
||||||
final WebContents webContents = getWebContents();
|
final WebContents webContents = getWebContents();
|
||||||
try {
|
|
||||||
return ThreadUtils.runOnUiThreadBlocking(
|
return ThreadUtils.runOnUiThreadBlocking(
|
||||||
() -> {
|
() -> {
|
||||||
return webContents != null
|
return webContents != null
|
||||||
? webContents.getViewAndroidDelegate().getContainerView()
|
? webContents.getViewAndroidDelegate().getContainerView()
|
||||||
: null;
|
: null;
|
||||||
});
|
});
|
||||||
} catch (ExecutionException e) {
|
|
||||||
Log.w(TAG, "Getting container view failed. Returning null", e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavascriptInjector getJavascriptInjector() {
|
public JavascriptInjector getJavascriptInjector() {
|
||||||
@@ -247,9 +212,8 @@ public class ContentShellActivityTestRule extends BaseActivityTestRule<ContentSh
|
|||||||
*
|
*
|
||||||
* @param url The URL to create the new {@link Shell} with.
|
* @param url The URL to create the new {@link Shell} with.
|
||||||
* @return A new instance of a {@link Shell}.
|
* @return A new instance of a {@link Shell}.
|
||||||
* @throws ExecutionException
|
|
||||||
*/
|
*/
|
||||||
public Shell loadNewShell(String url) throws ExecutionException {
|
public Shell loadNewShell(String url) {
|
||||||
Shell shell =
|
Shell shell =
|
||||||
ThreadUtils.runOnUiThreadBlocking(
|
ThreadUtils.runOnUiThreadBlocking(
|
||||||
new Callable<Shell>() {
|
new Callable<Shell>() {
|
||||||
|
@@ -17,8 +17,6 @@ import org.chromium.base.test.util.Feature;
|
|||||||
import org.chromium.base.test.util.UrlUtils;
|
import org.chromium.base.test.util.UrlUtils;
|
||||||
import org.chromium.content_shell.Shell;
|
import org.chromium.content_shell.Shell;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
/** Test suite to verify the behavior of the shell management logic. */
|
/** Test suite to verify the behavior of the shell management logic. */
|
||||||
@RunWith(BaseJUnit4ClassRunner.class)
|
@RunWith(BaseJUnit4ClassRunner.class)
|
||||||
public class ContentShellShellManagementTest {
|
public class ContentShellShellManagementTest {
|
||||||
@@ -34,7 +32,7 @@ public class ContentShellShellManagementTest {
|
|||||||
@SmallTest
|
@SmallTest
|
||||||
@Feature({"Main"})
|
@Feature({"Main"})
|
||||||
@DisabledTest(message = "https://crbug.com/1371971")
|
@DisabledTest(message = "https://crbug.com/1371971")
|
||||||
public void testMultipleShellsLaunched() throws ExecutionException {
|
public void testMultipleShellsLaunched() {
|
||||||
final ContentShellActivity activity =
|
final ContentShellActivity activity =
|
||||||
mActivityTestRule.launchContentShellWithUrl(TEST_PAGE_1);
|
mActivityTestRule.launchContentShellWithUrl(TEST_PAGE_1);
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
|
Reference in New Issue
Block a user