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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread_restrictions.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "components/guest_view/browser/guest_view_manager.h" | 16 #include "components/guest_view/browser/guest_view_manager.h" |
16 #include "components/guest_view/browser/guest_view_manager_delegate.h" | 17 #include "components/guest_view/browser/guest_view_manager_delegate.h" |
17 #include "components/guest_view/browser/guest_view_manager_factory.h" | 18 #include "components/guest_view/browser/guest_view_manager_factory.h" |
18 #include "components/guest_view/browser/test_guest_view_manager.h" | 19 #include "components/guest_view/browser/test_guest_view_manager.h" |
19 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/test_renderer_host.h" | 23 #include "content/public/test/test_renderer_host.h" |
23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 132 |
132 } // namespace | 133 } // namespace |
133 | 134 |
134 namespace extensions { | 135 namespace extensions { |
135 | 136 |
136 WebViewAPITest::WebViewAPITest() { | 137 WebViewAPITest::WebViewAPITest() { |
137 GuestViewManager::set_factory_for_testing(&factory_); | 138 GuestViewManager::set_factory_for_testing(&factory_); |
138 } | 139 } |
139 | 140 |
140 void WebViewAPITest::LaunchApp(const std::string& app_location) { | 141 void WebViewAPITest::LaunchApp(const std::string& app_location) { |
| 142 base::ThreadRestrictions::ScopedAllowIO allow_io; |
141 base::FilePath test_data_dir; | 143 base::FilePath test_data_dir; |
142 PathService::Get(DIR_TEST_DATA, &test_data_dir); | 144 PathService::Get(DIR_TEST_DATA, &test_data_dir); |
143 test_data_dir = test_data_dir.AppendASCII(app_location.c_str()); | 145 test_data_dir = test_data_dir.AppendASCII(app_location.c_str()); |
144 | 146 |
145 test_config_.SetString(kTestDataDirectory, | 147 test_config_.SetString(kTestDataDirectory, |
146 net::FilePathToFileURL(test_data_dir).spec()); | 148 net::FilePathToFileURL(test_data_dir).spec()); |
147 | 149 |
148 const Extension* extension = extension_system_->LoadApp(test_data_dir); | 150 const Extension* extension = extension_system_->LoadApp(test_data_dir); |
149 ASSERT_TRUE(extension); | 151 ASSERT_TRUE(extension); |
150 extension_system_->LaunchApp(extension->id()); | 152 extension_system_->LaunchApp(extension->id()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 198 |
197 void WebViewAPITest::StartTestServer(const std::string& app_location) { | 199 void WebViewAPITest::StartTestServer(const std::string& app_location) { |
198 // For serving guest pages. | 200 // For serving guest pages. |
199 if (!embedded_test_server()->InitializeAndListen()) { | 201 if (!embedded_test_server()->InitializeAndListen()) { |
200 LOG(ERROR) << "Failed to start test server."; | 202 LOG(ERROR) << "Failed to start test server."; |
201 return; | 203 return; |
202 } | 204 } |
203 | 205 |
204 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port()); | 206 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port()); |
205 | 207 |
| 208 base::ThreadRestrictions::ScopedAllowIO allow_io; |
206 base::FilePath test_data_dir; | 209 base::FilePath test_data_dir; |
207 PathService::Get(DIR_TEST_DATA, &test_data_dir); | 210 PathService::Get(DIR_TEST_DATA, &test_data_dir); |
208 test_data_dir = test_data_dir.AppendASCII(app_location.c_str()); | 211 test_data_dir = test_data_dir.AppendASCII(app_location.c_str()); |
209 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 212 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
210 | 213 |
211 embedded_test_server()->RegisterRequestHandler( | 214 embedded_test_server()->RegisterRequestHandler( |
212 base::Bind(&RedirectResponseHandler, | 215 base::Bind(&RedirectResponseHandler, |
213 kRedirectResponsePath, | 216 kRedirectResponsePath, |
214 embedded_test_server()->GetURL(kRedirectResponseFullPath))); | 217 embedded_test_server()->GetURL(kRedirectResponseFullPath))); |
215 | 218 |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 // This test verifies that webview.contentWindow works inside an iframe | 766 // This test verifies that webview.contentWindow works inside an iframe |
764 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 767 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
765 LaunchApp("web_view/inside_iframe"); | 768 LaunchApp("web_view/inside_iframe"); |
766 } | 769 } |
767 | 770 |
768 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { | 771 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { |
769 RunTest("testCaptureVisibleRegion", "web_view/apitest"); | 772 RunTest("testCaptureVisibleRegion", "web_view/apitest"); |
770 } | 773 } |
771 | 774 |
772 } // namespace extensions | 775 } // namespace extensions |
OLD | NEW |