Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_apitest.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 scoped_ptr<EmbeddedTestServer> test_server_; 237 scoped_ptr<EmbeddedTestServer> test_server_;
238 base::ScopedTempDir downloads_dir_; 238 base::ScopedTempDir downloads_dir_;
239 }; 239 };
240 240
241 // Tests that navigating to a resource with a MIME type handleable by an 241 // Tests that navigating to a resource with a MIME type handleable by an
242 // installed, white-listed extension invokes the extension's 242 // installed, white-listed extension invokes the extension's
243 // onExecuteContentHandler event (and does not start a download). 243 // onExecuteContentHandler event (and does not start a download).
244 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) { 244 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) {
245 #if defined(OS_WIN) && defined(USE_ASH) 245 #if defined(OS_WIN) && defined(USE_ASH)
246 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 246 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
247 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 247 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
248 switches::kAshBrowserTests))
248 return; 249 return;
249 #endif 250 #endif
250 251
251 ASSERT_TRUE(LoadTestExtension()) << message_; 252 ASSERT_TRUE(LoadTestExtension()) << message_;
252 253
253 ResultCatcher catcher; 254 ResultCatcher catcher;
254 255
255 ui_test_utils::NavigateToURL(browser(), 256 ui_test_utils::NavigateToURL(browser(),
256 test_server_->GetURL("/doc_path.doc")); 257 test_server_->GetURL("/doc_path.doc"));
257 258
258 // Wait for the response from the test server. 259 // Wait for the response from the test server.
259 base::MessageLoop::current()->RunUntilIdle(); 260 base::MessageLoop::current()->RunUntilIdle();
260 261
261 // There should be no downloads started by the navigation. 262 // There should be no downloads started by the navigation.
262 DownloadManager* download_manager = GetDownloadManager(); 263 DownloadManager* download_manager = GetDownloadManager();
263 std::vector<DownloadItem*> downloads; 264 std::vector<DownloadItem*> downloads;
264 download_manager->GetAllDownloads(&downloads); 265 download_manager->GetAllDownloads(&downloads);
265 ASSERT_EQ(0u, downloads.size()); 266 ASSERT_EQ(0u, downloads.size());
266 267
267 // The test extension should receive onExecuteContentHandler event with MIME 268 // The test extension should receive onExecuteContentHandler event with MIME
268 // type 'application/msword' (and call chrome.test.notifySuccess). 269 // type 'application/msword' (and call chrome.test.notifySuccess).
269 EXPECT_TRUE(catcher.GetNextResult()); 270 EXPECT_TRUE(catcher.GetNextResult());
270 } 271 }
271 272
272 // Tests that navigating to a file URL also intercepts despite there being no 273 // Tests that navigating to a file URL also intercepts despite there being no
273 // HTTP headers. This is a regression test for https://crbug.com/416433. 274 // HTTP headers. This is a regression test for https://crbug.com/416433.
274 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, FileURL) { 275 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, FileURL) {
275 #if defined(OS_WIN) && defined(USE_ASH) 276 #if defined(OS_WIN) && defined(USE_ASH)
276 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 277 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
277 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 278 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
279 switches::kAshBrowserTests))
278 return; 280 return;
279 #endif 281 #endif
280 282
281 ASSERT_TRUE(LoadTestExtension()) << message_; 283 ASSERT_TRUE(LoadTestExtension()) << message_;
282 284
283 ResultCatcher catcher; 285 ResultCatcher catcher;
284 286
285 ui_test_utils::NavigateToURL(browser(), ui_test_utils::GetTestUrl( 287 ui_test_utils::NavigateToURL(browser(), ui_test_utils::GetTestUrl(
286 base::FilePath(FILE_PATH_LITERAL("downloads")), 288 base::FilePath(FILE_PATH_LITERAL("downloads")),
287 base::FilePath(FILE_PATH_LITERAL("Picture_1.doc")))); 289 base::FilePath(FILE_PATH_LITERAL("Picture_1.doc"))));
288 290
289 // There should be no downloads started by the navigation. 291 // There should be no downloads started by the navigation.
290 DownloadManager* download_manager = GetDownloadManager(); 292 DownloadManager* download_manager = GetDownloadManager();
291 std::vector<DownloadItem*> downloads; 293 std::vector<DownloadItem*> downloads;
292 download_manager->GetAllDownloads(&downloads); 294 download_manager->GetAllDownloads(&downloads);
293 ASSERT_EQ(0u, downloads.size()); 295 ASSERT_EQ(0u, downloads.size());
294 296
295 // The test extension should receive onExecuteContentHandler event with MIME 297 // The test extension should receive onExecuteContentHandler event with MIME
296 // type 'application/msword' (and call chrome.test.notifySuccess). 298 // type 'application/msword' (and call chrome.test.notifySuccess).
297 EXPECT_TRUE(catcher.GetNextResult()); 299 EXPECT_TRUE(catcher.GetNextResult());
298 } 300 }
299 301
300 // Tests that navigating cross-site to a resource with a MIME type handleable by 302 // Tests that navigating cross-site to a resource with a MIME type handleable by
301 // an installed, white-listed extension invokes the extension's 303 // an installed, white-listed extension invokes the extension's
302 // onExecuteContentHandler event (and does not start a download). 304 // onExecuteContentHandler event (and does not start a download).
303 // Regression test for http://crbug.com/342999. 305 // Regression test for http://crbug.com/342999.
304 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, NavigateCrossSite) { 306 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, NavigateCrossSite) {
305 #if defined(OS_WIN) && defined(USE_ASH) 307 #if defined(OS_WIN) && defined(USE_ASH)
306 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 308 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
307 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 309 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
310 switches::kAshBrowserTests))
308 return; 311 return;
309 #endif 312 #endif
310 313
311 ASSERT_TRUE(LoadTestExtension()) << message_; 314 ASSERT_TRUE(LoadTestExtension()) << message_;
312 315
313 ResultCatcher catcher; 316 ResultCatcher catcher;
314 317
315 // Navigate to a URL on a different hostname. 318 // Navigate to a URL on a different hostname.
316 std::string initial_host = "www.example.com"; 319 std::string initial_host = "www.example.com";
317 host_resolver()->AddRule(initial_host, "127.0.0.1"); 320 host_resolver()->AddRule(initial_host, "127.0.0.1");
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // called by the extension). 430 // called by the extension).
428 SendDoneEvent(); 431 SendDoneEvent();
429 EXPECT_TRUE(catcher.GetNextResult()); 432 EXPECT_TRUE(catcher.GetNextResult());
430 } 433 }
431 434
432 // Tests that response headers are correctly passed to the API and that multiple 435 // Tests that response headers are correctly passed to the API and that multiple
433 // repsonse headers with the same name are merged correctly. 436 // repsonse headers with the same name are merged correctly.
434 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Headers) { 437 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Headers) {
435 #if defined(OS_WIN) && defined(USE_ASH) 438 #if defined(OS_WIN) && defined(USE_ASH)
436 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 439 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
437 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 440 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
441 switches::kAshBrowserTests))
438 return; 442 return;
439 #endif 443 #endif
440 444
441 ASSERT_TRUE(LoadTestExtension()) << message_; 445 ASSERT_TRUE(LoadTestExtension()) << message_;
442 446
443 ResultCatcher catcher; 447 ResultCatcher catcher;
444 448
445 ui_test_utils::NavigateToURL(browser(), 449 ui_test_utils::NavigateToURL(browser(),
446 test_server_->GetURL("/spreadsheet_path.xls")); 450 test_server_->GetURL("/spreadsheet_path.xls"));
447 451
448 // Wait for the response from the test server. 452 // Wait for the response from the test server.
449 base::MessageLoop::current()->RunUntilIdle(); 453 base::MessageLoop::current()->RunUntilIdle();
450 454
451 // There should be no downloads started by the navigation. 455 // There should be no downloads started by the navigation.
452 DownloadManager* download_manager = GetDownloadManager(); 456 DownloadManager* download_manager = GetDownloadManager();
453 std::vector<DownloadItem*> downloads; 457 std::vector<DownloadItem*> downloads;
454 download_manager->GetAllDownloads(&downloads); 458 download_manager->GetAllDownloads(&downloads);
455 ASSERT_EQ(0u, downloads.size()); 459 ASSERT_EQ(0u, downloads.size());
456 460
457 // The test extension should receive onExecuteContentHandler event with MIME 461 // The test extension should receive onExecuteContentHandler event with MIME
458 // type 'application/msexcel' (and call chrome.test.notifySuccess). 462 // type 'application/msexcel' (and call chrome.test.notifySuccess).
459 EXPECT_TRUE(catcher.GetNextResult()); 463 EXPECT_TRUE(catcher.GetNextResult());
460 } 464 }
461 465
462 // Tests that chrome.streamsPrivate.abort() works correctly. 466 // Tests that chrome.streamsPrivate.abort() works correctly.
463 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Abort) { 467 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Abort) {
464 #if defined(OS_WIN) && defined(USE_ASH) 468 #if defined(OS_WIN) && defined(USE_ASH)
465 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 469 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
466 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 470 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
471 switches::kAshBrowserTests))
467 return; 472 return;
468 #endif 473 #endif
469 474
470 ASSERT_TRUE(LoadTestExtension()) << message_; 475 ASSERT_TRUE(LoadTestExtension()) << message_;
471 476
472 ResultCatcher catcher; 477 ResultCatcher catcher;
473 ui_test_utils::NavigateToURL(browser(), 478 ui_test_utils::NavigateToURL(browser(),
474 test_server_->GetURL("/no_abort.rtf")); 479 test_server_->GetURL("/no_abort.rtf"));
475 base::MessageLoop::current()->RunUntilIdle(); 480 base::MessageLoop::current()->RunUntilIdle();
476 EXPECT_TRUE(catcher.GetNextResult()); 481 EXPECT_TRUE(catcher.GetNextResult());
477 482
478 ui_test_utils::NavigateToURL(browser(), 483 ui_test_utils::NavigateToURL(browser(),
479 test_server_->GetURL("/abort.rtf")); 484 test_server_->GetURL("/abort.rtf"));
480 base::MessageLoop::current()->RunUntilIdle(); 485 base::MessageLoop::current()->RunUntilIdle();
481 EXPECT_TRUE(catcher.GetNextResult()); 486 EXPECT_TRUE(catcher.GetNextResult());
482 } 487 }
483 488
484 } // namespace 489 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698