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

Side by Side Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/TestCallbackHelperContainer.java

Issue 1257603003: Revert of Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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 import org.chromium.content_public.browser.JavaScriptCallback;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 * synchronously evaluate JavaScript and then test the result. 119 * synchronously evaluate JavaScript and then test the result.
120 */ 120 */
121 public static class OnEvaluateJavaScriptResultHelper extends CallbackHelper { 121 public static class OnEvaluateJavaScriptResultHelper extends CallbackHelper {
122 private String mJsonResult; 122 private String mJsonResult;
123 123
124 /** 124 /**
125 * Starts evaluation of a given JavaScript code on a given webContents. 125 * Starts evaluation of a given JavaScript code on a given webContents.
126 * @param webContents A WebContents instance to be used. 126 * @param webContents A WebContents instance to be used.
127 * @param code A JavaScript code to be evaluated. 127 * @param code A JavaScript code to be evaluated.
128 */ 128 */
129 public void evaluateJavaScriptForTests(WebContents webContents, String c ode) { 129 public void evaluateJavaScript(WebContents webContents, String code) {
130 JavaScriptCallback callback = 130 JavaScriptCallback callback =
131 new JavaScriptCallback() { 131 new JavaScriptCallback() {
132 @Override 132 @Override
133 public void handleJavaScriptResult(String jsonResult) { 133 public void handleJavaScriptResult(String jsonResult) {
134 notifyCalled(jsonResult); 134 notifyCalled(jsonResult);
135 } 135 }
136 }; 136 };
137 webContents.evaluateJavaScriptForTests(code, callback); 137 webContents.evaluateJavaScript(code, callback);
138 mJsonResult = null; 138 mJsonResult = null;
139 } 139 }
140 140
141 /** 141 /**
142 * Returns true if the evaluation started by evaluateJavaScriptForTests( ) has completed. 142 * Returns true if the evaluation started by evaluateJavaScript() has co mpleted.
143 */ 143 */
144 public boolean hasValue() { 144 public boolean hasValue() {
145 return mJsonResult != null; 145 return mJsonResult != null;
146 } 146 }
147 147
148 /** 148 /**
149 * Returns the JSON result of a previously completed JavaScript evaluati on and 149 * Returns the JSON result of a previously completed JavaScript evaluati on and
150 * resets the helper to accept new evaluations. 150 * resets the helper to accept new evaluations.
151 * @return String JSON result of a previously completed JavaScript evalu ation. 151 * @return String JSON result of a previously completed JavaScript evalu ation.
152 */ 152 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 public OnReceivedErrorHelper getOnReceivedErrorHelper() { 218 public OnReceivedErrorHelper getOnReceivedErrorHelper() {
219 return mTestWebContentsObserver.getOnReceivedErrorHelper(); 219 return mTestWebContentsObserver.getOnReceivedErrorHelper();
220 } 220 }
221 221
222 public OnStartContentIntentHelper getOnStartContentIntentHelper() { 222 public OnStartContentIntentHelper getOnStartContentIntentHelper() {
223 return mTestContentViewClient.getOnStartContentIntentHelper(); 223 return mTestContentViewClient.getOnStartContentIntentHelper();
224 } 224 }
225 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698