-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.JavascriptAppModalDialog;
-import org.chromium.chrome.testshell.ChromiumTestShellTestBase;
-import org.chromium.chrome.testshell.TabShellTabUtils;
-import org.chromium.chrome.testshell.TabShellTabUtils.TestCallbackHelperContainerForTab;
+import org.chromium.chrome.shell.ChromeShellTestBase;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
/**
* Test suite for displaying and functioning of modal dialogs.
*/
-public class ModalDialogTest extends ChromiumTestShellTestBase {
- private final static String TAG = "ModalDialogTest";
- private final static String EMPTY_PAGE = UrlUtils.encodeHtmlDataUri(
+public class ModalDialogTest extends ChromeShellTestBase {
+ private static final String TAG = "ModalDialogTest";
+ private static final String EMPTY_PAGE = UrlUtils.encodeHtmlDataUri(
"<html><title>Modal Dialog Test</title><p>Testcase.</p></title></html>");
- private final static String BEFORE_UNLOAD_URL = UrlUtils.encodeHtmlDataUri(
+ private static final String BEFORE_UNLOAD_URL = UrlUtils.encodeHtmlDataUri(
"<html>" +
"<head><script>window.onbeforeunload=function() {" +
"return 'Are you sure?';" +
@Override
public void setUp() throws Exception {
super.setUp();
- launchChromiumTestShellWithUrl(EMPTY_PAGE);
+ launchChromeShellWithUrl(EMPTY_PAGE);
assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
}
"Stay on this page");
clickCancel(jsDialog);
- assertEquals(BEFORE_UNLOAD_URL, getActivity().getActiveContentView().getUrl());
+ assertEquals(BEFORE_UNLOAD_URL, getActivity().getActiveContentViewCore().getUrl());
executeJavaScriptAndWaitForDialog("history.back();");
jsDialog = getCurrentDialog();
int callCount = onPageLoaded.getCallCount();
clickOk(jsDialog);
onPageLoaded.waitForCallback(callCount);
- assertEquals(EMPTY_PAGE, getActivity().getActiveContentView().getUrl());
+ assertEquals(EMPTY_PAGE, getActivity().getActiveContentViewCore().getUrl());
}
/**
clickCancel(jsDialog);
scriptEvent.waitUntilHasValue();
- scriptEvent.evaluateJavaScript(getActivity().getActiveContentView().getContentViewCore(),
+ scriptEvent.evaluateJavaScript(getActivity().getActiveContentViewCore(),
"alert('Android');");
assertTrue("No further dialog boxes should be shown.", scriptEvent.waitUntilHasValue());
}
*/
@MediumTest
@Feature({"Browser", "Main"})
- public void testDialogDismissedAfterClosingTab()
- throws InterruptedException, TimeoutException, ExecutionException {
+ public void testDialogDismissedAfterClosingTab() throws InterruptedException {
executeJavaScriptAndWaitForDialog("alert('Android')");
- final TestCallbackHelperContainerForTab.OnCloseTabHelper onTabClosed =
- getActiveTabTestCallbackHelperContainer().getOnCloseTabHelper();
- int callCount = onTabClosed.getCallCount();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
getActivity().createTab(EMPTY_PAGE);
}
});
- onTabClosed.waitForCallback(callCount);
// Closing the tab should have dismissed the dialog.
boolean criteriaSatisfied = CriteriaHelper.pollForCriteria(
*/
private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog(String script)
throws InterruptedException {
- final OnEvaluateJavaScriptResultHelper helper =
- getActiveTabTestCallbackHelperContainer().getOnEvaluateJavaScriptResultHelper();
- return executeJavaScriptAndWaitForDialog(helper, script);
+ return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultHelper(), script);
}
/**
private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog(
final OnEvaluateJavaScriptResultHelper helper, String script)
throws InterruptedException {
- helper.evaluateJavaScript(getActivity().getActiveContentView().getContentViewCore(),
+ helper.evaluateJavaScript(getActivity().getActiveContentViewCore(),
script);
boolean criteriaSatisfied = CriteriaHelper.pollForCriteria(
new JavascriptAppModalDialogShownCriteria(true));
button.getText().toString());
}
- private TestCallbackHelperContainerForTab getActiveTabTestCallbackHelperContainer() {
- return TabShellTabUtils.getTestCallbackHelperContainer(getActivity().getActiveTab());
+ private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer() {
+ return new TestCallbackHelperContainer(getActivity().getActiveTab().getContentViewCore());
}
}