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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadFile) { | 367 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadFile) { |
368 CreateDownload(); | 368 CreateDownload(); |
369 | 369 |
370 EXPECT_EQ(l10n_util::GetStringFUTF16( | 370 EXPECT_EQ(l10n_util::GetStringFUTF16( |
371 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, | 371 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE, |
372 download_item()->GetFileNameToReportUser().LossyDisplayName()), | 372 download_item()->GetFileNameToReportUser().LossyDisplayName()), |
373 GetNotification(notification_id())->title()); | 373 GetNotification(notification_id())->title()); |
374 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, | 374 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS, |
375 GetNotification(notification_id())->type()); | 375 GetNotification(notification_id())->type()); |
376 | 376 |
377 // Confirms that the download update is delivered to the notification. | |
378 NotificationUpdateObserver download_notification_periodically_update_observer; | |
379 download_item()->UpdateObservers(); | |
380 download_notification_periodically_update_observer.Wait(); | |
381 | |
382 NotificationUpdateObserver download_notification_update_observer; | 377 NotificationUpdateObserver download_notification_update_observer; |
383 | 378 |
384 // Requests to complete the download. | 379 // Requests to complete the download. |
385 ui_test_utils::NavigateToURL( | 380 ui_test_utils::NavigateToURL( |
386 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 381 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
387 | 382 |
388 // Waits for download completion. | 383 // Waits for download completion. |
389 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 384 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
390 NotificationUpdateObserver download_change_notification_observer; | 385 NotificationUpdateObserver download_change_notification_observer; |
391 download_change_notification_observer.Wait(); | 386 download_change_notification_observer.Wait(); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 EXPECT_EQ(1u, popup_notifications.size()); | 777 EXPECT_EQ(1u, popup_notifications.size()); |
783 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1)); | 778 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1)); |
784 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2)); | 779 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2)); |
785 | 780 |
786 // Confirms that the old one is low priority, and the new one is default. | 781 // Confirms that the old one is low priority, and the new one is default. |
787 EXPECT_EQ(message_center::LOW_PRIORITY, | 782 EXPECT_EQ(message_center::LOW_PRIORITY, |
788 GetNotification(notification_id1)->priority()); | 783 GetNotification(notification_id1)->priority()); |
789 EXPECT_EQ(message_center::DEFAULT_PRIORITY, | 784 EXPECT_EQ(message_center::DEFAULT_PRIORITY, |
790 GetNotification(notification_id2)->priority()); | 785 GetNotification(notification_id2)->priority()); |
791 | 786 |
792 // Confirms that the updates of both download are delivered to the | |
793 // notifications. | |
794 NotificationUpdateObserver notification_periodically_update_observer1; | |
795 download1->UpdateObservers(); | |
796 EXPECT_EQ(notification_id1, | |
797 notification_periodically_update_observer1.Wait()); | |
798 NotificationUpdateObserver notification_periodically_update_observer2; | |
799 download2->UpdateObservers(); | |
800 EXPECT_EQ(notification_id2, | |
801 notification_periodically_update_observer2.Wait()); | |
802 | |
803 // Requests to complete the downloads. | 787 // Requests to complete the downloads. |
804 ui_test_utils::NavigateToURL( | 788 ui_test_utils::NavigateToURL( |
805 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 789 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
806 | 790 |
807 // Waits for the completion of downloads. | 791 // Waits for the completion of downloads. |
808 NotificationUpdateObserver download_change_notification_observer; | 792 NotificationUpdateObserver download_change_notification_observer; |
809 while (download1->GetState() != content::DownloadItem::COMPLETE || | 793 while (download1->GetState() != content::DownloadItem::COMPLETE || |
810 download2->GetState() != content::DownloadItem::COMPLETE) { | 794 download2->GetState() != content::DownloadItem::COMPLETE) { |
811 download_change_notification_observer.Wait(); | 795 download_change_notification_observer.Wait(); |
812 } | 796 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1219 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1236 GetNotification(notification_id_user1)->type()); | 1220 GetNotification(notification_id_user1)->type()); |
1237 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1221 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1238 GetNotification(notification_id_user2_1)->type()); | 1222 GetNotification(notification_id_user2_1)->type()); |
1239 // Normal notifications for user2. | 1223 // Normal notifications for user2. |
1240 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1224 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1241 GetNotification(notification_id_user2_1)->type()); | 1225 GetNotification(notification_id_user2_1)->type()); |
1242 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1226 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1243 GetNotification(notification_id_user2_2)->type()); | 1227 GetNotification(notification_id_user2_2)->type()); |
1244 } | 1228 } |
OLD | NEW |