Chromium Code Reviews| 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 notification is updated periodically. | |
| 378 NotificationUpdateObserver download_notification_periodically_update_observer; | |
|
asanka
2015/10/12 18:59:08
Does this rely on the DownloadItem firing UpdateOb
yoshiki
2015/10/14 06:53:38
Thank you for suggestion. Thanks. PTAL
| |
| 379 download_notification_periodically_update_observer.Wait(); | |
| 380 | |
| 377 NotificationUpdateObserver download_notification_update_observer; | 381 NotificationUpdateObserver download_notification_update_observer; |
| 378 | 382 |
| 379 // Requests to complete the download. | 383 // Requests to complete the download. |
| 380 ui_test_utils::NavigateToURL( | 384 ui_test_utils::NavigateToURL( |
| 381 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 385 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| 382 | 386 |
| 383 // Waits for download completion. | 387 // Waits for download completion. |
| 384 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 388 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
| 385 NotificationUpdateObserver download_change_notification_observer; | 389 NotificationUpdateObserver download_change_notification_observer; |
| 386 download_change_notification_observer.Wait(); | 390 download_change_notification_observer.Wait(); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 EXPECT_EQ(1u, popup_notifications.size()); | 781 EXPECT_EQ(1u, popup_notifications.size()); |
| 778 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1)); | 782 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1)); |
| 779 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2)); | 783 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2)); |
| 780 | 784 |
| 781 // Confirms that the old one is low priority, and the new one is default. | 785 // Confirms that the old one is low priority, and the new one is default. |
| 782 EXPECT_EQ(message_center::LOW_PRIORITY, | 786 EXPECT_EQ(message_center::LOW_PRIORITY, |
| 783 GetNotification(notification_id1)->priority()); | 787 GetNotification(notification_id1)->priority()); |
| 784 EXPECT_EQ(message_center::DEFAULT_PRIORITY, | 788 EXPECT_EQ(message_center::DEFAULT_PRIORITY, |
| 785 GetNotification(notification_id2)->priority()); | 789 GetNotification(notification_id2)->priority()); |
| 786 | 790 |
| 791 // Confirms that both notifications are updated periodically. | |
| 792 std::set<std::string> updated_ids; | |
| 793 while (updated_ids.size() != 2) { | |
| 794 NotificationUpdateObserver notification_periodically_update_observer; | |
| 795 updated_ids.insert(notification_periodically_update_observer.Wait()); | |
| 796 } | |
| 797 | |
| 787 // Requests to complete the downloads. | 798 // Requests to complete the downloads. |
| 788 ui_test_utils::NavigateToURL( | 799 ui_test_utils::NavigateToURL( |
| 789 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 800 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| 790 | 801 |
| 791 // Waits for the completion of downloads. | 802 // Waits for the completion of downloads. |
| 792 NotificationUpdateObserver download_change_notification_observer; | 803 NotificationUpdateObserver download_change_notification_observer; |
| 793 while (download1->GetState() != content::DownloadItem::COMPLETE || | 804 while (download1->GetState() != content::DownloadItem::COMPLETE || |
| 794 download2->GetState() != content::DownloadItem::COMPLETE) { | 805 download2->GetState() != content::DownloadItem::COMPLETE) { |
| 795 download_change_notification_observer.Wait(); | 806 download_change_notification_observer.Wait(); |
| 796 } | 807 } |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1230 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1220 GetNotification(notification_id_user1)->type()); | 1231 GetNotification(notification_id_user1)->type()); |
| 1221 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1232 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1222 GetNotification(notification_id_user2_1)->type()); | 1233 GetNotification(notification_id_user2_1)->type()); |
| 1223 // Normal notifications for user2. | 1234 // Normal notifications for user2. |
| 1224 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1235 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1225 GetNotification(notification_id_user2_1)->type()); | 1236 GetNotification(notification_id_user2_1)->type()); |
| 1226 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1237 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1227 GetNotification(notification_id_user2_2)->type()); | 1238 GetNotification(notification_id_user2_2)->type()); |
| 1228 } | 1239 } |
| OLD | NEW |