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

Unified Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java

Issue 2778103002: Alternative: Convert Chrome NativeLibraryTestBase tests example (Closed)
Patch Set: change BUILD.gn Created 3 years, 9 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/IntentHandlerTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java
index a673f124a5c402addb3e5fd96c5fd6b019bb5945..7b625c45f0f4dd5da409beb6e0214f759a1d0768 100644
--- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java
+++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java
@@ -6,17 +6,24 @@ package org.chromium.content.browser.test;
import android.support.test.InstrumentationRegistry;
+import org.junit.Assert;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
+import org.chromium.base.test.SetUpTestRule;
+
/**
* TestRule that adds support for loading and dealing with native libraries.
*
* NativeLibraryTestRule does not interact with any Activity.
*/
-public class NativeLibraryTestRule implements TestRule {
+public class NativeLibraryTestRule implements TestRule, SetUpTestRule<NativeLibraryTestRule> {
private final NativeLibraryTestCommon mTestCommon = new NativeLibraryTestCommon();
+ private NativeLibraryInitializationOption mInitOption;
+ private boolean mShouldSetUp = false;
+
+ public enum NativeLibraryInitializationOption { INIT_BROWSER_PROCESS, NO_BROWSER_PROCESS }
/**
* Loads the native library on the activity UI thread (must not be called from the UI thread).
@@ -33,8 +40,33 @@ public class NativeLibraryTestRule implements TestRule {
mTestCommon.handleNativeInitialization(true, InstrumentationRegistry.getInstrumentation());
}
+ public NativeLibraryTestRule setInitOption(NativeLibraryInitializationOption option) {
+ mInitOption = option;
+ return this;
+ }
+
+ @Override
+ public NativeLibraryTestRule shouldSetUp(boolean runSetUp) {
+ mShouldSetUp = runSetUp;
+ return this;
+ }
+
@Override
public Statement apply(Statement base, Description description) {
- return base;
+ return new SetUpStatement(base, this, mShouldSetUp);
+ }
+
+ @Override
+ public void setUp() {
+ Assert.assertNotNull("Initialization option not set, please call "
+ + "NativeLibraryTestRule#setInitOption to set up",
+ mInitOption);
+ if (mInitOption.equals(NativeLibraryInitializationOption.INIT_BROWSER_PROCESS)) {
+ loadNativeLibraryAndInitBrowserProcess();
+ } else if (mInitOption.equals(NativeLibraryInitializationOption.NO_BROWSER_PROCESS)) {
+ loadNativeLibraryNoBrowserProcess();
+ } else {
+ throw new AssertionError("Initialization option not recognized");
+ }
}
}
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/IntentHandlerTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698