Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1018d95196f8702428c07382d376bdb6155696f6 |
| --- /dev/null |
| +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.content.browser.test; |
| + |
| +import android.support.test.InstrumentationRegistry; |
| + |
| +import org.junit.rules.TestRule; |
| +import org.junit.runner.Description; |
| +import org.junit.runners.model.Statement; |
| + |
| +/** |
| + * TestRule that adds support for loading and dealing with native libraries. |
| + */ |
| +public class NativeLibraryTestRule implements TestRule { |
|
boliu
2017/03/08 21:40:18
why does this not inherit from android base class?
the real yoland
2017/03/08 22:53:53
Done
|
| + private final NativeLibraryTestCommon mTestCommon = new NativeLibraryTestCommon(); |
| + |
| + /** |
| + * Loads the native library on the activity UI thread (must not be called from the UI thread). |
| + */ |
| + public void loadNativeLibraryNoBrowserProcess() { |
| + mTestCommon.handleNativeInitialization(false, InstrumentationRegistry.getInstrumentation()); |
| + } |
| + |
| + /** |
| + * Loads the native library on the activity UI thread (must not be called from the UI thread). |
| + * After loading the library, this will initialize the browser process. |
| + */ |
| + public void loadNativeLibraryAndInitBrowserProcess() { |
| + mTestCommon.handleNativeInitialization(true, InstrumentationRegistry.getInstrumentation()); |
| + } |
| + |
| + @Override |
| + public Statement apply(final Statement base, Description description) { |
|
boliu
2017/03/08 21:40:18
just return base?
the real yoland
2017/03/08 22:53:53
Oops, done
|
| + return new Statement() { |
| + @Override |
| + public void evaluate() throws Throwable { |
| + base.evaluate(); |
| + } |
| + }; |
| + } |
| +} |