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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/ModalDialogTest.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, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.content.DialogInterface; 7 import android.content.DialogInterface;
8 import android.support.v7.app.AlertDialog; 8 import android.support.v7.app.AlertDialog;
9 import android.test.suitebuilder.annotation.MediumTest; 9 import android.test.suitebuilder.annotation.MediumTest;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return "Suppress checkbox is not visible."; 257 return "Suppress checkbox is not visible.";
258 } 258 }
259 suppress.setChecked(true); 259 suppress.setChecked(true);
260 return null; 260 return null;
261 } 261 }
262 }); 262 });
263 assertNull(errorMessage, errorMessage); 263 assertNull(errorMessage, errorMessage);
264 clickCancel(jsDialog); 264 clickCancel(jsDialog);
265 scriptEvent.waitUntilHasValue(); 265 scriptEvent.waitUntilHasValue();
266 266
267 scriptEvent.evaluateJavaScriptForTests( 267 scriptEvent.evaluateJavaScript(getActivity().getCurrentContentViewCore() .getWebContents(),
268 getActivity().getCurrentContentViewCore().getWebContents(),
269 "alert('Android');"); 268 "alert('Android');");
270 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU ntilHasValue()); 269 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU ntilHasValue());
271 } 270 }
272 271
273 /** 272 /**
274 * Displays a dialog and closes the tab in the background before attempting 273 * Displays a dialog and closes the tab in the background before attempting
275 * to accept the dialog. Verifies that the dialog is dismissed when the tab 274 * to accept the dialog. Verifies that the dialog is dismissed when the tab
276 * is closed. 275 * is closed.
277 */ 276 */
278 @MediumTest 277 @MediumTest
(...skipping 25 matching lines...) Expand all
304 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH elper(), script); 303 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH elper(), script);
305 } 304 }
306 305
307 /** 306 /**
308 * Given a JavaScript evaluation helper, asynchronously executes the given 307 * Given a JavaScript evaluation helper, asynchronously executes the given
309 * code for spawning a dialog and waits for the dialog to be visible. 308 * code for spawning a dialog and waits for the dialog to be visible.
310 */ 309 */
311 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog( 310 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog(
312 final OnEvaluateJavaScriptResultHelper helper, String script) 311 final OnEvaluateJavaScriptResultHelper helper, String script)
313 throws InterruptedException { 312 throws InterruptedException {
314 helper.evaluateJavaScriptForTests( 313 helper.evaluateJavaScript(getActivity().getCurrentContentViewCore().getW ebContents(),
315 getActivity().getCurrentContentViewCore().getWebContents(),
316 script); 314 script);
317 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria( 315 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria(
318 new JavascriptAppModalDialogShownCriteria(true)); 316 new JavascriptAppModalDialogShownCriteria(true));
319 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie d); 317 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie d);
320 return helper; 318 return helper;
321 } 319 }
322 320
323 /** 321 /**
324 * Returns an array of the 3 buttons for this dialog, in the order 322 * Returns an array of the 3 buttons for this dialog, in the order
325 * BUTTON_NEGATIVE, BUTTON_NEUTRAL and BUTTON_POSITIVE. Any of these values 323 * BUTTON_NEGATIVE, BUTTON_NEUTRAL and BUTTON_POSITIVE. Any of these values
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 button.getVisibility()); 408 button.getVisibility());
411 assertEquals("'" + readableName + "' button has wrong text", 409 assertEquals("'" + readableName + "' button has wrong text",
412 getActivity().getResources().getString(expectedTextResourceId), 410 getActivity().getResources().getString(expectedTextResourceId),
413 button.getText().toString()); 411 button.getText().toString());
414 } 412 }
415 413
416 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer( ) { 414 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer( ) {
417 return new TestCallbackHelperContainer(getActivity().getCurrentContentVi ewCore()); 415 return new TestCallbackHelperContainer(getActivity().getCurrentContentVi ewCore());
418 } 416 }
419 } 417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698