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

Unified Diff: android_webview/test/shell/src/org/chromium/android_webview/test/AwTestBaseUtility.java

Issue 2201783003: Add test to ensure shouldOverrideUrlLoading throws Java exception (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add testbase for separate-service tests, use this from AwSecondBrowserTest. Created 4 years, 3 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: android_webview/test/shell/src/org/chromium/android_webview/test/AwTestBaseUtility.java
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestBaseUtility.java b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestBaseUtility.java
new file mode 100644
index 0000000000000000000000000000000000000000..f44bc2168ccebba622f5fc5a2ffc2cefdbf12750
--- /dev/null
+++ b/android_webview/test/shell/src/org/chromium/android_webview/test/AwTestBaseUtility.java
@@ -0,0 +1,68 @@
+// Copyright 2016 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.android_webview.test;
+
+import android.content.Context;
+
+import org.chromium.android_webview.AwBrowserContext;
+import org.chromium.android_webview.AwBrowserProcess;
+import org.chromium.android_webview.AwContents;
+import org.chromium.android_webview.AwContentsClient;
+import org.chromium.android_webview.AwResource;
+import org.chromium.android_webview.AwSettings;
+import org.chromium.android_webview.shell.R;
+import org.chromium.base.CommandLine;
+import org.chromium.base.ContextUtils;
+import org.chromium.base.annotations.SuppressFBWarnings;
+
+/**
+ * Utility code related to AwTestBase but living in the shell apk to provide functionality to other
+ * classes in the shell apk.
+ */
+public class AwTestBaseUtility {
+ /**
+ * Factory class used in creation of test AwContents instances.
+ *
+ * Test cases can provide subclass instances to the createAwTest* methods in order to create an
+ * AwContents instance with injected test dependencies.
+ */
+ public static class TestDependencyFactory extends AwContents.DependencyFactory {
+ public AwTestContainerView createAwTestContainerView(
+ Context context, boolean allowHardwareAcceleration) {
+ return new AwTestContainerView(context, allowHardwareAcceleration);
+ }
+ public AwSettings createAwSettings(Context context, boolean supportsLegacyQuirks) {
+ return new AwSettings(context, false /* isAccessFromFileURLsGrantedByDefault */,
+ supportsLegacyQuirks, false /* allowEmptyDocumentPersistence */,
+ true /* allowGeolocationOnInsecureOrigins */);
+ }
+ }
+
+ public static AwTestContainerView createDetachedAwTestContainerView(Context context,
+ AwBrowserContext browserContext, final TestDependencyFactory testDependencyFactory,
+ final AwContentsClient awContentsClient, boolean supportsLegacyQuirks,
+ boolean allowHardwareAcceleration) {
+ final AwTestContainerView testContainerView =
+ testDependencyFactory.createAwTestContainerView(context, allowHardwareAcceleration);
+
+ AwSettings awSettings =
+ testDependencyFactory.createAwSettings(context, supportsLegacyQuirks);
+ testContainerView.initialize(new AwContents(browserContext, testContainerView,
+ testContainerView.getContext(), testContainerView.getInternalAccessDelegate(),
+ testContainerView.getNativeDrawGLFunctorFactory(), awContentsClient, awSettings,
+ testDependencyFactory));
+ return testContainerView;
+ }
+
+ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
+ static void startBrowserProcess(Context context) throws Exception {
+ CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");
+ AwResource.setResources(context.getResources());
+ AwResource.setConfigKeySystemUuidMapping(R.array.config_key_system_uuid_mapping);
+ ContextUtils.initApplicationContext(context.getApplicationContext());
+ AwBrowserProcess.loadLibrary();
+ AwBrowserProcess.start();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698