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.test; | 5 package org.chromium.chrome.browser.test; |
6 | 6 |
7 import android.app.AlertDialog; | 7 import android.app.AlertDialog; |
8 import android.content.DialogInterface; | 8 import android.content.DialogInterface; |
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return "Suppress checkbox is not visible."; | 258 return "Suppress checkbox is not visible."; |
259 } | 259 } |
260 suppress.setChecked(true); | 260 suppress.setChecked(true); |
261 return null; | 261 return null; |
262 } | 262 } |
263 }); | 263 }); |
264 assertNull(errorMessage, errorMessage); | 264 assertNull(errorMessage, errorMessage); |
265 clickCancel(jsDialog); | 265 clickCancel(jsDialog); |
266 scriptEvent.waitUntilHasValue(); | 266 scriptEvent.waitUntilHasValue(); |
267 | 267 |
268 scriptEvent.evaluateJavaScript(getActivity().getActiveContentViewCore(), | 268 scriptEvent.evaluateJavaScript(getActivity().getActiveContentViewCore().
getWebContents(), |
269 "alert('Android');"); | 269 "alert('Android');"); |
270 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU
ntilHasValue()); | 270 assertTrue("No further dialog boxes should be shown.", scriptEvent.waitU
ntilHasValue()); |
271 } | 271 } |
272 | 272 |
273 /** | 273 /** |
274 * 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 |
275 * 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 |
276 * is closed. | 276 * is closed. |
277 */ | 277 */ |
278 @MediumTest | 278 @MediumTest |
(...skipping 24 matching lines...) Expand all Loading... |
303 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH
elper(), script); | 303 return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultH
elper(), script); |
304 } | 304 } |
305 | 305 |
306 /** | 306 /** |
307 * Given a JavaScript evaluation helper, asynchronously executes the given | 307 * Given a JavaScript evaluation helper, asynchronously executes the given |
308 * 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. |
309 */ | 309 */ |
310 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog( | 310 private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog( |
311 final OnEvaluateJavaScriptResultHelper helper, String script) | 311 final OnEvaluateJavaScriptResultHelper helper, String script) |
312 throws InterruptedException { | 312 throws InterruptedException { |
313 helper.evaluateJavaScript(getActivity().getActiveContentViewCore(), | 313 helper.evaluateJavaScript(getActivity().getActiveContentViewCore().getWe
bContents(), |
314 script); | 314 script); |
315 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria( | 315 boolean criteriaSatisfied = CriteriaHelper.pollForCriteria( |
316 new JavascriptAppModalDialogShownCriteria(true)); | 316 new JavascriptAppModalDialogShownCriteria(true)); |
317 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie
d); | 317 assertTrue("Could not spawn or locate a modal dialog.", criteriaSatisfie
d); |
318 return helper; | 318 return helper; |
319 } | 319 } |
320 | 320 |
321 /** | 321 /** |
322 * 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 |
323 * 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 Loading... |
408 button.getVisibility()); | 408 button.getVisibility()); |
409 assertEquals("'" + readableName + "' button has wrong text", | 409 assertEquals("'" + readableName + "' button has wrong text", |
410 getActivity().getResources().getString(expectedTextResourceId), | 410 getActivity().getResources().getString(expectedTextResourceId), |
411 button.getText().toString()); | 411 button.getText().toString()); |
412 } | 412 } |
413 | 413 |
414 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer(
) { | 414 private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer(
) { |
415 return new TestCallbackHelperContainer(getActivity().getActiveTab().getC
ontentViewCore()); | 415 return new TestCallbackHelperContainer(getActivity().getActiveTab().getC
ontentViewCore()); |
416 } | 416 } |
417 } | 417 } |
OLD | NEW |