| OLD | NEW |
| 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 Loading... |
| 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.evaluateJavaScript(getActivity().getCurrentContentViewCore()
.getWebContents(), | 267 scriptEvent.evaluateJavaScriptForTests( |
| 268 getActivity().getCurrentContentViewCore().getWebContents(), |
| 268 "alert('Android');"); | 269 "alert('Android');"); |
| 269 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU
ntilHasValue()); | 270 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU
ntilHasValue()); |
| 270 } | 271 } |
| 271 | 272 |
| 272 /** | 273 /** |
| 273 * Displays a dialog and closes the tab in the background before attempting | 274 * Displays a dialog and closes the tab in the background before attempting |
| 274 * to accept the dialog. Verifies that the dialog is dismissed when the tab | 275 * to accept the dialog. Verifies that the dialog is dismissed when the tab |
| 275 * is closed. | 276 * is closed. |
| 276 */ | 277 */ |
| 277 @MediumTest | 278 @MediumTest |
| (...skipping 25 matching lines...) Expand all Loading... |
| 303 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH
elper(), script); | 304 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH
elper(), script); |
| 304 } | 305 } |
| 305 | 306 |
| 306 /** | 307 /** |
| 307 * Given a JavaScript evaluation helper, asynchronously executes the given | 308 * Given a JavaScript evaluation helper, asynchronously executes the given |
| 308 * code for spawning a dialog and waits for the dialog to be visible. | 309 * code for spawning a dialog and waits for the dialog to be visible. |
| 309 */ | 310 */ |
| 310 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog( | 311 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog( |
| 311 final OnEvaluateJavaScriptResultHelper helper, String script) | 312 final OnEvaluateJavaScriptResultHelper helper, String script) |
| 312 throws InterruptedException { | 313 throws InterruptedException { |
| 313 helper.evaluateJavaScript(getActivity().getCurrentContentViewCore().getW
ebContents(), | 314 helper.evaluateJavaScriptForTests( |
| 315 getActivity().getCurrentContentViewCore().getWebContents(), |
| 314 script); | 316 script); |
| 315 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria( | 317 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria( |
| 316 new JavascriptAppModalDialogShownCriteria(true)); | 318 new JavascriptAppModalDialogShownCriteria(true)); |
| 317 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie
d); | 319 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie
d); |
| 318 return helper; | 320 return helper; |
| 319 } | 321 } |
| 320 | 322 |
| 321 /** | 323 /** |
| 322 * Returns an array of the 3 buttons for this dialog, in the order | 324 * Returns an array of the 3 buttons for this dialog, in the order |
| 323 * BUTTON_NEGATIVE, BUTTON_NEUTRAL and BUTTON_POSITIVE. Any of these values | 325 * BUTTON_NEGATIVE, BUTTON_NEUTRAL and BUTTON_POSITIVE. Any of these values |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 button.getVisibility()); | 410 button.getVisibility()); |
| 409 assertEquals("'" + readableName + "' button has wrong text", | 411 assertEquals("'" + readableName + "' button has wrong text", |
| 410 getActivity().getResources().getString(expectedTextResourceId), | 412 getActivity().getResources().getString(expectedTextResourceId), |
| 411 button.getText().toString()); | 413 button.getText().toString()); |
| 412 } | 414 } |
| 413 | 415 |
| 414 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer(
) { | 416 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer(
) { |
| 415 return new TestCallbackHelperContainer(getActivity().getCurrentContentVi
ewCore()); | 417 return new TestCallbackHelperContainer(getActivity().getCurrentContentVi
ewCore()); |
| 416 } | 418 } |
| 417 } | 419 } |
| OLD | NEW |