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

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

Issue 2739603003: Add TestRules for content shell test and refactor test bases (Closed)
Patch Set: Address +boliu's comments 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
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..a673f124a5c402addb3e5fd96c5fd6b019bb5945
--- /dev/null
+++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java
@@ -0,0 +1,40 @@
+// 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.
+ *
+ * NativeLibraryTestRule does not interact with any Activity.
+ */
+public class NativeLibraryTestRule implements TestRule {
+ 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(Statement base, Description description) {
+ return base;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698