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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.util.Log; | 7 import android.util.Log; |
8 | 8 |
9 import org.chromium.base.test.util.UrlUtils; | 9 import org.chromium.base.test.util.UrlUtils; |
10 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 10 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
11 import org.chromium.content_public.browser.LoadUrlParams; | 11 import org.chromium.content_public.browser.LoadUrlParams; |
| 12 import org.chromium.content_public.browser.NavigationController; |
12 import org.chromium.content_shell_apk.ContentShellActivity; | 13 import org.chromium.content_shell_apk.ContentShellActivity; |
13 import org.chromium.content_shell_apk.ContentShellTestBase; | 14 import org.chromium.content_shell_apk.ContentShellTestBase; |
14 | 15 |
15 /** | 16 /** |
16 * Provides test environment for ContentView Test Shell. | 17 * Provides test environment for ContentView Test Shell. |
17 * This is a helper class for Content Shell tests. | 18 * This is a helper class for Content Shell tests. |
18 */ | 19 */ |
19 public class ContentViewTestBase extends ContentShellTestBase { | 20 public class ContentViewTestBase extends ContentShellTestBase { |
20 | 21 |
21 protected TestCallbackHelperContainer mTestCallbackHelperContainer; | 22 protected TestCallbackHelperContainer mTestCallbackHelperContainer; |
(...skipping 13 matching lines...) Expand all Loading... |
35 try { | 36 try { |
36 runTestOnUiThread(new Runnable() { | 37 runTestOnUiThread(new Runnable() { |
37 @Override | 38 @Override |
38 public void run() { | 39 public void run() { |
39 ContentViewCore viewCore = activity.getActiveContentViewCore
(); | 40 ContentViewCore viewCore = activity.getActiveContentViewCore
(); |
40 viewCore.addPossiblyUnsafeJavascriptInterface(object, name,
null); | 41 viewCore.addPossiblyUnsafeJavascriptInterface(object, name,
null); |
41 mTestCallbackHelperContainer = new TestCallbackHelperContain
er(viewCore); | 42 mTestCallbackHelperContainer = new TestCallbackHelperContain
er(viewCore); |
42 } | 43 } |
43 }); | 44 }); |
44 | 45 |
45 loadDataSync(activity.getActiveContentViewCore(), | 46 loadDataSync(activity.getActiveContentViewCore().getWebContents() |
46 "<!DOCTYPE html><title></title>", "text/html", false); | 47 .getNavigationController(), "<!DOCTYPE html><title></title>"
, "text/html", |
| 48 false); |
47 } catch (Throwable e) { | 49 } catch (Throwable e) { |
48 throw new RuntimeException( | 50 throw new RuntimeException( |
49 "Failed to set up ContentView: " + Log.getStackTraceString(e
)); | 51 "Failed to set up ContentView: " + Log.getStackTraceString(e
)); |
50 } | 52 } |
51 } | 53 } |
52 | 54 |
53 /** | 55 /** |
54 * Loads data on the UI thread and blocks until onPageFinished is called. | 56 * Loads data on the UI thread and blocks until onPageFinished is called. |
55 * TODO(cramya): Move method to a separate util file once UiUtils.java moves
into base. | 57 * TODO(cramya): Move method to a separate util file once UiUtils.java moves
into base. |
56 */ | 58 */ |
57 protected void loadDataSync(final ContentViewCore contentViewCore, final Str
ing data, | 59 protected void loadDataSync(final NavigationController navigationController,
final String data, |
58 final String mimeType, final boolean isBase64Encoded) throws Throwab
le { | 60 final String mimeType, final boolean isBase64Encoded) throws Throwab
le { |
59 loadUrl(contentViewCore, mTestCallbackHelperContainer, LoadUrlParams.cre
ateLoadDataParams( | 61 loadUrl(navigationController, mTestCallbackHelperContainer, |
60 data, mimeType, isBase64Encoded)); | 62 LoadUrlParams.createLoadDataParams(data, mimeType, isBase64Encod
ed)); |
61 } | 63 } |
62 } | 64 } |
OLD | NEW |