| 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");
|
| + }
|
| }
|
| }
|
|
|