| 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 #include "apps/ui/native_app_window.h" | 5 #include "apps/ui/native_app_window.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/browser/gpu_data_manager.h" | 23 #include "content/public/browser/gpu_data_manager.h" |
| 24 #include "content/public/browser/interstitial_page.h" | 24 #include "content/public/browser/interstitial_page.h" |
| 25 #include "content/public/browser/interstitial_page_delegate.h" | 25 #include "content/public/browser/interstitial_page_delegate.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
| 29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 30 #include "content/public/test/browser_test_utils.h" | 30 #include "content/public/test/browser_test_utils.h" |
| 31 #include "content/public/test/fake_speech_recognition_manager.h" | 31 #include "content/public/test/fake_speech_recognition_manager.h" |
| 32 #include "content/public/test/test_renderer_host.h" |
| 32 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
| 33 #include "extensions/common/extensions_client.h" | 34 #include "extensions/common/extensions_client.h" |
| 34 #include "net/test/embedded_test_server/embedded_test_server.h" | 35 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 35 #include "net/test/embedded_test_server/http_request.h" | 36 #include "net/test/embedded_test_server/http_request.h" |
| 36 #include "net/test/embedded_test_server/http_response.h" | 37 #include "net/test/embedded_test_server/http_response.h" |
| 37 #include "ui/gl/gl_switches.h" | 38 #include "ui/gl/gl_switches.h" |
| 38 | 39 |
| 39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 40 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 41 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 41 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" | 42 #include "chrome/browser/chromeos/accessibility/speech_monitor.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 SetBrowserClientForTesting(old_client); | 668 SetBrowserClientForTesting(old_client); |
| 668 } | 669 } |
| 669 | 670 |
| 670 void SendMessageToEmbedder(const std::string& message) { | 671 void SendMessageToEmbedder(const std::string& message) { |
| 671 EXPECT_TRUE( | 672 EXPECT_TRUE( |
| 672 content::ExecuteScript( | 673 content::ExecuteScript( |
| 673 GetEmbedderWebContents(), | 674 GetEmbedderWebContents(), |
| 674 base::StringPrintf("onAppCommand('%s');", message.c_str()))); | 675 base::StringPrintf("onAppCommand('%s');", message.c_str()))); |
| 675 } | 676 } |
| 676 | 677 |
| 678 void SendMessageToGuestAndWait(const std::string& message, |
| 679 const std::string& wait_message) { |
| 680 scoped_ptr<ExtensionTestMessageListener> listener; |
| 681 if (!wait_message.empty()) { |
| 682 listener.reset(new ExtensionTestMessageListener(wait_message, false)); |
| 683 } |
| 684 |
| 685 EXPECT_TRUE( |
| 686 content::ExecuteScript( |
| 687 GetGuestWebContents(), |
| 688 base::StringPrintf("onAppCommand('%s');", message.c_str()))); |
| 689 |
| 690 if (listener) { |
| 691 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
| 692 } |
| 693 } |
| 694 |
| 677 content::WebContents* GetGuestWebContents() { | 695 content::WebContents* GetGuestWebContents() { |
| 678 return guest_web_contents_; | 696 return guest_web_contents_; |
| 679 } | 697 } |
| 680 | 698 |
| 681 content::WebContents* GetEmbedderWebContents() { | 699 content::WebContents* GetEmbedderWebContents() { |
| 682 if (!embedder_web_contents_) { | 700 if (!embedder_web_contents_) { |
| 683 embedder_web_contents_ = GetFirstAppWindowWebContents(); | 701 embedder_web_contents_ = GetFirstAppWindowWebContents(); |
| 684 } | 702 } |
| 685 return embedder_web_contents_; | 703 return embedder_web_contents_; |
| 686 } | 704 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 new content::MessageLoopRunner); | 748 new content::MessageLoopRunner); |
| 731 WebContentsHiddenObserver observer(GetGuestWebContents(), | 749 WebContentsHiddenObserver observer(GetGuestWebContents(), |
| 732 loop_runner->QuitClosure()); | 750 loop_runner->QuitClosure()); |
| 733 | 751 |
| 734 // Handled in platform_apps/web_view/visibility_changed/main.js | 752 // Handled in platform_apps/web_view/visibility_changed/main.js |
| 735 SendMessageToEmbedder("hide-embedder"); | 753 SendMessageToEmbedder("hide-embedder"); |
| 736 if (!observer.hidden_observed()) | 754 if (!observer.hidden_observed()) |
| 737 loop_runner->Run(); | 755 loop_runner->Run(); |
| 738 } | 756 } |
| 739 | 757 |
| 758 IN_PROC_BROWSER_TEST_F(WebViewTest, AcceptTouchEvents) { |
| 759 LoadAppWithGuest("web_view/accept_touch_events"); |
| 760 |
| 761 content::RenderViewHost* embedder_rvh = |
| 762 GetEmbedderWebContents()->GetRenderViewHost(); |
| 763 |
| 764 bool embedder_has_touch_handler = |
| 765 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh); |
| 766 EXPECT_FALSE(embedder_has_touch_handler); |
| 767 |
| 768 SendMessageToGuestAndWait("install-touch-handler", "installed-touch-handler"); |
| 769 |
| 770 // Note that we need to wait for the installed/registered touch handler to |
| 771 // appear in browser process before querying |embedder_rvh|. |
| 772 // In practice, since we do a roundrtip from browser process to guest and |
| 773 // back, this is sufficient. |
| 774 embedder_has_touch_handler = |
| 775 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh); |
| 776 EXPECT_TRUE(embedder_has_touch_handler); |
| 777 |
| 778 SendMessageToGuestAndWait("uninstall-touch-handler", |
| 779 "uninstalled-touch-handler"); |
| 780 // Same as the note above about waiting. |
| 781 embedder_has_touch_handler = |
| 782 content::RenderViewHostTester::HasTouchEventHandler(embedder_rvh); |
| 783 EXPECT_FALSE(embedder_has_touch_handler); |
| 784 } |
| 785 |
| 740 // This test ensures JavaScript errors ("Cannot redefine property") do not | 786 // This test ensures JavaScript errors ("Cannot redefine property") do not |
| 741 // happen when a <webview> is removed from DOM and added back. | 787 // happen when a <webview> is removed from DOM and added back. |
| 742 IN_PROC_BROWSER_TEST_F(WebViewTest, | 788 IN_PROC_BROWSER_TEST_F(WebViewTest, |
| 743 AddRemoveWebView_AddRemoveWebView) { | 789 AddRemoveWebView_AddRemoveWebView) { |
| 744 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 790 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 745 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/addremove")) | 791 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/addremove")) |
| 746 << message_; | 792 << message_; |
| 747 } | 793 } |
| 748 | 794 |
| 749 IN_PROC_BROWSER_TEST_F(WebViewTest, AutoSize) { | 795 IN_PROC_BROWSER_TEST_F(WebViewTest, AutoSize) { |
| (...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI_findupdate) { | 2124 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI_findupdate) { |
| 2079 TestHelper("testFindAPI_findupdate", "web_view/shim", NO_TEST_SERVER); | 2125 TestHelper("testFindAPI_findupdate", "web_view/shim", NO_TEST_SERVER); |
| 2080 } | 2126 } |
| 2081 | 2127 |
| 2082 // <webview> screenshot capture fails with ubercomp. | 2128 // <webview> screenshot capture fails with ubercomp. |
| 2083 // See http://crbug.com/327035. | 2129 // See http://crbug.com/327035. |
| 2084 IN_PROC_BROWSER_TEST_F(WebViewCaptureTest, | 2130 IN_PROC_BROWSER_TEST_F(WebViewCaptureTest, |
| 2085 DISABLED_Shim_ScreenshotCapture) { | 2131 DISABLED_Shim_ScreenshotCapture) { |
| 2086 TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER); | 2132 TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER); |
| 2087 } | 2133 } |
| OLD | NEW |