Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java

Issue 2810373002: InstalledAppProviderImpl: Assert that code is run off the UI thread. (Closed)
Patch Set: Use real assert instead of exception (apparently this works now). Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java
diff --git a/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java b/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java
index b2c2161f033856d71c5500de3f2eba6219ab7b05..5b073a12849c757a52570d50d7b7f64a289353cf 100644
--- a/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java
+++ b/content/public/android/junit/src/org/chromium/content/browser/installedapp/InstalledAppProviderTest.java
@@ -12,15 +12,16 @@ import android.content.res.AssetManager;
import android.content.res.Resources;
import android.os.Bundle;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.res.builder.DefaultPackageManager;
+import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.installedapp.mojom.InstalledAppProvider;
import org.chromium.installedapp.mojom.RelatedApplication;
@@ -294,6 +295,9 @@ public class InstalledAppProviderTest {
@Before
public void setUp() {
+ // Avoid triggering asserts in InstalledAppProviderImpl that check they are being run off
+ // the UI thread (since this is a single-threaded test).
+ ThreadUtils.setThreadAssertsEnabled(false);
mPackageManager = new FakePackageManager();
RuntimeEnvironment.setRobolectricPackageManager(mPackageManager);
mFrameUrlDelegate = new FakeFrameUrlDelegate(URL_ON_ORIGIN);
@@ -301,6 +305,11 @@ public class InstalledAppProviderTest {
new InstalledAppProviderTestImpl(mFrameUrlDelegate, RuntimeEnvironment.application);
}
+ @After
+ public void tearDown() {
+ ThreadUtils.setThreadAssertsEnabled(true);
+ }
+
/**
* Origin of the page using the API is missing certain parts of the URI.
*/

Powered by Google App Engine
This is Rietveld 408576698