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 <array> | 5 #include <array> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 public: | 144 public: |
145 DesktopCaptureApiTest() { | 145 DesktopCaptureApiTest() { |
146 DesktopCaptureChooseDesktopMediaFunction:: | 146 DesktopCaptureChooseDesktopMediaFunction:: |
147 SetPickerFactoryForTests(&picker_factory_); | 147 SetPickerFactoryForTests(&picker_factory_); |
148 } | 148 } |
149 ~DesktopCaptureApiTest() override { | 149 ~DesktopCaptureApiTest() override { |
150 DesktopCaptureChooseDesktopMediaFunction:: | 150 DesktopCaptureChooseDesktopMediaFunction:: |
151 SetPickerFactoryForTests(NULL); | 151 SetPickerFactoryForTests(NULL); |
152 } | 152 } |
153 | 153 |
| 154 void SetUpOnMainThread() override { |
| 155 ExtensionApiTest::SetUpOnMainThread(); |
| 156 host_resolver()->AddRule("*", "127.0.0.1"); |
| 157 } |
| 158 |
154 protected: | 159 protected: |
155 GURL GetURLForPath(const std::string& host, const std::string& path) { | 160 GURL GetURLForPath(const std::string& host, const std::string& path) { |
156 std::string port = base::UintToString(embedded_test_server()->port()); | 161 std::string port = base::UintToString(embedded_test_server()->port()); |
157 GURL::Replacements replacements; | 162 GURL::Replacements replacements; |
158 replacements.SetHostStr(host); | 163 replacements.SetHostStr(host); |
159 replacements.SetPortStr(port); | 164 replacements.SetPortStr(port); |
160 return embedded_test_server()->GetURL(path).ReplaceComponents(replacements); | 165 return embedded_test_server()->GetURL(path).ReplaceComponents(replacements); |
161 } | 166 } |
162 | 167 |
163 FakeDesktopMediaPickerFactory picker_factory_; | 168 FakeDesktopMediaPickerFactory picker_factory_; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 242 } |
238 | 243 |
239 // Test is flaky http://crbug.com/301887. | 244 // Test is flaky http://crbug.com/301887. |
240 IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_Delegation) { | 245 IN_PROC_BROWSER_TEST_F(DesktopCaptureApiTest, DISABLED_Delegation) { |
241 // Initialize test server. | 246 // Initialize test server. |
242 base::FilePath test_data; | 247 base::FilePath test_data; |
243 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); | 248 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); |
244 embedded_test_server()->ServeFilesFromDirectory(test_data.AppendASCII( | 249 embedded_test_server()->ServeFilesFromDirectory(test_data.AppendASCII( |
245 "extensions/api_test/desktop_capture_delegate")); | 250 "extensions/api_test/desktop_capture_delegate")); |
246 ASSERT_TRUE(embedded_test_server()->Start()); | 251 ASSERT_TRUE(embedded_test_server()->Start()); |
247 host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); | |
248 | 252 |
249 // Load extension. | 253 // Load extension. |
250 base::FilePath extension_path = | 254 base::FilePath extension_path = |
251 test_data_dir_.AppendASCII("desktop_capture_delegate"); | 255 test_data_dir_.AppendASCII("desktop_capture_delegate"); |
252 const Extension* extension = LoadExtensionWithFlags( | 256 const Extension* extension = LoadExtensionWithFlags( |
253 extension_path, ExtensionBrowserTest::kFlagNone); | 257 extension_path, ExtensionBrowserTest::kFlagNone); |
254 ASSERT_TRUE(extension); | 258 ASSERT_TRUE(extension); |
255 | 259 |
256 ui_test_utils::NavigateToURL( | 260 ui_test_utils::NavigateToURL( |
257 browser(), GetURLForPath("example.com", "/example.com.html")); | 261 browser(), GetURLForPath("example.com", "/example.com.html")); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 EXPECT_TRUE(result); | 294 EXPECT_TRUE(result); |
291 EXPECT_TRUE(test_flags[2].picker_created); | 295 EXPECT_TRUE(test_flags[2].picker_created); |
292 EXPECT_FALSE(test_flags[2].picker_deleted); | 296 EXPECT_FALSE(test_flags[2].picker_deleted); |
293 | 297 |
294 web_contents->Close(); | 298 web_contents->Close(); |
295 destroyed_watcher.Wait(); | 299 destroyed_watcher.Wait(); |
296 EXPECT_TRUE(test_flags[2].picker_deleted); | 300 EXPECT_TRUE(test_flags[2].picker_deleted); |
297 } | 301 } |
298 | 302 |
299 } // namespace extensions | 303 } // namespace extensions |
OLD | NEW |