OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 7 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
8 | 8 |
9 import android.app.Instrumentation; | 9 import android.app.Instrumentation; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 if (needsAwBrowserContextCreated()) { | 87 if (needsAwBrowserContextCreated()) { |
88 createAwBrowserContext(); | 88 createAwBrowserContext(); |
89 } | 89 } |
90 | 90 |
91 super.setUp(); | 91 super.setUp(); |
92 if (needsBrowserProcessStarted()) { | 92 if (needsBrowserProcessStarted()) { |
93 startBrowserProcess(); | 93 startBrowserProcess(); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 protected void createAwBrowserContext() { | 97 protected void createAwBrowserContext() { |
boliu
2017/02/14 18:31:40
ideally this would be made private as well, are th
Nate Fischer
2017/02/14 19:42:55
No other test overrides this function, but AwStric
boliu
2017/02/14 22:26:57
Ok. This is fine then.
| |
98 if (mBrowserContext != null) { | 98 if (mBrowserContext != null) { |
99 throw new AndroidRuntimeException("There should only be one browser context."); | 99 throw new AndroidRuntimeException("There should only be one browser context."); |
100 } | 100 } |
101 getActivity(); // The Activity must be launched in order to load native code | 101 getActivity(); // The Activity must be launched in order to load native code |
102 final InMemorySharedPreferences prefs = new InMemorySharedPreferences(); | 102 final InMemorySharedPreferences prefs = new InMemorySharedPreferences(); |
103 final Context appContext = getInstrumentation().getTargetContext().getAp plicationContext(); | 103 final Context appContext = getInstrumentation().getTargetContext().getAp plicationContext(); |
104 getInstrumentation().runOnMainSync(new Runnable() { | 104 getInstrumentation().runOnMainSync(new Runnable() { |
105 @Override | 105 @Override |
106 public void run() { | 106 public void run() { |
107 mBrowserContext = new AwBrowserContext(prefs, appContext); | 107 createAwBrowserContextHelper(prefs, appContext); |
108 } | 108 } |
109 }); | 109 }); |
110 } | 110 } |
111 | 111 |
112 protected void createAwBrowserContextHelper( | |
boliu
2017/02/14 18:31:40
s/Helper/onUiThread/
Nate Fischer
2017/02/14 19:42:55
Done
| |
113 InMemorySharedPreferences prefs, Context appContext) { | |
114 setBrowserContext(new AwBrowserContext(prefs, appContext)); | |
115 } | |
116 | |
117 protected void setBrowserContext(AwBrowserContext browserContext) { | |
boliu
2017/02/14 18:31:40
this should be private (or shouldn't exist at all)
Nate Fischer
2017/02/14 19:42:55
Done
| |
118 mBrowserContext = browserContext; | |
119 } | |
120 | |
112 protected void startBrowserProcess() throws Exception { | 121 protected void startBrowserProcess() throws Exception { |
113 // The Activity must be launched in order for proper webview statics to be setup. | 122 // The Activity must be launched in order for proper webview statics to be setup. |
114 getActivity(); | 123 getActivity(); |
115 getInstrumentation().runOnMainSync(new Runnable() { | 124 getInstrumentation().runOnMainSync(new Runnable() { |
116 @Override | 125 @Override |
117 public void run() { | 126 public void run() { |
118 AwBrowserProcess.start(); | 127 AwBrowserProcess.start(); |
119 } | 128 } |
120 }); | 129 }); |
121 } | 130 } |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 int titleCallCount = onReceivedTitleHelper.getCallCount(); | 713 int titleCallCount = onReceivedTitleHelper.getCallCount(); |
705 | 714 |
706 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS , | 715 onPageFinishedHelper.waitForCallback(finishCallCount, 1, WAIT_TIMEOUT_MS , |
707 TimeUnit.MILLISECONDS); | 716 TimeUnit.MILLISECONDS); |
708 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS , | 717 onReceivedTitleHelper.waitForCallback(titleCallCount, 1, WAIT_TIMEOUT_MS , |
709 TimeUnit.MILLISECONDS); | 718 TimeUnit.MILLISECONDS); |
710 | 719 |
711 return new PopupInfo(popupContentsClient, popupContainerView, popupConte nts); | 720 return new PopupInfo(popupContentsClient, popupContainerView, popupConte nts); |
712 } | 721 } |
713 } | 722 } |
OLD | NEW |