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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/test/ChromeBrowserTestRule.java

Issue 2885983002: Fixes intent chooser being shown incorrectly when going from HTTPS to HTTP for (Closed)
Patch Set: . 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/test/ChromeBrowserTestRule.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/test/ChromeBrowserTestRule.java b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ChromeBrowserTestRule.java
new file mode 100644
index 0000000000000000000000000000000000000000..020ac6734e7f99c5f626a561d11db98b4128b71b
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/test/ChromeBrowserTestRule.java
@@ -0,0 +1,60 @@
+// 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.chrome.browser.test;
+
+import android.app.Instrumentation;
+import android.support.test.InstrumentationRegistry;
+
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import org.chromium.chrome.test.util.browser.signin.SigninTestUtil;
+import org.chromium.content.browser.test.NativeLibraryTestRule;
+
+/**
+ * JUnit test rule that takes care of important initialization for Chrome-specific tests, such as
+ * initializing the AccountManagerHelper.
+ */
+public class ChromeBrowserTestRule extends NativeLibraryTestRule {
+ private final boolean mInitBrowserProcess;
+
+ public ChromeBrowserTestRule(boolean initBrowserProcess) {
+ mInitBrowserProcess = initBrowserProcess;
+ }
+
+ void initialize(final boolean initBrowserProcess, Instrumentation instrumentation) {
+ SigninTestUtil.setUpAuthForTest(instrumentation);
+ if (initBrowserProcess) {
+ loadNativeLibraryAndInitBrowserProcess();
+ } else {
+ loadNativeLibraryNoBrowserProcess();
+ }
+ }
+
+ @Override
+ public Statement apply(final Statement base, Description description) {
+ return new Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ /**
+ * 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
+ * if necessary.
+ */
+ initialize(mInitBrowserProcess, InstrumentationRegistry.getInstrumentation());
+ try {
+ base.evaluate();
+ } finally {
+ tearDown();
+ }
+ }
+ };
+ }
+
+ public void tearDown() {
+ SigninTestUtil.resetSigninState();
+ SigninTestUtil.tearDownAuthForTest();
+ }
+}
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698