Chromium Code Reviews| 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 /** | 5 /** |
| 6 * Test suite for displaying and functioning of modal dialogs. | 6 * Test suite for displaying and functioning of modal dialogs. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 package org.chromium.android_webview.test; | 9 package org.chromium.android_webview.test; |
| 10 | 10 |
| 11 import android.support.test.filters.MediumTest; | 11 import android.support.test.filters.MediumTest; |
| 12 import android.support.test.filters.SmallTest; | 12 import android.support.test.filters.SmallTest; |
| 13 | 13 |
| 14 import org.chromium.android_webview.AwContents; | 14 import org.chromium.android_webview.AwContents; |
| 15 import org.chromium.android_webview.JsPromptResultReceiver; | 15 import org.chromium.android_webview.JsPromptResultReceiver; |
| 16 import org.chromium.android_webview.JsResultReceiver; | 16 import org.chromium.android_webview.JsResultReceiver; |
| 17 import org.chromium.android_webview.test.util.AwTestTouchUtils; | |
| 17 import org.chromium.base.test.util.CallbackHelper; | 18 import org.chromium.base.test.util.CallbackHelper; |
| 18 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
| 19 | 20 |
| 20 import java.util.concurrent.atomic.AtomicBoolean; | 21 import java.util.concurrent.atomic.AtomicBoolean; |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Tests for callbacks implementing JS alerts and prompts. | 24 * Tests for callbacks implementing JS alerts and prompts. |
| 24 */ | 25 */ |
| 25 public class WebViewModalDialogOverrideTest extends AwTestBase { | 26 public class WebViewModalDialogOverrideTest extends AwTestBase { |
| 26 private static final String EMPTY_PAGE = | 27 private static final String EMPTY_PAGE = |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 jsBeforeUnloadHelper.notifyCalled(); | 170 jsBeforeUnloadHelper.notifyCalled(); |
| 170 } | 171 } |
| 171 }; | 172 }; |
| 172 AwTestContainerView view = createAwTestContainerViewOnMainSync(client); | 173 AwTestContainerView view = createAwTestContainerViewOnMainSync(client); |
| 173 final AwContents awContents = view.getAwContents(); | 174 final AwContents awContents = view.getAwContents(); |
| 174 enableJavaScriptOnUiThread(awContents); | 175 enableJavaScriptOnUiThread(awContents); |
| 175 | 176 |
| 176 loadDataSync(awContents, client.getOnPageFinishedHelper(), BEFORE_UNLOAD _URL, | 177 loadDataSync(awContents, client.getOnPageFinishedHelper(), BEFORE_UNLOAD _URL, |
| 177 "text/html", false); | 178 "text/html", false); |
| 178 enableJavaScriptOnUiThread(awContents); | 179 enableJavaScriptOnUiThread(awContents); |
| 180 AwTestTouchUtils.simulateTouchCenterOfView(view); | |
|
boliu
2017/04/06 21:30:13
should write a comment explaining this?
Avi (use Gerrit)
2017/04/06 22:29:19
Done.
| |
| 179 | 181 |
| 180 // Don't wait synchronously because we don't leave the page. | 182 // Don't wait synchronously because we don't leave the page. |
| 181 int currentCallCount = jsBeforeUnloadHelper.getCallCount(); | 183 int currentCallCount = jsBeforeUnloadHelper.getCallCount(); |
| 182 loadDataAsync(awContents, EMPTY_PAGE, "text/html", false); | 184 loadDataAsync(awContents, EMPTY_PAGE, "text/html", false); |
| 183 jsBeforeUnloadHelper.waitForCallback(currentCallCount); | 185 jsBeforeUnloadHelper.waitForCallback(currentCallCount); |
| 184 } | 186 } |
| 185 } | 187 } |
| OLD | NEW |