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

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

Issue 1389273004: Update first download notification correctly if there are multiple notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update the download manually in the test Created 5 years, 2 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
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
377 NotificationUpdateObserver download_notification_update_observer; 382 NotificationUpdateObserver download_notification_update_observer;
378 383
379 // Requests to complete the download. 384 // Requests to complete the download.
380 ui_test_utils::NavigateToURL( 385 ui_test_utils::NavigateToURL(
381 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); 386 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
382 387
383 // Waits for download completion. 388 // Waits for download completion.
384 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { 389 while (download_item()->GetState() != content::DownloadItem::COMPLETE) {
385 NotificationUpdateObserver download_change_notification_observer; 390 NotificationUpdateObserver download_change_notification_observer;
386 download_change_notification_observer.Wait(); 391 download_change_notification_observer.Wait();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 EXPECT_EQ(1u, popup_notifications.size()); 782 EXPECT_EQ(1u, popup_notifications.size());
778 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1)); 783 EXPECT_FALSE(IsInNotifications(popup_notifications, notification_id1));
779 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2)); 784 EXPECT_TRUE(IsInNotifications(popup_notifications, notification_id2));
780 785
781 // Confirms that the old one is low priority, and the new one is default. 786 // Confirms that the old one is low priority, and the new one is default.
782 EXPECT_EQ(message_center::LOW_PRIORITY, 787 EXPECT_EQ(message_center::LOW_PRIORITY,
783 GetNotification(notification_id1)->priority()); 788 GetNotification(notification_id1)->priority());
784 EXPECT_EQ(message_center::DEFAULT_PRIORITY, 789 EXPECT_EQ(message_center::DEFAULT_PRIORITY,
785 GetNotification(notification_id2)->priority()); 790 GetNotification(notification_id2)->priority());
786 791
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
787 // Requests to complete the downloads. 803 // Requests to complete the downloads.
788 ui_test_utils::NavigateToURL( 804 ui_test_utils::NavigateToURL(
789 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); 805 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
790 806
791 // Waits for the completion of downloads. 807 // Waits for the completion of downloads.
792 NotificationUpdateObserver download_change_notification_observer; 808 NotificationUpdateObserver download_change_notification_observer;
793 while (download1->GetState() != content::DownloadItem::COMPLETE || 809 while (download1->GetState() != content::DownloadItem::COMPLETE ||
794 download2->GetState() != content::DownloadItem::COMPLETE) { 810 download2->GetState() != content::DownloadItem::COMPLETE) {
795 download_change_notification_observer.Wait(); 811 download_change_notification_observer.Wait();
796 } 812 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1235 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1220 GetNotification(notification_id_user1)->type()); 1236 GetNotification(notification_id_user1)->type());
1221 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1237 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1222 GetNotification(notification_id_user2_1)->type()); 1238 GetNotification(notification_id_user2_1)->type());
1223 // Normal notifications for user2. 1239 // Normal notifications for user2.
1224 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1240 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1225 GetNotification(notification_id_user2_1)->type()); 1241 GetNotification(notification_id_user2_1)->type());
1226 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, 1242 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1227 GetNotification(notification_id_user2_2)->type()); 1243 GetNotification(notification_id_user2_2)->type());
1228 } 1244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698