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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java

Issue 12567020: [android] Resize the android_webview if it's 0x0 initially. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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/javatests/src/org/chromium/android_webview/test/AwTestBase.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
index cf59ae5b62b1bc54d16b279f894d88d1b4cac59e..0c1d1e0cba1c6eea67d3585c24e8c4e08819a153 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java
@@ -12,6 +12,7 @@ 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.AwLayoutSizer;
import org.chromium.android_webview.AwSettings;
import org.chromium.android_webview.test.util.JSUtils;
import org.chromium.base.test.util.InMemorySharedPreferences;
@@ -189,26 +190,52 @@ public class AwTestBase
});
}
+ /**
+ * 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 {
+ public AwLayoutSizer createLayoutSizer() {
+ return new AwLayoutSizer();
+ }
+ }
+
protected AwTestContainerView createAwTestContainerView(
final AwContentsClient awContentsClient) {
- return createAwTestContainerView(new AwTestContainerView(getActivity()),
- awContentsClient);
+ return createAwTestContainerView(awContentsClient, new TestDependencyFactory());
}
protected AwTestContainerView createAwTestContainerView(
- final AwTestContainerView testContainerView,
- final AwContentsClient awContentsClient) {
+ final AwContentsClient awContentsClient,
+ final TestDependencyFactory testDependencyFactory) {
+ AwTestContainerView testContainerView =
+ createDetachedAwTestContainerView(awContentsClient, testDependencyFactory);
+ getActivity().addView(testContainerView);
+ testContainerView.requestFocus();
+ return testContainerView;
+ }
+
+ protected AwTestContainerView createDetachedAwTestContainerView(
+ final AwContentsClient awContentsClient,
+ final TestDependencyFactory testDependencyFactory) {
+ final AwTestContainerView testContainerView = new AwTestContainerView(getActivity());
testContainerView.initialize(new AwContents(
new AwBrowserContext(new InMemorySharedPreferences()),
testContainerView, testContainerView.getInternalAccessDelegate(),
- awContentsClient, false));
- getActivity().addView(testContainerView);
- testContainerView.requestFocus();
+ awContentsClient, false, testDependencyFactory.createLayoutSizer()));
return testContainerView;
}
protected AwTestContainerView createAwTestContainerViewOnMainSync(
final AwContentsClient client) throws Exception {
+ return createAwTestContainerViewOnMainSync(client, new TestDependencyFactory());
+ }
+
+ protected AwTestContainerView createAwTestContainerViewOnMainSync(
+ final AwContentsClient client,
+ final TestDependencyFactory testDependencyFactory) throws Exception {
final AtomicReference<AwTestContainerView> testContainerView =
new AtomicReference<AwTestContainerView>();
getInstrumentation().runOnMainSync(new Runnable() {

Powered by Google App Engine
This is Rietveld 408576698