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 std::string ToResponseString() const override { return std::string(); } |
88 return std::string(); | |
89 } | |
90 }; | 88 }; |
91 | 89 |
92 class TestInterstitialPageDelegate : public content::InterstitialPageDelegate { | 90 class TestInterstitialPageDelegate : public content::InterstitialPageDelegate { |
93 public: | 91 public: |
94 TestInterstitialPageDelegate() { | 92 TestInterstitialPageDelegate() { |
95 } | 93 } |
96 virtual ~TestInterstitialPageDelegate() {} | 94 ~TestInterstitialPageDelegate() override {} |
97 virtual std::string GetHTMLContents() override { return std::string(); } | 95 std::string GetHTMLContents() override { return std::string(); } |
98 }; | 96 }; |
99 | 97 |
100 class WebContentsHiddenObserver : public content::WebContentsObserver { | 98 class WebContentsHiddenObserver : public content::WebContentsObserver { |
101 public: | 99 public: |
102 WebContentsHiddenObserver(content::WebContents* web_contents, | 100 WebContentsHiddenObserver(content::WebContents* web_contents, |
103 const base::Closure& hidden_callback) | 101 const base::Closure& hidden_callback) |
104 : WebContentsObserver(web_contents), | 102 : WebContentsObserver(web_contents), |
105 hidden_callback_(hidden_callback), | 103 hidden_callback_(hidden_callback), |
106 hidden_observed_(false) { | 104 hidden_observed_(false) { |
107 } | 105 } |
108 | 106 |
109 // WebContentsObserver. | 107 // WebContentsObserver. |
110 virtual void WasHidden() override { | 108 void WasHidden() override { |
111 hidden_observed_ = true; | 109 hidden_observed_ = true; |
112 hidden_callback_.Run(); | 110 hidden_callback_.Run(); |
113 } | 111 } |
114 | 112 |
115 bool hidden_observed() { return hidden_observed_; } | 113 bool hidden_observed() { return hidden_observed_; } |
116 | 114 |
117 private: | 115 private: |
118 base::Closure hidden_callback_; | 116 base::Closure hidden_callback_; |
119 bool hidden_observed_; | 117 bool hidden_observed_; |
120 | 118 |
(...skipping 18 matching lines...) Expand all Loading... |
139 // should be triggered only if the embedder API (from tests) allows the request | 137 // should be triggered only if the embedder API (from tests) allows the request |
140 // in Javascript. | 138 // in Javascript. |
141 // We do not issue the actual media request; the fact that the request reached | 139 // We do not issue the actual media request; the fact that the request reached |
142 // embedder's WebContents is good enough for our tests. This is also to make | 140 // embedder's WebContents is good enough for our tests. This is also to make |
143 // the test run successfully on trybots. | 141 // the test run successfully on trybots. |
144 class MockWebContentsDelegate : public content::WebContentsDelegate { | 142 class MockWebContentsDelegate : public content::WebContentsDelegate { |
145 public: | 143 public: |
146 MockWebContentsDelegate() | 144 MockWebContentsDelegate() |
147 : requested_(false), | 145 : requested_(false), |
148 checked_(false) {} | 146 checked_(false) {} |
149 virtual ~MockWebContentsDelegate() {} | 147 ~MockWebContentsDelegate() override {} |
150 | 148 |
151 virtual void RequestMediaAccessPermission( | 149 void RequestMediaAccessPermission( |
152 content::WebContents* web_contents, | 150 content::WebContents* web_contents, |
153 const content::MediaStreamRequest& request, | 151 const content::MediaStreamRequest& request, |
154 const content::MediaResponseCallback& callback) override { | 152 const content::MediaResponseCallback& callback) override { |
155 requested_ = true; | 153 requested_ = true; |
156 if (request_message_loop_runner_.get()) | 154 if (request_message_loop_runner_.get()) |
157 request_message_loop_runner_->Quit(); | 155 request_message_loop_runner_->Quit(); |
158 } | 156 } |
159 | 157 |
160 virtual bool CheckMediaAccessPermission( | 158 bool CheckMediaAccessPermission(content::WebContents* web_contents, |
161 content::WebContents* web_contents, | 159 const GURL& security_origin, |
162 const GURL& security_origin, | 160 content::MediaStreamType type) override { |
163 content::MediaStreamType type) override { | |
164 checked_ = true; | 161 checked_ = true; |
165 if (check_message_loop_runner_.get()) | 162 if (check_message_loop_runner_.get()) |
166 check_message_loop_runner_->Quit(); | 163 check_message_loop_runner_->Quit(); |
167 return true; | 164 return true; |
168 } | 165 } |
169 | 166 |
170 void WaitForRequestMediaPermission() { | 167 void WaitForRequestMediaPermission() { |
171 if (requested_) | 168 if (requested_) |
172 return; | 169 return; |
173 request_message_loop_runner_ = new content::MessageLoopRunner; | 170 request_message_loop_runner_ = new content::MessageLoopRunner; |
(...skipping 19 matching lines...) Expand all Loading... |
193 // This class intercepts download request from the guest. | 190 // This class intercepts download request from the guest. |
194 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { | 191 class MockDownloadWebContentsDelegate : public content::WebContentsDelegate { |
195 public: | 192 public: |
196 explicit MockDownloadWebContentsDelegate( | 193 explicit MockDownloadWebContentsDelegate( |
197 content::WebContentsDelegate* orig_delegate) | 194 content::WebContentsDelegate* orig_delegate) |
198 : orig_delegate_(orig_delegate), | 195 : orig_delegate_(orig_delegate), |
199 waiting_for_decision_(false), | 196 waiting_for_decision_(false), |
200 expect_allow_(false), | 197 expect_allow_(false), |
201 decision_made_(false), | 198 decision_made_(false), |
202 last_download_allowed_(false) {} | 199 last_download_allowed_(false) {} |
203 virtual ~MockDownloadWebContentsDelegate() {} | 200 ~MockDownloadWebContentsDelegate() override {} |
204 | 201 |
205 virtual void CanDownload( | 202 void CanDownload(content::RenderViewHost* render_view_host, |
206 content::RenderViewHost* render_view_host, | 203 const GURL& url, |
207 const GURL& url, | 204 const std::string& request_method, |
208 const std::string& request_method, | 205 const base::Callback<void(bool)>& callback) override { |
209 const base::Callback<void(bool)>& callback) override { | |
210 orig_delegate_->CanDownload( | 206 orig_delegate_->CanDownload( |
211 render_view_host, url, request_method, | 207 render_view_host, url, request_method, |
212 base::Bind(&MockDownloadWebContentsDelegate::DownloadDecided, | 208 base::Bind(&MockDownloadWebContentsDelegate::DownloadDecided, |
213 base::Unretained(this))); | 209 base::Unretained(this))); |
214 } | 210 } |
215 | 211 |
216 void WaitForCanDownload(bool expect_allow) { | 212 void WaitForCanDownload(bool expect_allow) { |
217 EXPECT_FALSE(waiting_for_decision_); | 213 EXPECT_FALSE(waiting_for_decision_); |
218 waiting_for_decision_ = true; | 214 waiting_for_decision_ = true; |
219 | 215 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 270 |
275 virtual void TearDown() override { | 271 virtual void TearDown() override { |
276 if (UsesFakeSpeech()) { | 272 if (UsesFakeSpeech()) { |
277 // SpeechRecognition test specific TearDown. | 273 // SpeechRecognition test specific TearDown. |
278 content::SpeechRecognitionManager::SetManagerForTesting(NULL); | 274 content::SpeechRecognitionManager::SetManagerForTesting(NULL); |
279 } | 275 } |
280 | 276 |
281 extensions::PlatformAppBrowserTest::TearDown(); | 277 extensions::PlatformAppBrowserTest::TearDown(); |
282 } | 278 } |
283 | 279 |
284 virtual void SetUpOnMainThread() override { | 280 void SetUpOnMainThread() override { |
285 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); | 281 extensions::PlatformAppBrowserTest::SetUpOnMainThread(); |
286 const testing::TestInfo* const test_info = | 282 const testing::TestInfo* const test_info = |
287 testing::UnitTest::GetInstance()->current_test_info(); | 283 testing::UnitTest::GetInstance()->current_test_info(); |
288 // Mock out geolocation for geolocation specific tests. | 284 // Mock out geolocation for geolocation specific tests. |
289 if (!strncmp(test_info->name(), "GeolocationAPI", | 285 if (!strncmp(test_info->name(), "GeolocationAPI", |
290 strlen("GeolocationAPI"))) { | 286 strlen("GeolocationAPI"))) { |
291 ui_test_utils::OverrideGeolocation(10, 20); | 287 ui_test_utils::OverrideGeolocation(10, 20); |
292 } | 288 } |
293 } | 289 } |
294 | 290 |
295 virtual void SetUpCommandLine(CommandLine* command_line) override { | 291 void SetUpCommandLine(CommandLine* command_line) override { |
296 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 292 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
297 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 293 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
298 | 294 |
299 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); | 295 extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
300 } | 296 } |
301 | 297 |
302 // This method is responsible for initializing a packaged app, which contains | 298 // This method is responsible for initializing a packaged app, which contains |
303 // multiple webview tags. The tags have different partition identifiers and | 299 // multiple webview tags. The tags have different partition identifiers and |
304 // their WebContent objects are returned as output. The method also verifies | 300 // their WebContent objects are returned as output. The method also verifies |
305 // the expected process allocation and storage partition assignment. | 301 // 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_; | 702 fake_speech_recognition_manager_; |
707 | 703 |
708 extensions::TestGuestViewManagerFactory factory_; | 704 extensions::TestGuestViewManagerFactory factory_; |
709 // Note that these are only set if you launch app using LoadAppWithGuest(). | 705 // Note that these are only set if you launch app using LoadAppWithGuest(). |
710 content::WebContents* guest_web_contents_; | 706 content::WebContents* guest_web_contents_; |
711 content::WebContents* embedder_web_contents_; | 707 content::WebContents* embedder_web_contents_; |
712 }; | 708 }; |
713 | 709 |
714 class WebViewDPITest : public WebViewTest { | 710 class WebViewDPITest : public WebViewTest { |
715 protected: | 711 protected: |
716 virtual void SetUpCommandLine(CommandLine* command_line) override { | 712 void SetUpCommandLine(CommandLine* command_line) override { |
717 WebViewTest::SetUpCommandLine(command_line); | 713 WebViewTest::SetUpCommandLine(command_line); |
718 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | 714 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, |
719 base::StringPrintf("%f", scale())); | 715 base::StringPrintf("%f", scale())); |
720 } | 716 } |
721 | 717 |
722 static float scale() { return 2.0f; } | 718 static float scale() { return 2.0f; } |
723 }; | 719 }; |
724 | 720 |
725 // This test verifies that hiding the guest triggers WebContents::WasHidden(). | 721 // This test verifies that hiding the guest triggers WebContents::WasHidden(). |
726 IN_PROC_BROWSER_TEST_F(WebViewTest, GuestVisibilityChanged) { | 722 IN_PROC_BROWSER_TEST_F(WebViewTest, GuestVisibilityChanged) { |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 LoadExtension( | 2229 LoadExtension( |
2234 test_data_dir_.AppendASCII( | 2230 test_data_dir_.AppendASCII( |
2235 "platform_apps/web_view/extension_api/content_settings")); | 2231 "platform_apps/web_view/extension_api/content_settings")); |
2236 ASSERT_TRUE(content_settings_extension); | 2232 ASSERT_TRUE(content_settings_extension); |
2237 TestHelper("testPostMessageCommChannel", "web_view/shim", NO_TEST_SERVER); | 2233 TestHelper("testPostMessageCommChannel", "web_view/shim", NO_TEST_SERVER); |
2238 } | 2234 } |
2239 | 2235 |
2240 #if defined(ENABLE_PLUGINS) | 2236 #if defined(ENABLE_PLUGINS) |
2241 class WebViewPluginTest : public WebViewTest { | 2237 class WebViewPluginTest : public WebViewTest { |
2242 protected: | 2238 protected: |
2243 virtual void SetUpCommandLine(CommandLine* command_line) override { | 2239 void SetUpCommandLine(CommandLine* command_line) override { |
2244 WebViewTest::SetUpCommandLine(command_line); | 2240 WebViewTest::SetUpCommandLine(command_line); |
2245 | 2241 |
2246 // Append the switch to register the pepper plugin. | 2242 // Append the switch to register the pepper plugin. |
2247 // library name = <out dir>/<test_name>.<library_extension> | 2243 // library name = <out dir>/<test_name>.<library_extension> |
2248 // MIME type = application/x-ppapi-<test_name> | 2244 // MIME type = application/x-ppapi-<test_name> |
2249 base::FilePath plugin_dir; | 2245 base::FilePath plugin_dir; |
2250 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); | 2246 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); |
2251 | 2247 |
2252 base::FilePath plugin_lib = plugin_dir.Append(library_name); | 2248 base::FilePath plugin_lib = plugin_dir.Append(library_name); |
2253 EXPECT_TRUE(base::PathExists(plugin_lib)); | 2249 EXPECT_TRUE(base::PathExists(plugin_lib)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2301 // http://crbug.com/403325 | 2297 // http://crbug.com/403325 |
2302 #define MAYBE_WebViewInBackgroundPage \ | 2298 #define MAYBE_WebViewInBackgroundPage \ |
2303 DISABLED_WebViewInBackgroundPage | 2299 DISABLED_WebViewInBackgroundPage |
2304 #else | 2300 #else |
2305 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage | 2301 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage |
2306 #endif | 2302 #endif |
2307 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { | 2303 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { |
2308 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) | 2304 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) |
2309 << message_; | 2305 << message_; |
2310 } | 2306 } |
OLD | NEW |