Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / apps / web_view_browsertest.cc
index 48e180a..bd154fe 100644 (file)
 #include "net/test/embedded_test_server/http_response.h"
 #include "ui/gl/gl_switches.h"
 
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
+#include "chrome/browser/chromeos/accessibility/speech_monitor.h"
+#endif
+
 // For fine-grained suppression on flaky tests.
 #if defined(OS_WIN)
 #include "base/win/windows_version.h"
@@ -515,7 +520,7 @@ class WebViewTest : public extensions::PlatformAppBrowserTest {
     content::RunAllPendingInMessageLoop();
 
     content::WebContents* embedder_web_contents =
-        GetFirstShellWindowWebContents();
+        GetFirstAppWindowWebContents();
     if (!embedder_web_contents) {
       LOG(ERROR) << "UNABLE TO FIND EMBEDDER WEB CONTENTS.";
       return;
@@ -572,7 +577,7 @@ class WebViewTest : public extensions::PlatformAppBrowserTest {
     ASSERT_TRUE(loaded_listener.WaitUntilSatisfied());
 
     content::WebContents* embedder_web_contents =
-        GetFirstShellWindowWebContents();
+        GetFirstAppWindowWebContents();
     ASSERT_TRUE(embedder_web_contents);
 
     ExtensionTestMessageListener test_run_listener("PASSED", false);
@@ -633,7 +638,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, AutoSize) {
 // This test ensures <webview> doesn't crash in SW rendering when autosize is
 // turned on.
 // Flaky on Windows http://crbug.com/299507
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_MACOSX)
 #define MAYBE_AutoSizeSW DISABLED_AutoSizeSW
 #else
 #define MAYBE_AutoSizeSW AutoSizeSW
@@ -901,8 +906,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestRemoveWebviewOnExit) {
   LoadAndLaunchPlatformApp("web_view/shim");
   ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
 
-  content::WebContents* embedder_web_contents =
-      GetFirstShellWindowWebContents();
+  content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
   ASSERT_TRUE(embedder_web_contents);
 
   GURL::Replacements replace_host;
@@ -993,8 +997,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, InterstitialTeardown) {
       SetBrowserClientForTesting(&new_client);
 
   // Now load the guest.
-  content::WebContents* embedder_web_contents =
-      GetFirstShellWindowWebContents();
+  content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
   ExtensionTestMessageListener second("GuestAddedToDom", false);
   EXPECT_TRUE(content::ExecuteScript(
       embedder_web_contents,
@@ -1008,7 +1011,7 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, InterstitialTeardown) {
   WaitForInterstitial(guest_web_contents);
 
   // Now close the app while interstitial page being shown in guest.
-  apps::ShellWindow* window = GetFirstShellWindow();
+  apps::AppWindow* window = GetFirstAppWindow();
   window->GetBaseWindow()->Close();
 }
 
@@ -1017,16 +1020,6 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) {
       << message_;
 }
 
-// Disabled on Windows for flaky failures: crbug.com/329032
-#if defined(OS_WIN)
-#define MAYBE_Size DISABLED_Size
-#else
-#define MAYBE_Size Size
-#endif
-IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_Size) {
-  ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/size")) << message_;
-}
-
 // This test verifies that prerendering has been disabled inside <webview>.
 // This test is here rather than in PrerenderBrowserTest for testing convenience
 // only. If it breaks then this is a bug in the prerenderer.
@@ -1495,8 +1488,7 @@ void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) {
   LoadAndLaunchPlatformApp("web_view/media_access/allow");
   ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
 
-  content::WebContents* embedder_web_contents =
-      GetFirstShellWindowWebContents();
+  content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
   ASSERT_TRUE(embedder_web_contents);
   MockWebContentsDelegate* mock = new MockWebContentsDelegate;
   embedder_web_contents->SetDelegate(mock);
@@ -1555,6 +1547,26 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, SpeechRecognition) {
   EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
 }
 
+#if defined(OS_CHROMEOS)
+IN_PROC_BROWSER_TEST_F(WebViewTest, ChromeVoxInjection) {
+  EXPECT_FALSE(
+      chromeos::AccessibilityManager::Get()->IsSpokenFeedbackEnabled());
+
+  ASSERT_TRUE(StartEmbeddedTestServer());
+  content::WebContents* guest_web_contents = LoadGuest(
+      "/extensions/platform_apps/web_view/chromevox_injection/guest.html",
+      "web_view/chromevox_injection");
+  ASSERT_TRUE(guest_web_contents);
+
+  chromeos::SpeechMonitor monitor;
+  chromeos::AccessibilityManager::Get()->EnableSpokenFeedback(
+      true, ash::A11Y_NOTIFICATION_NONE);
+  EXPECT_TRUE(monitor.SkipChromeVoxEnabledMessage());
+
+  EXPECT_EQ("chrome vox test title", monitor.GetNextUtterance());
+}
+#endif
+
 // Flaky on Windows. http://crbug.com/303966
 #if defined(OS_WIN)
 #define MAYBE_TearDownTest DISABLED_TearDownTest
@@ -1566,12 +1578,12 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) {
   const extensions::Extension* extension =
       LoadAndLaunchPlatformApp("web_view/teardown");
   ASSERT_TRUE(first_loaded_listener.WaitUntilSatisfied());
-  apps::ShellWindow* window = NULL;
-  if (!GetShellWindowCount())
-    window = CreateShellWindow(extension);
+  apps::AppWindow* window = NULL;
+  if (!GetAppWindowCount())
+    window = CreateAppWindow(extension);
   else
-    window = GetFirstShellWindow();
-  CloseShellWindow(window);
+    window = GetFirstAppWindow();
+  CloseAppWindow(window);
 
   // Load the app again.
   ExtensionTestMessageListener second_loaded_listener("guest-loaded", false);
@@ -1863,16 +1875,14 @@ class WebViewCaptureTest : public WebViewTest,
   }
 };
 
-#if defined(USE_AURA) && defined(OS_LINUX)
-// Keeps failing on LinuxAura try server, tentatively disable this
-// so that CQ becomes sane.
-// crbug.com/330146
-#define MAYBE_Shim_ScreenshotCapture DISABLED_Shim_ScreenshotCapture
-#else
-#define MAYBE_Shim_ScreenshotCapture Shim_ScreenshotCapture
-#endif
+IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestZoomAPI) {
+  TestHelper("testZoomAPI", "web_view/shim", NO_TEST_SERVER);
+}
+
+// <webview> screenshot capture fails with ubercomp.
+// See http://crbug.com/327035.
 IN_PROC_BROWSER_TEST_P(WebViewCaptureTest,
-                       MAYBE_Shim_ScreenshotCapture) {
+                       DISABLED_Shim_ScreenshotCapture) {
   TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER);
 }