Chromium Code Reviews| Index: chrome/browser/download/notification/download_notification_browsertest.cc |
| diff --git a/chrome/browser/download/notification/download_notification_browsertest.cc b/chrome/browser/download/notification/download_notification_browsertest.cc |
| index e8045b8a8a95c9b4a9fb843a44074b6d60a0ba65..ec6e80477c0e1da40ac232f0725f2d60296edabf 100644 |
| --- a/chrome/browser/download/notification/download_notification_browsertest.cc |
| +++ b/chrome/browser/download/notification/download_notification_browsertest.cc |
| @@ -784,6 +784,73 @@ IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadMultipleFiles) { |
| EXPECT_EQ(2u, GetNotification(notification_id_group)->items().size()); |
| } |
| +IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| + DownloadMultipleFilesOneByOne) { |
| + CreateDownload(); |
|
asanka
2015/08/04 21:55:09
I think the fact that this call changes global sta
yoshiki
2015/08/05 09:09:31
I added some comments, and introduced variables fo
|
| + |
| + // Requests to complete the download. |
| + ui_test_utils::NavigateToURL( |
| + browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| + |
| + // Waits for download completion. |
| + while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
| + NotificationUpdateObserver download_change_notification_observer; |
| + download_change_notification_observer.Wait(); |
| + } |
| + EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); |
| + |
| + // Opens the message center. |
| + EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size()); |
| + |
| + // Starts another download. |
| + GURL url(net::URLRequestSlowDownloadJob::kKnownSizeUrl); |
| + NotificationAddObserver download_start_notification_observer; |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + EXPECT_TRUE(download_start_notification_observer.Wait()); |
| + |
| + // Confirms that a notification is created. |
| + std::string second_notification_id = |
| + download_start_notification_observer.notification_id(); |
| + EXPECT_FALSE(second_notification_id.empty()); |
| + ASSERT_TRUE(notification()); |
| + |
| + // Confirms that there is two notification. |
|
asanka
2015/08/04 21:55:09
.. are two notifications...
yoshiki
2015/08/05 09:09:31
Done.
|
| + message_center::NotificationList::Notifications |
| + visible_notifications = GetMessageCenter()->GetVisibleNotifications(); |
| + EXPECT_EQ(2u, visible_notifications.size()); |
| + EXPECT_TRUE(IsInNotifications(visible_notifications, second_notification_id)); |
| + |
| + // Confirms that a download is also started. |
| + std::vector<content::DownloadItem*> downloads; |
| + GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| + EXPECT_EQ(2u, downloads.size()); |
| + EXPECT_TRUE(download_item() == downloads[0] || |
| + download_item() == downloads[1]); |
| + content::DownloadItem* second_download_item; |
| + if (download_item() == downloads[0]) |
| + second_download_item = downloads[1]; |
| + else |
| + second_download_item = downloads[0]; |
| + |
| + EXPECT_EQ(content::DownloadItem::IN_PROGRESS, |
| + second_download_item->GetState()); |
| + |
| + // Requests to complete the download. |
| + ui_test_utils::NavigateToURL( |
| + browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| + |
| + // Waits for download completion. |
| + while (second_download_item->GetState() != content::DownloadItem::COMPLETE) { |
| + NotificationUpdateObserver download_change_notification_observer; |
| + download_change_notification_observer.Wait(); |
| + } |
| + |
| + // Opens the message center. |
| + GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
| + EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); |
| + EXPECT_EQ(content::DownloadItem::COMPLETE, second_download_item->GetState()); |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { |
| CreateDownload(); |