Commit 9c3e86bb authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Commit Bot

Remove "not called from UI thread" check from NativeLibraryTestUtils

runOnUiThreadBlocking() has no restriction on being called from the
UI thread, so it should be safe to call the loadNativeLibrary...()
methods from the UI thread as well.

This CL also fixes one comment cross-reference to NativeLibraryTestRule,
which apparently doesn't exist anymore.


[1] https://source.chromium.org/chromium/chromium/src/+/master:base/android/java/src/org/chromium/base/ThreadUtils.java;drc=c741e070dbfcc33b2369e7a5131be87c7b21bb99;bpv=1;l=156

TBR=jdoerrie@chromium.org

Bug: None
Change-Id: Icd38029ac5dddd372485be00f03648068d7e3063
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404351
Commit-Queue: Victor Vianna <victorvianna@google.com>
Reviewed-by: default avatarVictor Vianna <victorvianna@google.com>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807054}
parent 30709248
...@@ -44,7 +44,7 @@ public @interface Batch { ...@@ -44,7 +44,7 @@ public @interface Batch {
* Unit tests must be careful not to persist any changes to global state, or flakes are likely * Unit tests must be careful not to persist any changes to global state, or flakes are likely
* to occur. * to occur.
* *
* An exception to this is loading Chrome's native library (eg. using NativeLibraryTestRule). * An exception to this is loading Chrome's native library (eg. using NativeLibraryTestUtils).
* Your unit tests must assume that the native library may have already been loaded by another * Your unit tests must assume that the native library may have already been loaded by another
* test. * test.
*/ */
......
...@@ -26,9 +26,8 @@ public class ChromeBrowserTestRule implements TestRule { ...@@ -26,9 +26,8 @@ public class ChromeBrowserTestRule implements TestRule {
@Override @Override
public void evaluate() throws Throwable { public void evaluate() throws Throwable {
/** /**
* Loads the native library on the activity UI thread (must not be called from the * Loads the native library on the activity UI thread. After loading the library,
* UI thread). After loading the library, this will initialize the browser process * this will initialize the browser process if necessary.
* if necessary.
*/ */
NativeLibraryTestUtils.loadNativeLibraryAndInitBrowserProcess(); NativeLibraryTestUtils.loadNativeLibraryAndInitBrowserProcess();
base.evaluate(); base.evaluate();
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
package org.chromium.content_public.browser.test; package org.chromium.content_public.browser.test;
import org.junit.Assert;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.LibraryLoader; import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType; import org.chromium.base.library_loader.LibraryProcessType;
...@@ -18,14 +16,14 @@ import org.chromium.ui.resources.ResourceExtractor; ...@@ -18,14 +16,14 @@ import org.chromium.ui.resources.ResourceExtractor;
*/ */
public class NativeLibraryTestUtils { public class NativeLibraryTestUtils {
/** /**
* Loads the native library on the activity UI thread (must not be called from the UI thread). * Loads the native library on the activity UI thread.
*/ */
public static void loadNativeLibraryNoBrowserProcess() { public static void loadNativeLibraryNoBrowserProcess() {
handleNativeInitialization(false); handleNativeInitialization(false);
} }
/** /**
* Loads the native library on the activity UI thread (must not be called from the UI thread). * Loads the native library on the activity UI thread.
* After loading the library, this will initialize the browser process. * After loading the library, this will initialize the browser process.
*/ */
public static void loadNativeLibraryAndInitBrowserProcess() { public static void loadNativeLibraryAndInitBrowserProcess() {
...@@ -33,8 +31,6 @@ public class NativeLibraryTestUtils { ...@@ -33,8 +31,6 @@ public class NativeLibraryTestUtils {
} }
private static void handleNativeInitialization(final boolean initBrowserProcess) { private static void handleNativeInitialization(final boolean initBrowserProcess) {
Assert.assertFalse(ThreadUtils.runningOnUiThread());
// LibraryLoader is not in general multithreaded; as other InstrumentationTestCase code // LibraryLoader is not in general multithreaded; as other InstrumentationTestCase code
// (specifically, ChromeBrowserProvider) uses it from the main thread we must do // (specifically, ChromeBrowserProvider) uses it from the main thread we must do
// likewise. // likewise.
......
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