Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / android / javatests / src / org / chromium / chrome / browser / test / ModalDialogTest.java
index beb56fd..38181b5 100644 (file)
@@ -1,4 +1,4 @@
-// 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.
 
@@ -18,9 +18,7 @@ import org.chromium.base.test.util.DisabledTest;
 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;
@@ -33,11 +31,11 @@ import java.util.concurrent.TimeoutException;
 /**
  * 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?';" +
@@ -46,7 +44,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        launchChromiumTestShellWithUrl(EMPTY_PAGE);
+        launchChromeShellWithUrl(EMPTY_PAGE);
         assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
     }
 
@@ -186,7 +184,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
                 "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();
@@ -200,7 +198,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
         int callCount = onPageLoaded.getCallCount();
         clickOk(jsDialog);
         onPageLoaded.waitForCallback(callCount);
-        assertEquals(EMPTY_PAGE, getActivity().getActiveContentView().getUrl());
+        assertEquals(EMPTY_PAGE, getActivity().getActiveContentViewCore().getUrl());
     }
 
     /**
@@ -265,7 +263,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
         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());
     }
@@ -277,20 +275,15 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
      */
     @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(
@@ -305,9 +298,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
      */
     private OnEvaluateJavaScriptResultHelper executeJavaScriptAndWaitForDialog(String script)
             throws InterruptedException {
-        final OnEvaluateJavaScriptResultHelper helper =
-                getActiveTabTestCallbackHelperContainer().getOnEvaluateJavaScriptResultHelper();
-        return executeJavaScriptAndWaitForDialog(helper, script);
+        return executeJavaScriptAndWaitForDialog(new OnEvaluateJavaScriptResultHelper(), script);
     }
 
     /**
@@ -317,7 +308,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
     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));
@@ -418,7 +409,7 @@ public class ModalDialogTest extends ChromiumTestShellTestBase {
                 button.getText().toString());
     }
 
-    private TestCallbackHelperContainerForTab getActiveTabTestCallbackHelperContainer() {
-        return TabShellTabUtils.getTestCallbackHelperContainer(getActivity().getActiveTab());
+    private TestCallbackHelperContainer getActiveTabTestCallbackHelperContainer() {
+        return new TestCallbackHelperContainer(getActivity().getActiveTab().getContentViewCore());
     }
 }