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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(); | |
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
| |
790 | |
791 // Requests to complete the download. | |
792 ui_test_utils::NavigateToURL( | |
793 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | |
794 | |
795 // Waits for download completion. | |
796 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | |
797 NotificationUpdateObserver download_change_notification_observer; | |
798 download_change_notification_observer.Wait(); | |
799 } | |
800 EXPECT_EQ(content::DownloadItem::COMPLETE, download_item()->GetState()); | |
801 | |
802 // Opens the message center. | |
803 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size()); | |
804 | |
805 // Starts another download. | |
806 GURL url(net::URLRequestSlowDownloadJob::kKnownSizeUrl); | |
807 NotificationAddObserver download_start_notification_observer; | |
808 ui_test_utils::NavigateToURL(browser(), url); | |
809 EXPECT_TRUE(download_start_notification_observer.Wait()); | |
810 | |
811 // Confirms that a notification is created. | |
812 std::string second_notification_id = | |
813 download_start_notification_observer.notification_id(); | |
814 EXPECT_FALSE(second_notification_id.empty()); | |
815 ASSERT_TRUE(notification()); | |
816 | |
817 // Confirms that there is two notification. | |
asanka
2015/08/04 21:55:09
.. are two notifications...
yoshiki
2015/08/05 09:09:31
Done.
| |
818 message_center::NotificationList::Notifications | |
819 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); | |
820 EXPECT_EQ(2u, visible_notifications.size()); | |
821 EXPECT_TRUE(IsInNotifications(visible_notifications, second_notification_id)); | |
822 | |
823 // Confirms that a download is also started. | |
824 std::vector<content::DownloadItem*> downloads; | |
825 GetDownloadManager(browser())->GetAllDownloads(&downloads); | |
826 EXPECT_EQ(2u, downloads.size()); | |
827 EXPECT_TRUE(download_item() == downloads[0] || | |
828 download_item() == downloads[1]); | |
829 content::DownloadItem* second_download_item; | |
830 if (download_item() == downloads[0]) | |
831 second_download_item = downloads[1]; | |
832 else | |
833 second_download_item = downloads[0]; | |
834 | |
835 EXPECT_EQ(content::DownloadItem::IN_PROGRESS, | |
836 second_download_item->GetState()); | |
837 | |
838 // Requests to complete the download. | |
839 ui_test_utils::NavigateToURL( | |
840 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | |
841 | |
842 // Waits for download completion. | |
843 while (second_download_item->GetState() != content::DownloadItem::COMPLETE) { | |
844 NotificationUpdateObserver download_change_notification_observer; | |
845 download_change_notification_observer.Wait(); | |
846 } | |
847 | |
848 // Opens the message center. | |
849 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | |
850 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size()); | |
851 EXPECT_EQ(content::DownloadItem::COMPLETE, second_download_item->GetState()); | |
852 } | |
853 | |
787 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { | 854 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { |
788 CreateDownload(); | 855 CreateDownload(); |
789 | 856 |
790 // Opens the message center. | 857 // Opens the message center. |
791 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); | 858 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); |
792 | 859 |
793 // Cancels the notification by clicking the "cancel' button. | 860 // Cancels the notification by clicking the "cancel' button. |
794 NotificationRemoveObserver notification_close_observer; | 861 NotificationRemoveObserver notification_close_observer; |
795 notification()->ButtonClick(1); | 862 notification()->ButtonClick(1); |
796 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); | 863 EXPECT_EQ(notification_id(), notification_close_observer.Wait()); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1130 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, | 1197 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, |
1131 GetNotification(notification_id_user2_group)->type()); | 1198 GetNotification(notification_id_user2_group)->type()); |
1132 EXPECT_EQ(2u, | 1199 EXPECT_EQ(2u, |
1133 GetNotification(notification_id_user2_group)->items().size()); | 1200 GetNotification(notification_id_user2_group)->items().size()); |
1134 // Normal notifications for user2. | 1201 // Normal notifications for user2. |
1135 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1202 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1136 GetNotification(notification_id_user2_1)->type()); | 1203 GetNotification(notification_id_user2_1)->type()); |
1137 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1204 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1138 GetNotification(notification_id_user2_2)->type()); | 1205 GetNotification(notification_id_user2_2)->type()); |
1139 } | 1206 } |
OLD | NEW |