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.test.util; | 5 package org.chromium.content.browser.test.util; |
6 | 6 |
7 | 7 |
8 import org.chromium.base.ThreadUtils; | 8 import org.chromium.base.ThreadUtils; |
9 import org.chromium.content.browser.ContentViewCore; | 9 import org.chromium.content.browser.ContentViewCore; |
| 10 import org.chromium.content_public.browser.JavaScriptCallback; |
10 | 11 |
11 import java.util.concurrent.TimeUnit; | 12 import java.util.concurrent.TimeUnit; |
12 import java.util.concurrent.TimeoutException; | 13 import java.util.concurrent.TimeoutException; |
13 | 14 |
14 /** | 15 /** |
15 * This class is used to provide callback hooks for tests and related classes. | 16 * This class is used to provide callback hooks for tests and related classes. |
16 */ | 17 */ |
17 public class TestCallbackHelperContainer { | 18 public class TestCallbackHelperContainer { |
18 private final TestContentViewClient mTestContentViewClient; | 19 private final TestContentViewClient mTestContentViewClient; |
19 private TestWebContentsObserver mTestWebContentsObserver; | 20 private TestWebContentsObserver mTestWebContentsObserver; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 */ | 103 */ |
103 public static class OnEvaluateJavaScriptResultHelper extends CallbackHelper
{ | 104 public static class OnEvaluateJavaScriptResultHelper extends CallbackHelper
{ |
104 private String mJsonResult; | 105 private String mJsonResult; |
105 | 106 |
106 /** | 107 /** |
107 * Starts evaluation of a given JavaScript code on a given contentViewCo
re. | 108 * Starts evaluation of a given JavaScript code on a given contentViewCo
re. |
108 * @param contentViewCore A ContentViewCore instance to be used. | 109 * @param contentViewCore A ContentViewCore instance to be used. |
109 * @param code A JavaScript code to be evaluated. | 110 * @param code A JavaScript code to be evaluated. |
110 */ | 111 */ |
111 public void evaluateJavaScript(ContentViewCore contentViewCore, String c
ode) { | 112 public void evaluateJavaScript(ContentViewCore contentViewCore, String c
ode) { |
112 ContentViewCore.JavaScriptCallback callback = | 113 JavaScriptCallback callback = |
113 new ContentViewCore.JavaScriptCallback() { | 114 new JavaScriptCallback() { |
114 @Override | 115 @Override |
115 public void handleJavaScriptResult(String jsonResult) { | 116 public void handleJavaScriptResult(String jsonResult) { |
116 notifyCalled(jsonResult); | 117 notifyCalled(jsonResult); |
117 } | 118 } |
118 }; | 119 }; |
119 contentViewCore.evaluateJavaScript(code, callback); | 120 contentViewCore.evaluateJavaScript(code, callback); |
120 mJsonResult = null; | 121 mJsonResult = null; |
121 } | 122 } |
122 | 123 |
123 /** | 124 /** |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 199 } |
199 | 200 |
200 public OnReceivedErrorHelper getOnReceivedErrorHelper() { | 201 public OnReceivedErrorHelper getOnReceivedErrorHelper() { |
201 return mTestWebContentsObserver.getOnReceivedErrorHelper(); | 202 return mTestWebContentsObserver.getOnReceivedErrorHelper(); |
202 } | 203 } |
203 | 204 |
204 public OnStartContentIntentHelper getOnStartContentIntentHelper() { | 205 public OnStartContentIntentHelper getOnStartContentIntentHelper() { |
205 return mTestContentViewClient.getOnStartContentIntentHelper(); | 206 return mTestContentViewClient.getOnStartContentIntentHelper(); |
206 } | 207 } |
207 } | 208 } |
OLD | NEW |