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

Side by Side Diff: chrome/browser/download/notification/download_notification_browsertest.cc

Issue 1271693006: Don't show the group notification when there is only one in-progress download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 5 years, 4 months 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
« no previous file with comments | « chrome/browser/download/notification/download_group_notification.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 // Confirms the types of download notifications are correct. 777 // Confirms the types of download notifications are correct.
778 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 778 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
779 GetNotification(notification_id1)->type()); 779 GetNotification(notification_id1)->type());
780 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 780 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
781 GetNotification(notification_id2)->type()); 781 GetNotification(notification_id2)->type());
782 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, 782 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE,
783 GetNotification(notification_id_group)->type()); 783 GetNotification(notification_id_group)->type());
784 EXPECT_EQ(2u, GetNotification(notification_id_group)->items().size()); 784 EXPECT_EQ(2u, GetNotification(notification_id_group)->items().size());
785 } 785 }
786 786
787 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest,
788 DownloadMultipleFilesOneByOne) {
789 CreateDownload();
790 content::DownloadItem* first_download_item = download_item();
791 content::DownloadItem* second_download_item = nullptr;
792 std::string first_notification_id = notification_id();
793 std::string second_notification_id;
794
795 // Requests to complete the first download.
796 ui_test_utils::NavigateToURL(
797 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
798
799 // Waits for completion of the first download.
800 while (first_download_item->GetState() != content::DownloadItem::COMPLETE) {
801 NotificationUpdateObserver download_change_notification_observer;
802 download_change_notification_observer.Wait();
803 }
804 EXPECT_EQ(content::DownloadItem::COMPLETE, first_download_item->GetState());
805
806 // Checks the message center.
807 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
808
809 // Starts the second download.
810 GURL url(net::URLRequestSlowDownloadJob::kKnownSizeUrl);
811 NotificationAddObserver download_start_notification_observer;
812 ui_test_utils::NavigateToURL(browser(), url);
813 EXPECT_TRUE(download_start_notification_observer.Wait());
814
815 // Confirms that the second notification is created.
816 second_notification_id =
817 download_start_notification_observer.notification_id();
818 EXPECT_FALSE(second_notification_id.empty());
819 ASSERT_TRUE(GetNotification(second_notification_id));
820
821 // Confirms that there are two notifications, including the second
822 // notification.
823 message_center::NotificationList::Notifications
824 visible_notifications = GetMessageCenter()->GetVisibleNotifications();
825 EXPECT_EQ(2u, visible_notifications.size());
826 EXPECT_TRUE(IsInNotifications(visible_notifications, first_notification_id));
827 EXPECT_TRUE(IsInNotifications(visible_notifications, second_notification_id));
828
829 // Confirms that the second download is also started.
830 std::vector<content::DownloadItem*> downloads;
831 GetDownloadManager(browser())->GetAllDownloads(&downloads);
832 EXPECT_EQ(2u, downloads.size());
833 EXPECT_TRUE(first_download_item == downloads[0] ||
834 first_download_item == downloads[1]);
835 // Stores the second download.
836 if (first_download_item == downloads[0])
837 second_download_item = downloads[1];
838 else
839 second_download_item = downloads[0];
840
841 EXPECT_EQ(content::DownloadItem::IN_PROGRESS,
842 second_download_item->GetState());
843
844 // Requests to complete the second download.
845 ui_test_utils::NavigateToURL(
846 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
847
848 // Waits for completion of the second download.
849 while (second_download_item->GetState() != content::DownloadItem::COMPLETE) {
850 NotificationUpdateObserver download_change_notification_observer;
851 download_change_notification_observer.Wait();
852 }
853
854 // Opens the message center.
855 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
856 // Checks the message center.
857 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size());
858 }
859
787 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { 860 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) {
788 CreateDownload(); 861 CreateDownload();
789 862
790 // Opens the message center. 863 // Opens the message center.
791 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); 864 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
792 865
793 // Cancels the notification by clicking the "cancel' button. 866 // Cancels the notification by clicking the "cancel' button.
794 NotificationRemoveObserver notification_close_observer; 867 NotificationRemoveObserver notification_close_observer;
795 notification()->ButtonClick(1); 868 notification()->ButtonClick(1);
796 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); 869 EXPECT_EQ(notification_id(), notification_close_observer.Wait());
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, 1203 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE,
1131 GetNotification(notification_id_user2_group)->type()); 1204 GetNotification(notification_id_user2_group)->type());
1132 EXPECT_EQ(2u, 1205 EXPECT_EQ(2u,
1133 GetNotification(notification_id_user2_group)->items().size()); 1206 GetNotification(notification_id_user2_group)->items().size());
1134 // Normal notifications for user2. 1207 // Normal notifications for user2.
1135 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1208 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1136 GetNotification(notification_id_user2_1)->type()); 1209 GetNotification(notification_id_user2_1)->type());
1137 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1210 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1138 GetNotification(notification_id_user2_2)->type()); 1211 GetNotification(notification_id_user2_2)->type());
1139 } 1212 }
OLDNEW
« no previous file with comments | « chrome/browser/download/notification/download_group_notification.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698