| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 return DownloadPrefs::FromDownloadManager(GetDownloadManager(browser()))-> | 378 return DownloadPrefs::FromDownloadManager(GetDownloadManager(browser()))-> |
| 379 DownloadPath(); | 379 DownloadPath(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 private: | 382 private: |
| 383 content::DownloadItem* download_item_ = nullptr; | 383 content::DownloadItem* download_item_ = nullptr; |
| 384 Browser* incognito_browser_ = nullptr; | 384 Browser* incognito_browser_ = nullptr; |
| 385 std::string notification_id_; | 385 std::string notification_id_; |
| 386 }; | 386 }; |
| 387 | 387 |
| 388 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadFile) { | 388 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 389 CreateDownload(); | 395 CreateDownload(); |
| 390 | 396 |
| 391 EXPECT_EQ(l10n_util::GetStringFUTF16( | 397 EXPECT_EQ(l10n_util::GetStringFUTF16( |
| 392 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, | 398 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, |
| 393 download_item()->GetFileNameToReportUser().LossyDisplayName()), | 399 download_item()->GetFileNameToReportUser().LossyDisplayName()), |
| 394 GetNotification(notification_id())->title()); | 400 GetNotification(notification_id())->title()); |
| 395 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, | 401 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, |
| 396 GetNotification(notification_id())->type()); | 402 GetNotification(notification_id())->type()); |
| 397 | 403 |
| 398 // Confirms that the download update is delivered to the notification. | 404 // Confirms that the download update is delivered to the notification. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 436 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 431 | 437 |
| 432 // Try to open the downloaded item by clicking the notification. | 438 // Try to open the downloaded item by clicking the notification. |
| 433 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); | 439 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); |
| 434 GetMessageCenter()->ClickOnNotification(notification_id()); | 440 GetMessageCenter()->ClickOnNotification(notification_id()); |
| 435 EXPECT_TRUE(GetDownloadManagerDelegate()->opened()); | 441 EXPECT_TRUE(GetDownloadManagerDelegate()->opened()); |
| 436 | 442 |
| 437 EXPECT_FALSE(GetNotification(notification_id())); | 443 EXPECT_FALSE(GetNotification(notification_id())); |
| 438 } | 444 } |
| 439 | 445 |
| 440 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadDangerousFile) { | 446 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 441 GURL download_url(embedded_test_server()->GetURL( | 453 GURL download_url(embedded_test_server()->GetURL( |
| 442 "/downloads/dangerous/dangerous.swf")); | 454 "/downloads/dangerous/dangerous.swf")); |
| 443 | 455 |
| 444 content::DownloadTestObserverTerminal download_terminal_observer( | 456 content::DownloadTestObserverTerminal download_terminal_observer( |
| 445 GetDownloadManager(browser()), | 457 GetDownloadManager(browser()), |
| 446 1u, /* wait_count */ | 458 1u, /* wait_count */ |
| 447 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 459 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
| 448 | 460 |
| 449 CreateDownloadForBrowserAndURL(browser(), download_url); | 461 CreateDownloadForBrowserAndURL(browser(), download_url); |
| 450 | 462 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 481 download_terminal_observer.WaitForFinished(); | 493 download_terminal_observer.WaitForFinished(); |
| 482 | 494 |
| 483 // Checks the download status. | 495 // Checks the download status. |
| 484 EXPECT_FALSE(download_item()->IsDangerous()); | 496 EXPECT_FALSE(download_item()->IsDangerous()); |
| 485 EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); | 497 EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); |
| 486 | 498 |
| 487 // Checks the downloaded file. | 499 // Checks the downloaded file. |
| 488 EXPECT_TRUE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 500 EXPECT_TRUE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
| 489 } | 501 } |
| 490 | 502 |
| 491 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DiscardDangerousFile) { | 503 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 492 GURL download_url(embedded_test_server()->GetURL( | 510 GURL download_url(embedded_test_server()->GetURL( |
| 493 "/downloads/dangerous/dangerous.swf")); | 511 "/downloads/dangerous/dangerous.swf")); |
| 494 | 512 |
| 495 content::DownloadTestObserverTerminal download_terminal_observer( | 513 content::DownloadTestObserverTerminal download_terminal_observer( |
| 496 GetDownloadManager(browser()), | 514 GetDownloadManager(browser()), |
| 497 1u, /* wait_count */ | 515 1u, /* wait_count */ |
| 498 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 516 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
| 499 | 517 |
| 500 CreateDownloadForBrowserAndURL(browser(), download_url); | 518 CreateDownloadForBrowserAndURL(browser(), download_url); |
| 501 | 519 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 530 // Checks there is neither any download nor any notification. | 548 // Checks there is neither any download nor any notification. |
| 531 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 549 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 532 std::vector<content::DownloadItem*> downloads; | 550 std::vector<content::DownloadItem*> downloads; |
| 533 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 551 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 534 EXPECT_EQ(0u, downloads.size()); | 552 EXPECT_EQ(0u, downloads.size()); |
| 535 | 553 |
| 536 // Checks the downloaded file doesn't exist. | 554 // Checks the downloaded file doesn't exist. |
| 537 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 555 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
| 538 } | 556 } |
| 539 | 557 |
| 540 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadImageFile) { | 558 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 541 GURL download_url(embedded_test_server()->GetURL( | 565 GURL download_url(embedded_test_server()->GetURL( |
| 542 "/downloads/image-octet-stream.png")); | 566 "/downloads/image-octet-stream.png")); |
| 543 | 567 |
| 544 content::DownloadTestObserverTerminal download_terminal_observer( | 568 content::DownloadTestObserverTerminal download_terminal_observer( |
| 545 GetDownloadManager(browser()), 1u, /* wait_count */ | 569 GetDownloadManager(browser()), 1u, /* wait_count */ |
| 546 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | 570 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
| 547 | 571 |
| 548 CreateDownloadForBrowserAndURL(browser(), download_url); | 572 CreateDownloadForBrowserAndURL(browser(), download_url); |
| 549 | 573 |
| 550 // Wait for the download completion. | 574 // Wait for the download completion. |
| 551 download_terminal_observer.WaitForFinished(); | 575 download_terminal_observer.WaitForFinished(); |
| 552 | 576 |
| 553 // Waits for download completion. | 577 // Waits for download completion. |
| 554 NotificationUpdateObserver | 578 NotificationUpdateObserver |
| 555 download_change_notification_observer(notification_id()); | 579 download_change_notification_observer(notification_id()); |
| 556 while (GetNotification(notification_id())->image().IsEmpty()) { | 580 while (GetNotification(notification_id())->image().IsEmpty()) { |
| 557 download_change_notification_observer.Wait(); | 581 download_change_notification_observer.Wait(); |
| 558 download_change_notification_observer.Reset(); | 582 download_change_notification_observer.Reset(); |
| 559 } | 583 } |
| 560 } | 584 } |
| 561 | 585 |
| 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 |
| 562 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 592 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 563 CloseNotificationAfterDownload) { | 593 MAYBE_CloseNotificationAfterDownload) { |
| 564 CreateDownload(); | 594 CreateDownload(); |
| 565 | 595 |
| 566 // Requests to complete the download. | 596 // Requests to complete the download. |
| 567 ui_test_utils::NavigateToURL( | 597 ui_test_utils::NavigateToURL( |
| 568 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 598 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| 569 | 599 |
| 570 // Waits for download completion. | 600 // Waits for download completion. |
| 571 NotificationUpdateObserver | 601 NotificationUpdateObserver |
| 572 download_change_notification_observer(notification_id()); | 602 download_change_notification_observer(notification_id()); |
| 573 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 603 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 585 | 615 |
| 586 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 616 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 587 | 617 |
| 588 // Confirms that a download is also started. | 618 // Confirms that a download is also started. |
| 589 std::vector<content::DownloadItem*> downloads; | 619 std::vector<content::DownloadItem*> downloads; |
| 590 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 620 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 591 EXPECT_EQ(1u, downloads.size()); | 621 EXPECT_EQ(1u, downloads.size()); |
| 592 EXPECT_EQ(content::DownloadItem::COMPLETE, downloads[0]->GetState()); | 622 EXPECT_EQ(content::DownloadItem::COMPLETE, downloads[0]->GetState()); |
| 593 } | 623 } |
| 594 | 624 |
| 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 |
| 595 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 631 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 596 CloseNotificationWhileDownloading) { | 632 MAYBE_CloseNotificationWhileDownloading) { |
| 597 CreateDownload(); | 633 CreateDownload(); |
| 598 | 634 |
| 599 // Closes the notification. | 635 // Closes the notification. |
| 600 NotificationRemoveObserver notification_close_observer; | 636 NotificationRemoveObserver notification_close_observer; |
| 601 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); | 637 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); |
| 602 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 638 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 603 | 639 |
| 604 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 640 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 605 | 641 |
| 606 // Confirms that a download is still in progress. | 642 // Confirms that a download is still in progress. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 625 // Waits that new notification. | 661 // Waits that new notification. |
| 626 download_notification_add_observer.Wait(); | 662 download_notification_add_observer.Wait(); |
| 627 | 663 |
| 628 // Confirms that there is only one notification. | 664 // Confirms that there is only one notification. |
| 629 message_center::NotificationList::Notifications | 665 message_center::NotificationList::Notifications |
| 630 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); | 666 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); |
| 631 EXPECT_EQ(1u, visible_notifications.size()); | 667 EXPECT_EQ(1u, visible_notifications.size()); |
| 632 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); | 668 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); |
| 633 } | 669 } |
| 634 | 670 |
| 635 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, InterruptDownload) { | 671 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 636 CreateDownload(); | 678 CreateDownload(); |
| 637 | 679 |
| 638 // Installs observers before requesting. | 680 // Installs observers before requesting. |
| 639 NotificationUpdateObserver | 681 NotificationUpdateObserver |
| 640 download_notification_update_observer(notification_id()); | 682 download_notification_update_observer(notification_id()); |
| 641 content::DownloadTestObserverTerminal download_terminal_observer( | 683 content::DownloadTestObserverTerminal download_terminal_observer( |
| 642 GetDownloadManager(browser()), | 684 GetDownloadManager(browser()), |
| 643 1u, /* wait_count */ | 685 1u, /* wait_count */ |
| 644 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 686 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
| 645 | 687 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 665 EXPECT_NE(GetNotification(notification_id())->message().find( | 707 EXPECT_NE(GetNotification(notification_id())->message().find( |
| 666 l10n_util::GetStringFUTF16( | 708 l10n_util::GetStringFUTF16( |
| 667 IDS_DOWNLOAD_STATUS_INTERRUPTED, | 709 IDS_DOWNLOAD_STATUS_INTERRUPTED, |
| 668 l10n_util::GetStringUTF16( | 710 l10n_util::GetStringUTF16( |
| 669 IDS_DOWNLOAD_INTERRUPTED_DESCRIPTION_NETWORK_ERROR))), | 711 IDS_DOWNLOAD_INTERRUPTED_DESCRIPTION_NETWORK_ERROR))), |
| 670 std::string::npos); | 712 std::string::npos); |
| 671 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 713 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 672 GetNotification(notification_id())->type()); | 714 GetNotification(notification_id())->type()); |
| 673 } | 715 } |
| 674 | 716 |
| 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 |
| 675 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 723 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 676 InterruptDownloadAfterClosingNotification) { | 724 MAYBE_InterruptDownloadAfterClosingNotification) { |
| 677 CreateDownload(); | 725 CreateDownload(); |
| 678 | 726 |
| 679 // Closes the notification. | 727 // Closes the notification. |
| 680 NotificationRemoveObserver notification_close_observer; | 728 NotificationRemoveObserver notification_close_observer; |
| 681 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); | 729 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); |
| 682 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 730 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 683 | 731 |
| 684 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 732 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 685 | 733 |
| 686 // Confirms that a download is still in progress. | 734 // Confirms that a download is still in progress. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 705 // Waits that new notification. | 753 // Waits that new notification. |
| 706 download_notification_add_observer.Wait(); | 754 download_notification_add_observer.Wait(); |
| 707 | 755 |
| 708 // Confirms that there is only one notification. | 756 // Confirms that there is only one notification. |
| 709 message_center::NotificationList::Notifications | 757 message_center::NotificationList::Notifications |
| 710 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); | 758 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); |
| 711 EXPECT_EQ(1u, visible_notifications.size()); | 759 EXPECT_EQ(1u, visible_notifications.size()); |
| 712 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); | 760 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); |
| 713 } | 761 } |
| 714 | 762 |
| 715 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadRemoved) { | 763 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 716 CreateDownload(); | 770 CreateDownload(); |
| 717 | 771 |
| 718 NotificationRemoveObserver notification_close_observer; | 772 NotificationRemoveObserver notification_close_observer; |
| 719 download_item()->Remove(); | 773 download_item()->Remove(); |
| 720 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 774 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 721 | 775 |
| 722 // Confirms that the notification is removed. | 776 // Confirms that the notification is removed. |
| 723 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 777 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 724 | 778 |
| 725 // Confirms that the download item is removed. | 779 // Confirms that the download item is removed. |
| 726 std::vector<content::DownloadItem*> downloads; | 780 std::vector<content::DownloadItem*> downloads; |
| 727 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 781 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 728 EXPECT_EQ(0u, downloads.size()); | 782 EXPECT_EQ(0u, downloads.size()); |
| 729 } | 783 } |
| 730 | 784 |
| 731 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadMultipleFiles) { | 785 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 732 GURL url1(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); | 792 GURL url1(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 733 GURL url2(net::URLRequestSlowDownloadJob::kKnownSizeUrl); | 793 GURL url2(net::URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 734 | 794 |
| 735 // Starts the 1st download. | 795 // Starts the 1st download. |
| 736 NotificationAddObserver download_start_notification_observer1; | 796 NotificationAddObserver download_start_notification_observer1; |
| 737 ui_test_utils::NavigateToURL(browser(), url1); | 797 ui_test_utils::NavigateToURL(browser(), url1); |
| 738 EXPECT_TRUE(download_start_notification_observer1.Wait()); | 798 EXPECT_TRUE(download_start_notification_observer1.Wait()); |
| 739 std::string notification_id1 = | 799 std::string notification_id1 = |
| 740 download_start_notification_observer1.notification_id(); | 800 download_start_notification_observer1.notification_id(); |
| 741 EXPECT_FALSE(notification_id1.empty()); | 801 EXPECT_FALSE(notification_id1.empty()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 EXPECT_EQ(message_center::DEFAULT_PRIORITY, | 913 EXPECT_EQ(message_center::DEFAULT_PRIORITY, |
| 854 GetNotification(notification_id2)->priority()); | 914 GetNotification(notification_id2)->priority()); |
| 855 | 915 |
| 856 // Confirms the types of download notifications are correct. | 916 // Confirms the types of download notifications are correct. |
| 857 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 917 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 858 GetNotification(notification_id1)->type()); | 918 GetNotification(notification_id1)->type()); |
| 859 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 919 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 860 GetNotification(notification_id2)->type()); | 920 GetNotification(notification_id2)->type()); |
| 861 } | 921 } |
| 862 | 922 |
| 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 |
| 863 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 929 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 864 DownloadMultipleFilesOneByOne) { | 930 MAYBE_DownloadMultipleFilesOneByOne) { |
| 865 CreateDownload(); | 931 CreateDownload(); |
| 866 content::DownloadItem* first_download_item = download_item(); | 932 content::DownloadItem* first_download_item = download_item(); |
| 867 content::DownloadItem* second_download_item = nullptr; | 933 content::DownloadItem* second_download_item = nullptr; |
| 868 std::string first_notification_id = notification_id(); | 934 std::string first_notification_id = notification_id(); |
| 869 std::string second_notification_id; | 935 std::string second_notification_id; |
| 870 | 936 |
| 871 // Requests to complete the first download. | 937 // Requests to complete the first download. |
| 872 ui_test_utils::NavigateToURL( | 938 ui_test_utils::NavigateToURL( |
| 873 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 939 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| 874 | 940 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 download_change_notification_observer2.Wait(); | 996 download_change_notification_observer2.Wait(); |
| 931 download_change_notification_observer2.Reset(); | 997 download_change_notification_observer2.Reset(); |
| 932 } | 998 } |
| 933 | 999 |
| 934 // Opens the message center. | 1000 // Opens the message center. |
| 935 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 1001 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 936 // Checks the message center. | 1002 // Checks the message center. |
| 937 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); | 1003 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 938 } | 1004 } |
| 939 | 1005 |
| 940 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { | 1006 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 941 CreateDownload(); | 1013 CreateDownload(); |
| 942 | 1014 |
| 943 // Opens the message center. | 1015 // Opens the message center. |
| 944 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 1016 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| 945 | 1017 |
| 946 // Cancels the notification by clicking the "cancel' button. | 1018 // Cancels the notification by clicking the "cancel' button. |
| 947 NotificationRemoveObserver notification_close_observer; | 1019 NotificationRemoveObserver notification_close_observer; |
| 948 notification()->ButtonClick(1); | 1020 notification()->ButtonClick(1); |
| 949 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 1021 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 950 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 1022 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 951 | 1023 |
| 952 // Confirms that a download is also cancelled. | 1024 // Confirms that a download is also cancelled. |
| 953 std::vector<content::DownloadItem*> downloads; | 1025 std::vector<content::DownloadItem*> downloads; |
| 954 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 1026 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 955 EXPECT_EQ(1u, downloads.size()); | 1027 EXPECT_EQ(1u, downloads.size()); |
| 956 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 1028 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
| 957 } | 1029 } |
| 958 | 1030 |
| 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 |
| 959 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 1037 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 960 DownloadCancelledByUserExternally) { | 1038 MAYBE_DownloadCancelledByUserExternally) { |
| 961 CreateDownload(); | 1039 CreateDownload(); |
| 962 | 1040 |
| 963 // Cancels the notification by clicking the "cancel' button. | 1041 // Cancels the notification by clicking the "cancel' button. |
| 964 NotificationRemoveObserver notification_close_observer; | 1042 NotificationRemoveObserver notification_close_observer; |
| 965 download_item()->Cancel(true /* by_user */); | 1043 download_item()->Cancel(true /* by_user */); |
| 966 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 1044 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 967 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 1045 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 968 | 1046 |
| 969 // Confirms that a download is also cancelled. | 1047 // Confirms that a download is also cancelled. |
| 970 std::vector<content::DownloadItem*> downloads; | 1048 std::vector<content::DownloadItem*> downloads; |
| 971 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 1049 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 972 EXPECT_EQ(1u, downloads.size()); | 1050 EXPECT_EQ(1u, downloads.size()); |
| 973 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 1051 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
| 974 } | 1052 } |
| 975 | 1053 |
| 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 |
| 976 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 1060 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 977 DownloadCancelledExternally) { | 1061 MAYBE_DownloadCancelledExternally) { |
| 978 CreateDownload(); | 1062 CreateDownload(); |
| 979 | 1063 |
| 980 // Cancels the notification by clicking the "cancel' button. | 1064 // Cancels the notification by clicking the "cancel' button. |
| 981 NotificationRemoveObserver notification_close_observer; | 1065 NotificationRemoveObserver notification_close_observer; |
| 982 download_item()->Cancel(false /* by_user */); | 1066 download_item()->Cancel(false /* by_user */); |
| 983 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 1067 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
| 984 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 1068 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 985 | 1069 |
| 986 // Confirms that a download is also cancelled. | 1070 // Confirms that a download is also cancelled. |
| 987 std::vector<content::DownloadItem*> downloads; | 1071 std::vector<content::DownloadItem*> downloads; |
| 988 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 1072 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 989 EXPECT_EQ(1u, downloads.size()); | 1073 EXPECT_EQ(1u, downloads.size()); |
| 990 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); | 1074 EXPECT_EQ(content::DownloadItem::CANCELLED, downloads[0]->GetState()); |
| 991 } | 1075 } |
| 992 | 1076 |
| 993 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, IncognitoDownloadFile) { | 1077 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 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) { |
| 994 PrepareIncognitoBrowser(); | 1084 PrepareIncognitoBrowser(); |
| 995 | 1085 |
| 996 // Starts an incognito download. | 1086 // Starts an incognito download. |
| 997 CreateDownloadForBrowserAndURL( | 1087 CreateDownloadForBrowserAndURL( |
| 998 incognito_browser(), | 1088 incognito_browser(), |
| 999 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl)); | 1089 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl)); |
| 1000 | 1090 |
| 1001 EXPECT_EQ(l10n_util::GetStringFUTF16( | 1091 EXPECT_EQ(l10n_util::GetStringFUTF16( |
| 1002 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, | 1092 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, |
| 1003 download_item()->GetFileNameToReportUser().LossyDisplayName()), | 1093 download_item()->GetFileNameToReportUser().LossyDisplayName()), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1032 // Try to open the downloaded item by clicking the notification. | 1122 // Try to open the downloaded item by clicking the notification. |
| 1033 EXPECT_FALSE(GetIncognitoDownloadManagerDelegate()->opened()); | 1123 EXPECT_FALSE(GetIncognitoDownloadManagerDelegate()->opened()); |
| 1034 GetMessageCenter()->ClickOnNotification(notification_id()); | 1124 GetMessageCenter()->ClickOnNotification(notification_id()); |
| 1035 EXPECT_TRUE(GetIncognitoDownloadManagerDelegate()->opened()); | 1125 EXPECT_TRUE(GetIncognitoDownloadManagerDelegate()->opened()); |
| 1036 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); | 1126 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); |
| 1037 | 1127 |
| 1038 EXPECT_FALSE(GetNotification(notification_id())); | 1128 EXPECT_FALSE(GetNotification(notification_id())); |
| 1039 chrome::CloseWindow(incognito_browser()); | 1129 chrome::CloseWindow(incognito_browser()); |
| 1040 } | 1130 } |
| 1041 | 1131 |
| 1132 // TODO(yoshiki): Disabled due to crbug.com/560329 |
| 1133 #if defined(OS_CHROMEOS) |
| 1134 #define MAYBE_SimultaneousIncognitoAndNormalDownloads DISABLED_SimultaneousIncog
nitoAndNormalDownloads |
| 1135 #else |
| 1136 #define MAYBE_SimultaneousIncognitoAndNormalDownloads SimultaneousIncognitoAndNo
rmalDownloads |
| 1137 #endif |
| 1042 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 1138 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 1043 SimultaneousIncognitoAndNormalDownloads) { | 1139 MAYBE_SimultaneousIncognitoAndNormalDownloads) { |
| 1044 PrepareIncognitoBrowser(); | 1140 PrepareIncognitoBrowser(); |
| 1045 | 1141 |
| 1046 GURL url_incognito(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); | 1142 GURL url_incognito(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 1047 GURL url_normal(net::URLRequestSlowDownloadJob::kKnownSizeUrl); | 1143 GURL url_normal(net::URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 1048 | 1144 |
| 1049 // Starts the incognito download. | 1145 // Starts the incognito download. |
| 1050 NotificationAddObserver download_start_notification_observer1; | 1146 NotificationAddObserver download_start_notification_observer1; |
| 1051 ui_test_utils::NavigateToURL(incognito_browser(), url_incognito); | 1147 ui_test_utils::NavigateToURL(incognito_browser(), url_incognito); |
| 1052 EXPECT_TRUE(download_start_notification_observer1.Wait()); | 1148 EXPECT_TRUE(download_start_notification_observer1.Wait()); |
| 1053 std::string notification_id1 = | 1149 std::string notification_id1 = |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1362 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1267 GetNotification(notification_id_user1)->type()); | 1363 GetNotification(notification_id_user1)->type()); |
| 1268 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1364 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1269 GetNotification(notification_id_user2_1)->type()); | 1365 GetNotification(notification_id_user2_1)->type()); |
| 1270 // Normal notifications for user2. | 1366 // Normal notifications for user2. |
| 1271 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1367 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1272 GetNotification(notification_id_user2_1)->type()); | 1368 GetNotification(notification_id_user2_1)->type()); |
| 1273 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1369 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1274 GetNotification(notification_id_user2_2)->type()); | 1370 GetNotification(notification_id_user2_2)->type()); |
| 1275 } | 1371 } |
| OLD | NEW |