OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/prefs/pref_service.h" |
8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
11 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 12 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
12 #include "chrome/browser/download/download_prefs.h" | 13 #include "chrome/browser/download/download_prefs.h" |
13 #include "chrome/browser/download/download_service.h" | 14 #include "chrome/browser/download/download_service.h" |
14 #include "chrome/browser/download/download_service_factory.h" | 15 #include "chrome/browser/download/download_service_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" |
21 #include "chrome/grit/chromium_strings.h" | 23 #include "chrome/grit/chromium_strings.h" |
22 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
23 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
25 #include "chromeos/chromeos_switches.h" | 27 #include "chromeos/chromeos_switches.h" |
26 #include "components/signin/core/browser/signin_manager_base.h" | 28 #include "components/signin/core/browser/signin_manager_base.h" |
27 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
28 #include "content/public/browser/download_item.h" | 30 #include "content/public/browser/download_item.h" |
29 #include "content/public/browser/download_manager.h" | 31 #include "content/public/browser/download_manager.h" |
30 #include "content/public/test/download_test_observer.h" | 32 #include "content/public/test/download_test_observer.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 279 } |
278 | 280 |
279 void SetUpOnMainThread() override { | 281 void SetUpOnMainThread() override { |
280 ASSERT_TRUE(embedded_test_server()->Start()); | 282 ASSERT_TRUE(embedded_test_server()->Start()); |
281 | 283 |
282 content::BrowserThread::PostTask( | 284 content::BrowserThread::PostTask( |
283 content::BrowserThread::IO, FROM_HERE, | 285 content::BrowserThread::IO, FROM_HERE, |
284 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler)); | 286 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler)); |
285 | 287 |
286 GetMessageCenter()->DisableTimersForTest(); | 288 GetMessageCenter()->DisableTimersForTest(); |
| 289 |
| 290 // Set up the temporary download folder. |
| 291 ASSERT_TRUE(CreateAndSetDownloadsDirectory(browser())); |
| 292 } |
| 293 |
| 294 protected: |
| 295 // Must be called after browser creation. Creates a temporary |
| 296 // directory for downloads that is auto-deleted on destruction. |
| 297 // Returning false indicates a failure of the function, and should be asserted |
| 298 // in the caller. |
| 299 bool CreateAndSetDownloadsDirectory(Browser* browser) { |
| 300 if (!browser) |
| 301 return false; |
| 302 |
| 303 if (!downloads_directory_.path().empty()) |
| 304 return true; // already created |
| 305 |
| 306 if (!downloads_directory_.CreateUniqueTempDir()) |
| 307 return false; |
| 308 |
| 309 browser->profile()->GetPrefs()->SetFilePath( |
| 310 prefs::kDownloadDefaultDirectory, |
| 311 downloads_directory_.path()); |
| 312 browser->profile()->GetPrefs()->SetFilePath( |
| 313 prefs::kSaveFileDefaultDirectory, |
| 314 downloads_directory_.path()); |
| 315 |
| 316 return true; |
287 } | 317 } |
288 | 318 |
289 content::DownloadManager* GetDownloadManager(Browser* browser) { | 319 content::DownloadManager* GetDownloadManager(Browser* browser) { |
290 return content::BrowserContext::GetDownloadManager(browser->profile()); | 320 return content::BrowserContext::GetDownloadManager(browser->profile()); |
291 } | 321 } |
| 322 |
| 323 private: |
| 324 // Location of the downloads directory for these tests |
| 325 base::ScopedTempDir downloads_directory_; |
292 }; | 326 }; |
293 | 327 |
294 ////////////////////////////////////////////////// | 328 ////////////////////////////////////////////////// |
295 // Test with a single profile | 329 // Test with a single profile |
296 ////////////////////////////////////////////////// | 330 ////////////////////////////////////////////////// |
297 | 331 |
298 class DownloadNotificationTest : public DownloadNotificationTestBase { | 332 class DownloadNotificationTest : public DownloadNotificationTestBase { |
299 public: | 333 public: |
300 ~DownloadNotificationTest() override {} | 334 ~DownloadNotificationTest() override {} |
301 | 335 |
(...skipping 13 matching lines...) Expand all Loading... |
315 TestChromeDownloadManagerDelegate* GetDownloadManagerDelegate() const { | 349 TestChromeDownloadManagerDelegate* GetDownloadManagerDelegate() const { |
316 return static_cast<TestChromeDownloadManagerDelegate*>( | 350 return static_cast<TestChromeDownloadManagerDelegate*>( |
317 DownloadServiceFactory::GetForBrowserContext(browser()->profile()) | 351 DownloadServiceFactory::GetForBrowserContext(browser()->profile()) |
318 ->GetDownloadManagerDelegate()); | 352 ->GetDownloadManagerDelegate()); |
319 } | 353 } |
320 | 354 |
321 void PrepareIncognitoBrowser() { | 355 void PrepareIncognitoBrowser() { |
322 incognito_browser_ = CreateIncognitoBrowser(); | 356 incognito_browser_ = CreateIncognitoBrowser(); |
323 Profile* incognito_profile = incognito_browser_->profile(); | 357 Profile* incognito_profile = incognito_browser_->profile(); |
324 | 358 |
| 359 ASSERT_TRUE(CreateAndSetDownloadsDirectory(incognito_browser_)); |
| 360 |
325 scoped_ptr<TestChromeDownloadManagerDelegate> incognito_test_delegate; | 361 scoped_ptr<TestChromeDownloadManagerDelegate> incognito_test_delegate; |
326 incognito_test_delegate.reset( | 362 incognito_test_delegate.reset( |
327 new TestChromeDownloadManagerDelegate(incognito_profile)); | 363 new TestChromeDownloadManagerDelegate(incognito_profile)); |
328 DownloadServiceFactory::GetForBrowserContext(incognito_profile) | 364 DownloadServiceFactory::GetForBrowserContext(incognito_profile) |
329 ->SetDownloadManagerDelegateForTesting(incognito_test_delegate.Pass()); | 365 ->SetDownloadManagerDelegateForTesting(incognito_test_delegate.Pass()); |
330 } | 366 } |
331 | 367 |
332 TestChromeDownloadManagerDelegate* GetIncognitoDownloadManagerDelegate() | 368 TestChromeDownloadManagerDelegate* GetIncognitoDownloadManagerDelegate() |
333 const { | 369 const { |
334 Profile* incognito_profile = incognito_browser()->profile(); | 370 Profile* incognito_profile = incognito_browser()->profile(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 return DownloadPrefs::FromDownloadManager(GetDownloadManager(browser()))-> | 414 return DownloadPrefs::FromDownloadManager(GetDownloadManager(browser()))-> |
379 DownloadPath(); | 415 DownloadPath(); |
380 } | 416 } |
381 | 417 |
382 private: | 418 private: |
383 content::DownloadItem* download_item_ = nullptr; | 419 content::DownloadItem* download_item_ = nullptr; |
384 Browser* incognito_browser_ = nullptr; | 420 Browser* incognito_browser_ = nullptr; |
385 std::string notification_id_; | 421 std::string notification_id_; |
386 }; | 422 }; |
387 | 423 |
388 // TODO(yoshiki): Disabled due to crbug.com/560329 | 424 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadFile) { |
389 #if defined(OS_CHROMEOS) | |
390 #define MAYBE_DownloadFile DISABLED_DownloadFile | |
391 #else | |
392 #define MAYBE_DownloadFile DownloadFile | |
393 #endif | |
394 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DownloadFile) { | |
395 CreateDownload(); | 425 CreateDownload(); |
396 | 426 |
397 EXPECT_EQ(l10n_util::GetStringFUTF16( | 427 EXPECT_EQ(l10n_util::GetStringFUTF16( |
398 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, | 428 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, |
399 download_item()->GetFileNameToReportUser().LossyDisplayName()), | 429 download_item()->GetFileNameToReportUser().LossyDisplayName()), |
400 GetNotification(notification_id())->title()); | 430 GetNotification(notification_id())->title()); |
401 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, | 431 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, |
402 GetNotification(notification_id())->type()); | 432 GetNotification(notification_id())->type()); |
403 | 433 |
404 // Confirms that the download update is delivered to the notification. | 434 // Confirms that the download update is delivered to the notification. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 466 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
437 | 467 |
438 // Try to open the downloaded item by clicking the notification. | 468 // Try to open the downloaded item by clicking the notification. |
439 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); | 469 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); |
440 GetMessageCenter()->ClickOnNotification(notification_id()); | 470 GetMessageCenter()->ClickOnNotification(notification_id()); |
441 EXPECT_TRUE(GetDownloadManagerDelegate()->opened()); | 471 EXPECT_TRUE(GetDownloadManagerDelegate()->opened()); |
442 | 472 |
443 EXPECT_FALSE(GetNotification(notification_id())); | 473 EXPECT_FALSE(GetNotification(notification_id())); |
444 } | 474 } |
445 | 475 |
446 // TODO(yoshiki): Disabled due to crbug.com/560329 | 476 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadDangerousFile) { |
447 #if defined(OS_CHROMEOS) | |
448 #define MAYBE_DownloadDangerousFile DISABLED_DownloadDangerousFile | |
449 #else | |
450 #define MAYBE_DownloadDangerousFile DownloadDangerousFile | |
451 #endif | |
452 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DownloadDangerousFile) { | |
453 GURL download_url(embedded_test_server()->GetURL( | 477 GURL download_url(embedded_test_server()->GetURL( |
454 "/downloads/dangerous/dangerous.swf")); | 478 "/downloads/dangerous/dangerous.swf")); |
455 | 479 |
456 content::DownloadTestObserverTerminal download_terminal_observer( | 480 content::DownloadTestObserverTerminal download_terminal_observer( |
457 GetDownloadManager(browser()), | 481 GetDownloadManager(browser()), |
458 1u, /* wait_count */ | 482 1u, /* wait_count */ |
459 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 483 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
460 | 484 |
461 CreateDownloadForBrowserAndURL(browser(), download_url); | 485 CreateDownloadForBrowserAndURL(browser(), download_url); |
462 | 486 |
(...skipping 30 matching lines...) Expand all Loading... |
493 download_terminal_observer.WaitForFinished(); | 517 download_terminal_observer.WaitForFinished(); |
494 | 518 |
495 // Checks the download status. | 519 // Checks the download status. |
496 EXPECT_FALSE(download_item()->IsDangerous()); | 520 EXPECT_FALSE(download_item()->IsDangerous()); |
497 EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); | 521 EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); |
498 | 522 |
499 // Checks the downloaded file. | 523 // Checks the downloaded file. |
500 EXPECT_TRUE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 524 EXPECT_TRUE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
501 } | 525 } |
502 | 526 |
503 // TODO(yoshiki): Disabled due to crbug.com/560329 | 527 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DiscardDangerousFile) { |
504 #if defined(OS_CHROMEOS) | |
505 #define MAYBE_DiscardDangerousFile DISABLED_DiscardDangerousFile | |
506 #else | |
507 #define MAYBE_DiscardDangerousFile DiscardDangerousFile | |
508 #endif | |
509 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DiscardDangerousFile) { | |
510 GURL download_url(embedded_test_server()->GetURL( | 528 GURL download_url(embedded_test_server()->GetURL( |
511 "/downloads/dangerous/dangerous.swf")); | 529 "/downloads/dangerous/dangerous.swf")); |
512 | 530 |
513 content::DownloadTestObserverTerminal download_terminal_observer( | 531 content::DownloadTestObserverTerminal download_terminal_observer( |
514 GetDownloadManager(browser()), | 532 GetDownloadManager(browser()), |
515 1u, /* wait_count */ | 533 1u, /* wait_count */ |
516 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 534 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
517 | 535 |
518 CreateDownloadForBrowserAndURL(browser(), download_url); | 536 CreateDownloadForBrowserAndURL(browser(), download_url); |
519 | 537 |
(...skipping 28 matching lines...) Expand all Loading... |
548 // Checks there is neither any download nor any notification. | 566 // Checks there is neither any download nor any notification. |
549 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 567 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
550 std::vector<content::DownloadItem*> downloads; | 568 std::vector<content::DownloadItem*> downloads; |
551 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 569 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
552 EXPECT_EQ(0u, downloads.size()); | 570 EXPECT_EQ(0u, downloads.size()); |
553 | 571 |
554 // Checks the downloaded file doesn't exist. | 572 // Checks the downloaded file doesn't exist. |
555 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 573 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
556 } | 574 } |
557 | 575 |
558 // TODO(yoshiki): Disabled due to crbug.com/560329 | 576 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadImageFile) { |
559 #if defined(OS_CHROMEOS) | |
560 #define MAYBE_DownloadImageFile DISABLED_DownloadImageFile | |
561 #else | |
562 #define MAYBE_DownloadImageFile DownloadImageFile | |
563 #endif | |
564 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DownloadImageFile) { | |
565 GURL download_url(embedded_test_server()->GetURL( | 577 GURL download_url(embedded_test_server()->GetURL( |
566 "/downloads/image-octet-stream.png")); | 578 "/downloads/image-octet-stream.png")); |
567 | 579 |
568 content::DownloadTestObserverTerminal download_terminal_observer( | 580 content::DownloadTestObserverTerminal download_terminal_observer( |
569 GetDownloadManager(browser()), 1u, /* wait_count */ | 581 GetDownloadManager(browser()), 1u, /* wait_count */ |
570 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 582 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
571 | 583 |
572 CreateDownloadForBrowserAndURL(browser(), download_url); | 584 CreateDownloadForBrowserAndURL(browser(), download_url); |
573 | 585 |
574 // Wait for the download completion. | 586 // Wait for the download completion. |
575 download_terminal_observer.WaitForFinished(); | 587 download_terminal_observer.WaitForFinished(); |
576 | 588 |
577 // Waits for download completion. | 589 // Waits for download completion. |
578 NotificationUpdateObserver | 590 NotificationUpdateObserver |
579 download_change_notification_observer(notification_id()); | 591 download_change_notification_observer(notification_id()); |
580 while (GetNotification(notification_id())->image().IsEmpty()) { | 592 while (GetNotification(notification_id())->image().IsEmpty()) { |
581 download_change_notification_observer.Wait(); | 593 download_change_notification_observer.Wait(); |
582 download_change_notification_observer.Reset(); | 594 download_change_notification_observer.Reset(); |
583 } | 595 } |
584 } | 596 } |
585 | 597 |
586 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
587 #if defined(OS_CHROMEOS) | |
588 #define MAYBE_CloseNotificationAfterDownload DISABLED_CloseNotificationAfterDown
load | |
589 #else | |
590 #define MAYBE_CloseNotificationAfterDownload CloseNotificationAfterDownload | |
591 #endif | |
592 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 598 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
593 MAYBE_CloseNotificationAfterDownload) { | 599 CloseNotificationAfterDownload) { |
594 CreateDownload(); | 600 CreateDownload(); |
595 | 601 |
596 // Requests to complete the download. | 602 // Requests to complete the download. |
597 ui_test_utils::NavigateToURL( | 603 ui_test_utils::NavigateToURL( |
598 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 604 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
599 | 605 |
600 // Waits for download completion. | 606 // Waits for download completion. |
601 NotificationUpdateObserver | 607 NotificationUpdateObserver |
602 download_change_notification_observer(notification_id()); | 608 download_change_notification_observer(notification_id()); |
603 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 609 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
(...skipping 11 matching lines...) Expand all Loading... |
615 | 621 |
616 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 622 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
617 | 623 |
618 // Confirms that a download is also started. | 624 // Confirms that a download is also started. |
619 std::vector<content::DownloadItem*> downloads; | 625 std::vector<content::DownloadItem*> downloads; |
620 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 626 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
621 EXPECT_EQ(1u, downloads.size()); | 627 EXPECT_EQ(1u, downloads.size()); |
622 EXPECT_EQ(content::DownloadItem::COMPLETE, downloads[0]->GetState()); | 628 EXPECT_EQ(content::DownloadItem::COMPLETE, downloads[0]->GetState()); |
623 } | 629 } |
624 | 630 |
625 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
626 #if defined(OS_CHROMEOS) | |
627 #define MAYBE_CloseNotificationWhileDownloading DISABLED_CloseNotificationWhileD
ownloading | |
628 #else | |
629 #define MAYBE_CloseNotificationWhileDownloading CloseNotificationWhileDownloadin
g | |
630 #endif | |
631 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 631 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
632 MAYBE_CloseNotificationWhileDownloading) { | 632 CloseNotificationWhileDownloading) { |
633 CreateDownload(); | 633 CreateDownload(); |
634 | 634 |
635 // Closes the notification. | 635 // Closes the notification. |
636 NotificationRemoveObserver notification_close_observer; | 636 NotificationRemoveObserver notification_close_observer; |
637 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); | 637 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); |
638 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 638 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
639 | 639 |
640 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 640 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
641 | 641 |
642 // Confirms that a download is still in progress. | 642 // Confirms that a download is still in progress. |
(...skipping 18 matching lines...) Expand all Loading... |
661 // Waits that new notification. | 661 // Waits that new notification. |
662 download_notification_add_observer.Wait(); | 662 download_notification_add_observer.Wait(); |
663 | 663 |
664 // Confirms that there is only one notification. | 664 // Confirms that there is only one notification. |
665 message_center::NotificationList::Notifications | 665 message_center::NotificationList::Notifications |
666 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); | 666 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); |
667 EXPECT_EQ(1u, visible_notifications.size()); | 667 EXPECT_EQ(1u, visible_notifications.size()); |
668 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); | 668 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); |
669 } | 669 } |
670 | 670 |
671 // TODO(yoshiki): Disabled due to crbug.com/560329 | 671 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, InterruptDownload) { |
672 #if defined(OS_CHROMEOS) | |
673 #define MAYBE_InterruptDownload DISABLED_InterruptDownload | |
674 #else | |
675 #define MAYBE_InterruptDownload InterruptDownload | |
676 #endif | |
677 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_InterruptDownload) { | |
678 CreateDownload(); | 672 CreateDownload(); |
679 | 673 |
680 // Installs observers before requesting. | 674 // Installs observers before requesting. |
681 NotificationUpdateObserver | 675 NotificationUpdateObserver |
682 download_notification_update_observer(notification_id()); | 676 download_notification_update_observer(notification_id()); |
683 content::DownloadTestObserverTerminal download_terminal_observer( | 677 content::DownloadTestObserverTerminal download_terminal_observer( |
684 GetDownloadManager(browser()), | 678 GetDownloadManager(browser()), |
685 1u, /* wait_count */ | 679 1u, /* wait_count */ |
686 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 680 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
687 | 681 |
(...skipping 19 matching lines...) Expand all Loading... |
707 EXPECT_NE(GetNotification(notification_id())->message().find( | 701 EXPECT_NE(GetNotification(notification_id())->message().find( |
708 l10n_util::GetStringFUTF16( | 702 l10n_util::GetStringFUTF16( |
709 IDS_DOWNLOAD_STATUS_INTERRUPTED, | 703 IDS_DOWNLOAD_STATUS_INTERRUPTED, |
710 l10n_util::GetStringUTF16( | 704 l10n_util::GetStringUTF16( |
711 IDS_DOWNLOAD_INTERRUPTED_DESCRIPTION_NETWORK_ERROR))), | 705 IDS_DOWNLOAD_INTERRUPTED_DESCRIPTION_NETWORK_ERROR))), |
712 std::string::npos); | 706 std::string::npos); |
713 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 707 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
714 GetNotification(notification_id())->type()); | 708 GetNotification(notification_id())->type()); |
715 } | 709 } |
716 | 710 |
717 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
718 #if defined(OS_CHROMEOS) | |
719 #define MAYBE_InterruptDownloadAfterClosingNotification DISABLED_InterruptDownlo
adAfterClosingNotification | |
720 #else | |
721 #define MAYBE_InterruptDownloadAfterClosingNotification InterruptDownloadAfterCl
osingNotification | |
722 #endif | |
723 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 711 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
724 MAYBE_InterruptDownloadAfterClosingNotification) { | 712 InterruptDownloadAfterClosingNotification) { |
725 CreateDownload(); | 713 CreateDownload(); |
726 | 714 |
727 // Closes the notification. | 715 // Closes the notification. |
728 NotificationRemoveObserver notification_close_observer; | 716 NotificationRemoveObserver notification_close_observer; |
729 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); | 717 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); |
730 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 718 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
731 | 719 |
732 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 720 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
733 | 721 |
734 // Confirms that a download is still in progress. | 722 // Confirms that a download is still in progress. |
(...skipping 18 matching lines...) Expand all Loading... |
753 // Waits that new notification. | 741 // Waits that new notification. |
754 download_notification_add_observer.Wait(); | 742 download_notification_add_observer.Wait(); |
755 | 743 |
756 // Confirms that there is only one notification. | 744 // Confirms that there is only one notification. |
757 message_center::NotificationList::Notifications | 745 message_center::NotificationList::Notifications |
758 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); | 746 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); |
759 EXPECT_EQ(1u, visible_notifications.size()); | 747 EXPECT_EQ(1u, visible_notifications.size()); |
760 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); | 748 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); |
761 } | 749 } |
762 | 750 |
763 // TODO(yoshiki): Disabled due to crbug.com/560329 | 751 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadRemoved) { |
764 #if defined(OS_CHROMEOS) | |
765 #define MAYBE_DownloadRemoved DISABLED_DownloadRemoved | |
766 #else | |
767 #define MAYBE_DownloadRemoved DownloadRemoved | |
768 #endif | |
769 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DownloadRemoved) { | |
770 CreateDownload(); | 752 CreateDownload(); |
771 | 753 |
772 NotificationRemoveObserver notification_close_observer; | 754 NotificationRemoveObserver notification_close_observer; |
773 download_item()->Remove(); | 755 download_item()->Remove(); |
774 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 756 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
775 | 757 |
776 // Confirms that the notification is removed. | 758 // Confirms that the notification is removed. |
777 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 759 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
778 | 760 |
779 // Confirms that the download item is removed. | 761 // Confirms that the download item is removed. |
780 std::vector<content::DownloadItem*> downloads; | 762 std::vector<content::DownloadItem*> downloads; |
781 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 763 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
782 EXPECT_EQ(0u, downloads.size()); | 764 EXPECT_EQ(0u, downloads.size()); |
783 } | 765 } |
784 | 766 |
785 // TODO(yoshiki): Disabled due to crbug.com/560329 | 767 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadMultipleFiles) { |
786 #if defined(OS_CHROMEOS) | |
787 #define MAYBE_DownloadMultipleFiles DISABLED_DownloadMultipleFiles | |
788 #else | |
789 #define MAYBE_DownloadMultipleFiles DownloadMultipleFiles | |
790 #endif | |
791 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_DownloadMultipleFiles) { | |
792 GURL url1(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); | 768 GURL url1(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); |
793 GURL url2(net::URLRequestSlowDownloadJob::kKnownSizeUrl); | 769 GURL url2(net::URLRequestSlowDownloadJob::kKnownSizeUrl); |
794 | 770 |
795 // Starts the 1st download. | 771 // Starts the 1st download. |
796 NotificationAddObserver download_start_notification_observer1; | 772 NotificationAddObserver download_start_notification_observer1; |
797 ui_test_utils::NavigateToURL(browser(), url1); | 773 ui_test_utils::NavigateToURL(browser(), url1); |
798 EXPECT_TRUE(download_start_notification_observer1.Wait()); | 774 EXPECT_TRUE(download_start_notification_observer1.Wait()); |
799 std::string notification_id1 = | 775 std::string notification_id1 = |
800 download_start_notification_observer1.notification_id(); | 776 download_start_notification_observer1.notification_id(); |
801 EXPECT_FALSE(notification_id1.empty()); | 777 EXPECT_FALSE(notification_id1.empty()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 EXPECT_EQ(message_center::DEFAULT_PRIORITY, | 889 EXPECT_EQ(message_center::DEFAULT_PRIORITY, |
914 GetNotification(notification_id2)->priority()); | 890 GetNotification(notification_id2)->priority()); |
915 | 891 |
916 // Confirms the types of download notifications are correct. | 892 // Confirms the types of download notifications are correct. |
917 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 893 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
918 GetNotification(notification_id1)->type()); | 894 GetNotification(notification_id1)->type()); |
919 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 895 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
920 GetNotification(notification_id2)->type()); | 896 GetNotification(notification_id2)->type()); |
921 } | 897 } |
922 | 898 |
923 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
924 #if defined(OS_CHROMEOS) | |
925 #define MAYBE_DownloadMultipleFilesOneByOne DISABLED_DownloadMultipleFilesOneByO
ne | |
926 #else | |
927 #define MAYBE_DownloadMultipleFilesOneByOne DownloadMultipleFilesOneByOne | |
928 #endif | |
929 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 899 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
930 MAYBE_DownloadMultipleFilesOneByOne) { | 900 DownloadMultipleFilesOneByOne) { |
931 CreateDownload(); | 901 CreateDownload(); |
932 content::DownloadItem* first_download_item = download_item(); | 902 content::DownloadItem* first_download_item = download_item(); |
933 content::DownloadItem* second_download_item = nullptr; | 903 content::DownloadItem* second_download_item = nullptr; |
934 std::string first_notification_id = notification_id(); | 904 std::string first_notification_id = notification_id(); |
935 std::string second_notification_id; | 905 std::string second_notification_id; |
936 | 906 |
937 // Requests to complete the first download. | 907 // Requests to complete the first download. |
938 ui_test_utils::NavigateToURL( | 908 ui_test_utils::NavigateToURL( |
939 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 909 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
940 | 910 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 download_change_notification_observer2.Wait(); | 966 download_change_notification_observer2.Wait(); |
997 download_change_notification_observer2.Reset(); | 967 download_change_notification_observer2.Reset(); |
998 } | 968 } |
999 | 969 |
1000 // Opens the message center. | 970 // Opens the message center. |
1001 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 971 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
1002 // Checks the message center. | 972 // Checks the message center. |
1003 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); | 973 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); |
1004 } | 974 } |
1005 | 975 |
1006 // TODO(yoshiki): Disabled due to crbug.com/560329 | 976 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { |
1007 #if defined(OS_CHROMEOS) | |
1008 #define MAYBE_CancelDownload DISABLED_CancelDownload | |
1009 #else | |
1010 #define MAYBE_CancelDownload CancelDownload | |
1011 #endif | |
1012 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_CancelDownload) { | |
1013 CreateDownload(); | 977 CreateDownload(); |
1014 | 978 |
1015 // Opens the message center. | 979 // Opens the message center. |
1016 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 980 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
1017 | 981 |
1018 // Cancels the notification by clicking the "cancel' button. | 982 // Cancels the notification by clicking the "cancel' button. |
1019 NotificationRemoveObserver notification_close_observer; | 983 NotificationRemoveObserver notification_close_observer; |
1020 notification()->ButtonClick(1); | 984 notification()->ButtonClick(1); |
1021 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 985 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
1022 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 986 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
1023 | 987 |
1024 // Confirms that a download is also cancelled. | 988 // Confirms that a download is also cancelled. |
1025 std::vector<content::DownloadItem*> downloads; | 989 std::vector<content::DownloadItem*> downloads; |
1026 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 990 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
1027 EXPECT_EQ(1u, downloads.size()); | 991 EXPECT_EQ(1u, downloads.size()); |
1028 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 992 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
1029 } | 993 } |
1030 | 994 |
1031 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
1032 #if defined(OS_CHROMEOS) | |
1033 #define MAYBE_DownloadCancelledByUserExternally DISABLED_DownloadCancelledByUser
Externally | |
1034 #else | |
1035 #define MAYBE_DownloadCancelledByUserExternally DownloadCancelledByUserExternall
y | |
1036 #endif | |
1037 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 995 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
1038 MAYBE_DownloadCancelledByUserExternally) { | 996 DownloadCancelledByUserExternally) { |
1039 CreateDownload(); | 997 CreateDownload(); |
1040 | 998 |
1041 // Cancels the notification by clicking the "cancel' button. | 999 // Cancels the notification by clicking the "cancel' button. |
1042 NotificationRemoveObserver notification_close_observer; | 1000 NotificationRemoveObserver notification_close_observer; |
1043 download_item()->Cancel(true /* by_user */); | 1001 download_item()->Cancel(true /* by_user */); |
1044 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 1002 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
1045 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 1003 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
1046 | 1004 |
1047 // Confirms that a download is also cancelled. | 1005 // Confirms that a download is also cancelled. |
1048 std::vector<content::DownloadItem*> downloads; | 1006 std::vector<content::DownloadItem*> downloads; |
1049 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 1007 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
1050 EXPECT_EQ(1u, downloads.size()); | 1008 EXPECT_EQ(1u, downloads.size()); |
1051 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 1009 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
1052 } | 1010 } |
1053 | 1011 |
1054 // TODO(yoshiki): Disabled due to crbug.com/560329 | |
1055 #if defined(OS_CHROMEOS) | |
1056 #define MAYBE_DownloadCancelledExternally DISABLED_DownloadCancelledExternally | |
1057 #else | |
1058 #define MAYBE_DownloadCancelledExternally DownloadCancelledExternally | |
1059 #endif | |
1060 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 1012 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
1061 MAYBE_DownloadCancelledExternally) { | 1013 DownloadCancelledExternally) { |
1062 CreateDownload(); | 1014 CreateDownload(); |
1063 | 1015 |
1064 // Cancels the notification by clicking the "cancel' button. | 1016 // Cancels the notification by clicking the "cancel' button. |
1065 NotificationRemoveObserver notification_close_observer; | 1017 NotificationRemoveObserver notification_close_observer; |
1066 download_item()->Cancel(false /* by_user */); | 1018 download_item()->Cancel(false /* by_user */); |
1067 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 1019 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
1068 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 1020 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
1069 | 1021 |
1070 // Confirms that a download is also cancelled. | 1022 // Confirms that a download is also cancelled. |
1071 std::vector<content::DownloadItem*> downloads; | 1023 std::vector<content::DownloadItem*> downloads; |
1072 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 1024 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
1073 EXPECT_EQ(1u, downloads.size()); | 1025 EXPECT_EQ(1u, downloads.size()); |
1074 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 1026 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
1075 } | 1027 } |
1076 | 1028 |
1077 // TODO(yoshiki): Disabled due to crbug.com/560329 | 1029 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, IncognitoDownloadFile) { |
1078 #if defined(OS_CHROMEOS) | |
1079 #define MAYBE_IncognitoDownloadFile DISABLED_IncognitoDownloadFile | |
1080 #else | |
1081 #define MAYBE_IncognitoDownloadFile IncognitoDownloadFile | |
1082 #endif | |
1083 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, MAYBE_IncognitoDownloadFile) { | |
1084 PrepareIncognitoBrowser(); | 1030 PrepareIncognitoBrowser(); |
1085 | 1031 |
1086 // Starts an incognito download. | 1032 // Starts an incognito download. |
1087 CreateDownloadForBrowserAndURL( | 1033 CreateDownloadForBrowserAndURL( |
1088 incognito_browser(), | 1034 incognito_browser(), |
1089 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl)); | 1035 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl)); |
1090 | 1036 |
1091 EXPECT_EQ(l10n_util::GetStringFUTF16( | 1037 EXPECT_EQ(l10n_util::GetStringFUTF16( |
1092 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, | 1038 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, |
1093 download_item()->GetFileNameToReportUser().LossyDisplayName()), | 1039 download_item()->GetFileNameToReportUser().LossyDisplayName()), |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1313 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1368 GetNotification(notification_id_user1)->type()); | 1314 GetNotification(notification_id_user1)->type()); |
1369 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1315 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1370 GetNotification(notification_id_user2_1)->type()); | 1316 GetNotification(notification_id_user2_1)->type()); |
1371 // Normal notifications for user2. | 1317 // Normal notifications for user2. |
1372 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1318 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1373 GetNotification(notification_id_user2_1)->type()); | 1319 GetNotification(notification_id_user2_1)->type()); |
1374 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1320 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1375 GetNotification(notification_id_user2_2)->type()); | 1321 GetNotification(notification_id_user2_2)->type()); |
1376 } | 1322 } |
OLD | NEW |