OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 android.app.Instrumentation; | 7 import android.app.Instrumentation; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.test.ActivityInstrumentationTestCase2; | 9 import android.test.ActivityInstrumentationTestCase2; |
10 | 10 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 throws Throwable { | 196 throws Throwable { |
197 runTestOnUiThread(new Runnable() { | 197 runTestOnUiThread(new Runnable() { |
198 @Override | 198 @Override |
199 public void run() { | 199 public void run() { |
200 awContents.loadUrl(LoadUrlParams.createLoadDataParams( | 200 awContents.loadUrl(LoadUrlParams.createLoadDataParams( |
201 data, mimeType, isBase64Encoded)); | 201 data, mimeType, isBase64Encoded)); |
202 } | 202 } |
203 }); | 203 }); |
204 } | 204 } |
205 | 205 |
206 protected AwTestContainerView createAwTestContainerView(final boolean incogn ito, | 206 protected AwTestContainerView createAwTestContainerView( |
207 final AwContentsClient awContentsClient) { | 207 final AwContentsClient awContentsClient) { |
208 return createAwTestContainerView(incognito, new AwTestContainerView(getA ctivity()), | 208 return createAwTestContainerView(new AwTestContainerView(getActivity()), |
209 awContentsClient); | 209 awContentsClient); |
210 } | 210 } |
211 | 211 |
212 protected AwTestContainerView createAwTestContainerView(final boolean incogn ito, | 212 protected AwTestContainerView createAwTestContainerView( |
213 final AwTestContainerView testContainerView, | 213 final AwTestContainerView testContainerView, |
214 final AwContentsClient awContentsClient) { | 214 final AwContentsClient awContentsClient) { |
215 testContainerView.initialize(new AwContents(testContainerView, | 215 testContainerView.initialize(new AwContents(testContainerView, |
216 testContainerView.getInternalAccessDelegate(), | 216 testContainerView.getInternalAccessDelegate(), |
217 awContentsClient, new ActivityNativeWindow(getActivity()), | 217 awContentsClient, new ActivityNativeWindow(getActivity()), false )); |
218 incognito, false)); | |
219 getActivity().addView(testContainerView); | 218 getActivity().addView(testContainerView); |
220 testContainerView.requestFocus(); | 219 testContainerView.requestFocus(); |
221 return testContainerView; | 220 return testContainerView; |
222 } | 221 } |
223 | 222 |
224 protected AwTestContainerView createAwTestContainerViewOnMainSync( | 223 protected AwTestContainerView createAwTestContainerViewOnMainSync( |
225 final AwContentsClient client) throws Exception { | 224 final AwContentsClient client) throws Exception { |
226 return createAwTestContainerViewOnMainSync(NORMAL_VIEW, client); | 225 return createAwTestContainerViewOnMainSync(NORMAL_VIEW, client); |
227 } | 226 } |
228 | 227 |
229 protected AwTestContainerView createAwTestContainerViewOnMainSync( | 228 protected AwTestContainerView createAwTestContainerViewOnMainSync( |
230 final boolean incognito, | 229 final boolean incognito, |
boliu
2013/01/05 09:11:14
Will be more work to remove this
Kristian Monsen
2013/01/07 17:35:01
It was a bit of work, also removed what was a bunc
| |
231 final AwContentsClient client) throws Exception { | 230 final AwContentsClient client) throws Exception { |
232 final AtomicReference<AwTestContainerView> testContainerView = | 231 final AtomicReference<AwTestContainerView> testContainerView = |
233 new AtomicReference<AwTestContainerView>(); | 232 new AtomicReference<AwTestContainerView>(); |
234 final Context context = getActivity(); | 233 final Context context = getActivity(); |
235 getInstrumentation().runOnMainSync(new Runnable() { | 234 getInstrumentation().runOnMainSync(new Runnable() { |
236 @Override | 235 @Override |
237 public void run() { | 236 public void run() { |
238 testContainerView.set(createAwTestContainerView(incognito, clien t)); | 237 testContainerView.set(createAwTestContainerView(client)); |
239 } | 238 } |
240 }); | 239 }); |
241 return testContainerView.get(); | 240 return testContainerView.get(); |
242 } | 241 } |
243 | 242 |
244 protected void destroyAwContentsOnMainSync(final AwContents awContents) { | 243 protected void destroyAwContentsOnMainSync(final AwContents awContents) { |
245 if (awContents == null) return; | 244 if (awContents == null) return; |
246 getInstrumentation().runOnMainSync(new Runnable() { | 245 getInstrumentation().runOnMainSync(new Runnable() { |
247 @Override | 246 @Override |
248 public void run() { | 247 public void run() { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 final AwContents awContents, | 315 final AwContents awContents, |
317 final boolean includeDiskFiles) throws Throwable { | 316 final boolean includeDiskFiles) throws Throwable { |
318 runTestOnUiThread(new Runnable() { | 317 runTestOnUiThread(new Runnable() { |
319 @Override | 318 @Override |
320 public void run() { | 319 public void run() { |
321 awContents.clearCache(includeDiskFiles); | 320 awContents.clearCache(includeDiskFiles); |
322 } | 321 } |
323 }); | 322 }); |
324 } | 323 } |
325 } | 324 } |
OLD | NEW |