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 "base/path_service.h" | 5 #include "base/path_service.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
10 #include "chrome/browser/prerender/prerender_link_manager.h" | 10 #include "chrome/browser/prerender/prerender_link_manager.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
78 const wchar_t library_name[] = L"ppapi_tests.dll"; | 78 const wchar_t library_name[] = L"ppapi_tests.dll"; |
79 #elif defined(OS_MACOSX) | 79 #elif defined(OS_MACOSX) |
80 const char library_name[] = "ppapi_tests.plugin"; | 80 const char library_name[] = "ppapi_tests.plugin"; |
81 #elif defined(OS_POSIX) | 81 #elif defined(OS_POSIX) |
82 const char library_name[] = "libppapi_tests.so"; | 82 const char library_name[] = "libppapi_tests.so"; |
83 #endif | 83 #endif |
84 | 84 |
85 class EmptyHttpResponse : public net::test_server::HttpResponse { | 85 class EmptyHttpResponse : public net::test_server::HttpResponse { |
86 public: | 86 public: |
87 virtual std::string ToResponseString() const OVERRIDE { | 87 virtual std::string ToResponseString() const override { |
88 return std::string(); | 88 return std::string(); |
89 } | 89 } |
90 }; | 90 }; |
91 | 91 |
92 class TestInterstitialPageDelegate : public content::InterstitialPageDelegate { | 92 class TestInterstitialPageDelegate : public content::InterstitialPageDelegate { |
93 public: | 93 public: |
94 TestInterstitialPageDelegate() { | 94 TestInterstitialPageDelegate() { |
95 } | 95 } |
96 virtual ~TestInterstitialPageDelegate() {} | 96 virtual ~TestInterstitialPageDelegate() {} |
97 virtual std::string GetHTMLContents() OVERRIDE { return std::string(); } | 97 virtual std::string GetHTMLContents() override { return std::string(); } |
98 }; | 98 }; |
99 | 99 |
100 class WebContentsHiddenObserver : public content::WebContentsObserver { | 100 class WebContentsHiddenObserver : public content::WebContentsObserver { |
101 public: | 101 public: |
102 WebContentsHiddenObserver(content::WebContents* web_contents, | 102 WebContentsHiddenObserver(content::WebContents* web_contents, |
103 const base::Closure& hidden_callback) | 103 const base::Closure& hidden_callback) |
104 : WebContentsObserver(web_contents), | 104 : WebContentsObserver(web_contents), |
105 hidden_callback_(hidden_callback), | 105 hidden_callback_(hidden_callback), |
106 hidden_observed_(false) { | 106 hidden_observed_(false) { |
107 } | 107 } |
108 | 108 |
109 // WebContentsObserver. | 109 // WebContentsObserver. |
110 virtual void WasHidden() OVERRIDE { | 110 virtual void WasHidden() override { |
111 hidden_observed_ = true; | 111 hidden_observed_ = true; |
112 hidden_callback_.Run(); | 112 hidden_callback_.Run(); |
113 } | 113 } |
114 | 114 |
115 bool hidden_observed() { return hidden_observed_; } | 115 bool hidden_observed() { return hidden_observed_; } |
116 | 116 |
117 private: | 117 private: |
118 base::Closure hidden_callback_; | 118 base::Closure hidden_callback_; |
119 bool hidden_observed_; | 119 bool hidden_observed_; |
120 | 120 |
(...skipping 23 matching lines...) Expand all Loading... |
144 class MockWebContentsDelegate : public content::WebContentsDelegate { | 144 class MockWebContentsDelegate : public content::WebContentsDelegate { |
145 public: | 145 public: |
146 MockWebContentsDelegate() | 146 MockWebContentsDelegate() |
147 : requested_(false), | 147 : requested_(false), |
148 checked_(false) {} | 148 checked_(false) {} |
149 virtual ~MockWebContentsDelegate() {} | 149 virtual ~MockWebContentsDelegate() {} |
150 | 150 |
151 virtual void RequestMediaAccessPermission( | 151 virtual void RequestMediaAccessPermission( |
152 content::WebContents* web_contents, | 152 content::WebContents* web_contents, |
153 const content::MediaStreamRequest& request, | 153 const content::MediaStreamRequest& request, |
154 const content::MediaResponseCallback& callback) OVERRIDE { | 154 const content::MediaResponseCallback& callback) override { |
155 requested_ = true; | 155 requested_ = true; |
156 if (request_message_loop_runner_.get()) | 156 if (request_message_loop_runner_.get()) |
157 request_message_loop_runner_->Quit(); | 157 request_message_loop_runner_->Quit(); |
158 } | 158 } |
159 | 159 |
160 virtual bool CheckMediaAccessPermission( | 160 virtual bool CheckMediaAccessPermission( |
161 content::WebContents* web_contents, | 161 content::WebContents* web_contents, |
162 const GURL& security_origin, | 162 const GURL& security_origin, |
163 content::MediaStreamType type) OVERRIDE { | 163 content::MediaStreamType type) override { |
164 checked_ = true; | 164 checked_ = true; |
165 if (check_message_loop_runner_.get()) | 165 if (check_message_loop_runner_.get()) |
166 check_message_loop_runner_->Quit(); | 166 check_message_loop_runner_->Quit(); |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 void WaitForRequestMediaPermission() { | 170 void WaitForRequestMediaPermission() { |
171 if (requested_) | 171 if (requested_) |
172 return; | 172 return; |
173 request_message_loop_runner_ = new content::MessageLoopRunner; | 173 request_message_loop_runner_ = new content::MessageLoopRunner; |
(...skipping 25 matching lines...) Expand all Loading... |
199 waiting_for_decision_(false), | 199 waiting_for_decision_(false), |
200 expect_allow_(false), | 200 expect_allow_(false), |
201 decision_made_(false), | 201 decision_made_(false), |
202 last_download_allowed_(false) {} | 202 last_download_allowed_(false) {} |
203 virtual ~MockDownloadWebContentsDelegate() {} | 203 virtual ~MockDownloadWebContentsDelegate() {} |
204 | 204 |
205 virtual void CanDownload( | 205 virtual void CanDownload( |
206 content::RenderViewHost* render_view_host, | 206 content::RenderViewHost* render_view_host, |
207 const GURL& url, | 207 const GURL& url, |
208 const std::string& request_method, | 208 const std::string& request_method, |
209 const base::Callback<void(bool)>& callback) OVERRIDE { | 209 const base::Callback<void(bool)>& callback) override { |
210 orig_delegate_->CanDownload( | 210 orig_delegate_->CanDownload( |
211 render_view_host, url, request_method, | 211 render_view_host, url, request_method, |
212 base::Bind(&MockDownloadWebContentsDelegate::DownloadDecided, | 212 base::Bind(&MockDownloadWebContentsDelegate::DownloadDecided, |
213 base::Unretained(this))); | 213 base::Unretained(this))); |
214 } | 214 } |
215 | 215 |
216 void WaitForCanDownload(bool expect_allow) { | 216 void WaitForCanDownload(bool expect_allow) { |
217 EXPECT_FALSE(waiting_for_decision_); | 217 EXPECT_FALSE(waiting_for_decision_); |
218 waiting_for_decision_ = true; | 218 waiting_for_decision_ = true; |
219 | 219 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 bool expect_allow_; | 251 bool expect_allow_; |
252 bool decision_made_; | 252 bool decision_made_; |
253 bool last_download_allowed_; | 253 bool last_download_allowed_; |
254 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 254 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
255 | 255 |
256 DISALLOW_COPY_AND_ASSIGN(MockDownloadWebContentsDelegate); | 256 DISALLOW_COPY_AND_ASSIGN(MockDownloadWebContentsDelegate); |
257 }; | 257 }; |
258 | 258 |
259 class WebViewTest : public extensions::PlatformAppBrowserTest { | 259 class WebViewTest : public extensions::PlatformAppBrowserTest { |
260 protected: | 260 protected: |
261 virtual void SetUp() OVERRIDE { | 261 virtual void SetUp() override { |
262 if (UsesFakeSpeech()) { | 262 if (UsesFakeSpeech()) { |
263 // SpeechRecognition test specific SetUp. | 263 // SpeechRecognition test specific SetUp. |
264 fake_speech_recognition_manager_.reset( | 264 fake_speech_recognition_manager_.reset( |
265 new content::FakeSpeechRecognitionManager()); | 265 new content::FakeSpeechRecognitionManager()); |
266 fake_speech_recognition_manager_->set_should_send_fake_response(true); | 266 fake_speech_recognition_manager_->set_should_send_fake_response(true); |
267 // Inject the fake manager factory so that the test result is returned to | 267 // Inject the fake manager factory so that the test result is returned to |
268 // the web page. | 268 // the web page. |
269 content::SpeechRecognitionManager::SetManagerForTesting( | 269 content::SpeechRecognitionManager::SetManagerForTesting( |
270 fake_speech_recognition_manager_.get()); | 270 fake_speech_recognition_manager_.get()); |
271 } | 271 } |
272 extensions::PlatformAppBrowserTest::SetUp(); | 272 extensions::PlatformAppBrowserTest::SetUp(); |
273 } | 273 } |
274 | 274 |
275 virtual void TearDown() OVERRIDE { | 275 virtual void TearDown() override { |
276 if (UsesFakeSpeech()) { | 276 if (UsesFakeSpeech()) { |
277 // SpeechRecognition test specific TearDown. | 277 // SpeechRecognition test specific TearDown. |
278 content::SpeechRecognitionManager::SetManagerForTesting(NULL); | 278 content::SpeechRecognitionManager::SetManagerForTesting(NULL); |
279 } | 279 } |
280 | 280 |
281 extensions::PlatformAppBrowserTest::TearDown(); | 281 extensions::PlatformAppBrowserTest::TearDown(); |
282 } | 282 } |
283 | 283 |
284 virtual void SetUpOnMainThread() OVERRIDE { | 284 virtual void SetUpOnMainThread() override { |
285 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); | 285 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); |
286 const testing::TestInfo* const test_info = | 286 const testing::TestInfo* const test_info = |
287 testing::UnitTest::GetInstance()->current_test_info(); | 287 testing::UnitTest::GetInstance()->current_test_info(); |
288 // Mock out geolocation for geolocation specific tests. | 288 // Mock out geolocation for geolocation specific tests. |
289 if (!strncmp(test_info->name(), "GeolocationAPI", | 289 if (!strncmp(test_info->name(), "GeolocationAPI", |
290 strlen("GeolocationAPI"))) { | 290 strlen("GeolocationAPI"))) { |
291 ui_test_utils::OverrideGeolocation(10, 20); | 291 ui_test_utils::OverrideGeolocation(10, 20); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 295 virtual void SetUpCommandLine(CommandLine* command_line) override { |
296 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 296 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
297 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 297 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
298 | 298 |
299 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 299 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
300 } | 300 } |
301 | 301 |
302 // This method is responsible for initializing a packaged app, which contains | 302 // This method is responsible for initializing a packaged app, which contains |
303 // multiple webview tags. The tags have different partition identifiers and | 303 // multiple webview tags. The tags have different partition identifiers and |
304 // their WebContent objects are returned as output. The method also verifies | 304 // their WebContent objects are returned as output. The method also verifies |
305 // the expected process allocation and storage partition assignment. | 305 // the expected process allocation and storage partition assignment. |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 fake_speech_recognition_manager_; | 706 fake_speech_recognition_manager_; |
707 | 707 |
708 extensions::TestGuestViewManagerFactory factory_; | 708 extensions::TestGuestViewManagerFactory factory_; |
709 // Note that these are only set if you launch app using LoadAppWithGuest(). | 709 // Note that these are only set if you launch app using LoadAppWithGuest(). |
710 content::WebContents* guest_web_contents_; | 710 content::WebContents* guest_web_contents_; |
711 content::WebContents* embedder_web_contents_; | 711 content::WebContents* embedder_web_contents_; |
712 }; | 712 }; |
713 | 713 |
714 class WebViewDPITest : public WebViewTest { | 714 class WebViewDPITest : public WebViewTest { |
715 protected: | 715 protected: |
716 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 716 virtual void SetUpCommandLine(CommandLine* command_line) override { |
717 WebViewTest::SetUpCommandLine(command_line); | 717 WebViewTest::SetUpCommandLine(command_line); |
718 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | 718 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, |
719 base::StringPrintf("%f", scale())); | 719 base::StringPrintf("%f", scale())); |
720 } | 720 } |
721 | 721 |
722 static float scale() { return 2.0f; } | 722 static float scale() { return 2.0f; } |
723 }; | 723 }; |
724 | 724 |
725 // This test verifies that hiding the guest triggers WebContents::WasHidden(). | 725 // This test verifies that hiding the guest triggers WebContents::WasHidden(). |
726 IN_PROC_BROWSER_TEST_F(WebViewTest, GuestVisibilityChanged) { | 726 IN_PROC_BROWSER_TEST_F(WebViewTest, GuestVisibilityChanged) { |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 LoadExtension( | 2239 LoadExtension( |
2240 test_data_dir_.AppendASCII( | 2240 test_data_dir_.AppendASCII( |
2241 "platform_apps/web_view/extension_api/content_settings")); | 2241 "platform_apps/web_view/extension_api/content_settings")); |
2242 ASSERT_TRUE(content_settings_extension); | 2242 ASSERT_TRUE(content_settings_extension); |
2243 TestHelper("testPostMessageCommChannel", "web_view/shim", NO_TEST_SERVER); | 2243 TestHelper("testPostMessageCommChannel", "web_view/shim", NO_TEST_SERVER); |
2244 } | 2244 } |
2245 | 2245 |
2246 #if defined(ENABLE_PLUGINS) | 2246 #if defined(ENABLE_PLUGINS) |
2247 class WebViewPluginTest : public WebViewTest { | 2247 class WebViewPluginTest : public WebViewTest { |
2248 protected: | 2248 protected: |
2249 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 2249 virtual void SetUpCommandLine(CommandLine* command_line) override { |
2250 WebViewTest::SetUpCommandLine(command_line); | 2250 WebViewTest::SetUpCommandLine(command_line); |
2251 | 2251 |
2252 // Append the switch to register the pepper plugin. | 2252 // Append the switch to register the pepper plugin. |
2253 // library name = <out dir>/<test_name>.<library_extension> | 2253 // library name = <out dir>/<test_name>.<library_extension> |
2254 // MIME type = application/x-ppapi-<test_name> | 2254 // MIME type = application/x-ppapi-<test_name> |
2255 base::FilePath plugin_dir; | 2255 base::FilePath plugin_dir; |
2256 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 2256 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
2257 | 2257 |
2258 base::FilePath plugin_lib = plugin_dir.Append(library_name); | 2258 base::FilePath plugin_lib = plugin_dir.Append(library_name); |
2259 EXPECT_TRUE(base::PathExists(plugin_lib)); | 2259 EXPECT_TRUE(base::PathExists(plugin_lib)); |
2260 base::FilePath::StringType pepper_plugin = plugin_lib.value(); | 2260 base::FilePath::StringType pepper_plugin = plugin_lib.value(); |
2261 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); | 2261 pepper_plugin.append(FILE_PATH_LITERAL(";application/x-ppapi-tests")); |
2262 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | 2262 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, |
2263 pepper_plugin); | 2263 pepper_plugin); |
2264 } | 2264 } |
2265 }; | 2265 }; |
2266 | 2266 |
2267 IN_PROC_BROWSER_TEST_F(WebViewPluginTest, TestLoadPluginEvent) { | 2267 IN_PROC_BROWSER_TEST_F(WebViewPluginTest, TestLoadPluginEvent) { |
2268 TestHelper("testPluginLoadPermission", "web_view/shim", NO_TEST_SERVER); | 2268 TestHelper("testPluginLoadPermission", "web_view/shim", NO_TEST_SERVER); |
2269 } | 2269 } |
2270 #endif // defined(ENABLE_PLUGINS) | 2270 #endif // defined(ENABLE_PLUGINS) |
2271 | 2271 |
2272 class WebViewCaptureTest : public WebViewTest { | 2272 class WebViewCaptureTest : public WebViewTest { |
2273 public: | 2273 public: |
2274 WebViewCaptureTest() {} | 2274 WebViewCaptureTest() {} |
2275 virtual ~WebViewCaptureTest() {} | 2275 virtual ~WebViewCaptureTest() {} |
2276 virtual void SetUp() OVERRIDE { | 2276 virtual void SetUp() override { |
2277 EnablePixelOutput(); | 2277 EnablePixelOutput(); |
2278 WebViewTest::SetUp(); | 2278 WebViewTest::SetUp(); |
2279 } | 2279 } |
2280 }; | 2280 }; |
2281 | 2281 |
2282 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestZoomAPI) { | 2282 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestZoomAPI) { |
2283 TestHelper("testZoomAPI", "web_view/shim", NO_TEST_SERVER); | 2283 TestHelper("testZoomAPI", "web_view/shim", NO_TEST_SERVER); |
2284 } | 2284 } |
2285 | 2285 |
2286 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI) { | 2286 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAPI) { |
(...skipping 20 matching lines...) Expand all Loading... |
2307 // http://crbug.com/403325 | 2307 // http://crbug.com/403325 |
2308 #define MAYBE_WebViewInBackgroundPage \ | 2308 #define MAYBE_WebViewInBackgroundPage \ |
2309 DISABLED_WebViewInBackgroundPage | 2309 DISABLED_WebViewInBackgroundPage |
2310 #else | 2310 #else |
2311 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage | 2311 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage |
2312 #endif | 2312 #endif |
2313 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { | 2313 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { |
2314 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) | 2314 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) |
2315 << message_; | 2315 << message_; |
2316 } | 2316 } |
OLD | NEW |