| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_apitest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/test/test_renderer_host.h" | 22 #include "content/public/test/test_renderer_host.h" |
| 23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
| 24 #include "extensions/browser/api/extensions_api_client.h" | 24 #include "extensions/browser/api/extensions_api_client.h" |
| 25 #include "extensions/browser/api/test/test_api.h" | 25 #include "extensions/browser/api/test/test_api.h" |
| 26 #include "extensions/browser/app_window/app_window.h" | 26 #include "extensions/browser/app_window/app_window.h" |
| 27 #include "extensions/browser/app_window/app_window_registry.h" | 27 #include "extensions/browser/app_window/app_window_registry.h" |
| 28 #include "extensions/browser/process_manager.h" | 28 #include "extensions/browser/process_manager.h" |
| 29 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| 30 #include "extensions/common/extension_paths.h" | 30 #include "extensions/common/extension_paths.h" |
| 31 #include "extensions/common/switches.h" | 31 #include "extensions/common/switches.h" |
| 32 #include "extensions/shell/browser/desktop_controller.h" |
| 32 #include "extensions/shell/browser/shell_content_browser_client.h" | 33 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 33 #include "extensions/shell/browser/shell_extension_system.h" | 34 #include "extensions/shell/browser/shell_extension_system.h" |
| 34 #include "extensions/shell/test/shell_test.h" | 35 #include "extensions/shell/test/shell_test.h" |
| 35 #include "extensions/test/extension_test_message_listener.h" | 36 #include "extensions/test/extension_test_message_listener.h" |
| 36 #include "net/base/filename_util.h" | 37 #include "net/base/filename_util.h" |
| 37 #include "net/test/embedded_test_server/embedded_test_server.h" | 38 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 38 #include "net/test/embedded_test_server/http_request.h" | 39 #include "net/test/embedded_test_server/http_request.h" |
| 39 #include "net/test/embedded_test_server/http_response.h" | 40 #include "net/test/embedded_test_server/http_response.h" |
| 40 #include "ui/display/display_switches.h" | 41 #include "ui/display/display_switches.h" |
| 41 | 42 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 ExtensionTestMessageListener done_listener("TEST_PASSED", false); | 170 ExtensionTestMessageListener done_listener("TEST_PASSED", false); |
| 170 done_listener.set_failure_message("TEST_FAILED"); | 171 done_listener.set_failure_message("TEST_FAILED"); |
| 171 ASSERT_TRUE(content::ExecuteScript( | 172 ASSERT_TRUE(content::ExecuteScript( |
| 172 embedder_web_contents_, | 173 embedder_web_contents_, |
| 173 base::StringPrintf("runTest('%s')", test_name.c_str()))) | 174 base::StringPrintf("runTest('%s')", test_name.c_str()))) |
| 174 << "Unable to start test."; | 175 << "Unable to start test."; |
| 175 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); | 176 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void WebViewAPITest::RunTestOnMainThreadLoop() { | |
| 179 AppShellTest::RunTestOnMainThreadLoop(); | |
| 180 GetGuestViewManager()->WaitForAllGuestsDeleted(); | |
| 181 } | |
| 182 | |
| 183 void WebViewAPITest::SetUpCommandLine(base::CommandLine* command_line) { | 179 void WebViewAPITest::SetUpCommandLine(base::CommandLine* command_line) { |
| 184 AppShellTest::SetUpCommandLine(command_line); | 180 AppShellTest::SetUpCommandLine(command_line); |
| 185 command_line->AppendSwitchASCII(::switches::kJavaScriptFlags, "--expose-gc"); | 181 command_line->AppendSwitchASCII(::switches::kJavaScriptFlags, "--expose-gc"); |
| 186 } | 182 } |
| 187 | 183 |
| 188 void WebViewAPITest::SetUpOnMainThread() { | 184 void WebViewAPITest::SetUpOnMainThread() { |
| 189 AppShellTest::SetUpOnMainThread(); | 185 AppShellTest::SetUpOnMainThread(); |
| 190 | 186 |
| 191 TestGetConfigFunction::set_test_config_state(&test_config_); | 187 TestGetConfigFunction::set_test_config_state(&test_config_); |
| 192 base::FilePath test_data_dir; | 188 base::FilePath test_data_dir; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 embedded_test_server()->StartAcceptingConnections(); | 225 embedded_test_server()->StartAcceptingConnections(); |
| 230 } | 226 } |
| 231 | 227 |
| 232 void WebViewAPITest::StopTestServer() { | 228 void WebViewAPITest::StopTestServer() { |
| 233 if (!embedded_test_server()->ShutdownAndWaitUntilComplete()) { | 229 if (!embedded_test_server()->ShutdownAndWaitUntilComplete()) { |
| 234 LOG(ERROR) << "Failed to shutdown test server."; | 230 LOG(ERROR) << "Failed to shutdown test server."; |
| 235 } | 231 } |
| 236 } | 232 } |
| 237 | 233 |
| 238 void WebViewAPITest::TearDownOnMainThread() { | 234 void WebViewAPITest::TearDownOnMainThread() { |
| 235 DesktopController::instance()->CloseAppWindows(); |
| 236 GetGuestViewManager()->WaitForAllGuestsDeleted(); |
| 239 TestGetConfigFunction::set_test_config_state(nullptr); | 237 TestGetConfigFunction::set_test_config_state(nullptr); |
| 240 | 238 |
| 241 AppShellTest::TearDownOnMainThread(); | 239 AppShellTest::TearDownOnMainThread(); |
| 242 } | 240 } |
| 243 | 241 |
| 244 void WebViewAPITest::SendMessageToEmbedder(const std::string& message) { | 242 void WebViewAPITest::SendMessageToEmbedder(const std::string& message) { |
| 245 EXPECT_TRUE( | 243 EXPECT_TRUE( |
| 246 content::ExecuteScript( | 244 content::ExecuteScript( |
| 247 GetEmbedderWebContents(), | 245 GetEmbedderWebContents(), |
| 248 base::StringPrintf("onAppCommand('%s');", message.c_str()))); | 246 base::StringPrintf("onAppCommand('%s');", message.c_str()))); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 // This test verifies that webview.contentWindow works inside an iframe | 763 // This test verifies that webview.contentWindow works inside an iframe |
| 766 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 764 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
| 767 LaunchApp("web_view/inside_iframe"); | 765 LaunchApp("web_view/inside_iframe"); |
| 768 } | 766 } |
| 769 | 767 |
| 770 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { | 768 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { |
| 771 RunTest("testCaptureVisibleRegion", "web_view/apitest"); | 769 RunTest("testCaptureVisibleRegion", "web_view/apitest"); |
| 772 } | 770 } |
| 773 | 771 |
| 774 } // namespace extensions | 772 } // namespace extensions |
| OLD | NEW |