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

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

Issue 1145953002: [Download Notification] change notification type from SIMPLE to BASE_FORMAT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | chrome/browser/download/notification/download_notification_item.cc » ('j') | 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/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 9 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "chrome/browser/download/chrome_download_manager_delegate.h" 10 #include "chrome/browser/download/chrome_download_manager_delegate.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 // Waits for new notification. 378 // Waits for new notification.
379 download_notification_remove_observer.Wait(); 379 download_notification_remove_observer.Wait();
380 download_notification_add_observer.Wait(); 380 download_notification_add_observer.Wait();
381 381
382 // Checks strings. 382 // Checks strings.
383 EXPECT_EQ(l10n_util::GetStringFUTF16( 383 EXPECT_EQ(l10n_util::GetStringFUTF16(
384 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE, 384 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE,
385 download_item()->GetFileNameToReportUser().LossyDisplayName()), 385 download_item()->GetFileNameToReportUser().LossyDisplayName()),
386 GetNotification(notification_id())->title()); 386 GetNotification(notification_id())->title());
387 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 387 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
388 GetNotification(notification_id())->type()); 388 GetNotification(notification_id())->type());
389 389
390 // Confirms that there is only one notification. 390 // Confirms that there is only one notification.
391 message_center::NotificationList::Notifications 391 message_center::NotificationList::Notifications
392 visible_notifications = GetMessageCenter()->GetVisibleNotifications(); 392 visible_notifications = GetMessageCenter()->GetVisibleNotifications();
393 EXPECT_EQ(1u, visible_notifications.size()); 393 EXPECT_EQ(1u, visible_notifications.size());
394 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id())); 394 EXPECT_TRUE(IsInNotifications(visible_notifications, notification_id()));
395 395
396 // Opens the message center. 396 // Opens the message center.
397 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); 397 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // Checks strings. 601 // Checks strings.
602 EXPECT_EQ(l10n_util::GetStringFUTF16( 602 EXPECT_EQ(l10n_util::GetStringFUTF16(
603 IDS_DOWNLOAD_STATUS_DOWNLOAD_FAILED_TITLE, 603 IDS_DOWNLOAD_STATUS_DOWNLOAD_FAILED_TITLE,
604 download_item()->GetFileNameToReportUser().LossyDisplayName()), 604 download_item()->GetFileNameToReportUser().LossyDisplayName()),
605 GetNotification(notification_id())->title()); 605 GetNotification(notification_id())->title());
606 EXPECT_EQ(l10n_util::GetStringFUTF16( 606 EXPECT_EQ(l10n_util::GetStringFUTF16(
607 IDS_DOWNLOAD_STATUS_INTERRUPTED, 607 IDS_DOWNLOAD_STATUS_INTERRUPTED,
608 l10n_util::GetStringUTF16( 608 l10n_util::GetStringUTF16(
609 IDS_DOWNLOAD_INTERRUPTED_STATUS_NETWORK_ERROR)), 609 IDS_DOWNLOAD_INTERRUPTED_STATUS_NETWORK_ERROR)),
610 GetNotification(notification_id())->message()); 610 GetNotification(notification_id())->message());
611 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 611 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
612 GetNotification(notification_id())->type()); 612 GetNotification(notification_id())->type());
613 } 613 }
614 614
615 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, 615 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest,
616 InterruptDownloadAfterClosingNotification) { 616 InterruptDownloadAfterClosingNotification) {
617 CreateDownload(); 617 CreateDownload();
618 618
619 // Closes the notification. 619 // Closes the notification.
620 NotificationRemoveObserver notification_close_observer; 620 NotificationRemoveObserver notification_close_observer;
621 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */); 621 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); 714 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
715 715
716 // Waits for the completion of downloads. 716 // Waits for the completion of downloads.
717 while (download1->GetState() != content::DownloadItem::COMPLETE || 717 while (download1->GetState() != content::DownloadItem::COMPLETE ||
718 download2->GetState() != content::DownloadItem::COMPLETE) { 718 download2->GetState() != content::DownloadItem::COMPLETE) {
719 NotificationUpdateObserver download_change_notification_observer; 719 NotificationUpdateObserver download_change_notification_observer;
720 download_change_notification_observer.Wait(); 720 download_change_notification_observer.Wait();
721 } 721 }
722 722
723 // Confirms the types of download notifications are correct. 723 // Confirms the types of download notifications are correct.
724 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 724 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
725 GetNotification(notification_id1)->type()); 725 GetNotification(notification_id1)->type());
726 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 726 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
727 GetNotification(notification_id2)->type()); 727 GetNotification(notification_id2)->type());
728 } 728 }
729 729
730 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) { 730 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, CancelDownload) {
731 CreateDownload(); 731 CreateDownload();
732 732
733 // Opens the message center. 733 // Opens the message center.
734 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); 734 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
735 735
736 // Cancels the notification by clicking the "cancel' button. 736 // Cancels the notification by clicking the "cancel' button.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // Waits for download completion. 804 // Waits for download completion.
805 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { 805 while (download_item()->GetState() != content::DownloadItem::COMPLETE) {
806 NotificationUpdateObserver download_change_notification_observer; 806 NotificationUpdateObserver download_change_notification_observer;
807 download_change_notification_observer.Wait(); 807 download_change_notification_observer.Wait();
808 } 808 }
809 809
810 EXPECT_EQ(l10n_util::GetStringFUTF16( 810 EXPECT_EQ(l10n_util::GetStringFUTF16(
811 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE, 811 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE,
812 download_item()->GetFileNameToReportUser().LossyDisplayName()), 812 download_item()->GetFileNameToReportUser().LossyDisplayName()),
813 GetNotification(notification_id())->title()); 813 GetNotification(notification_id())->title());
814 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 814 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
815 GetNotification(notification_id())->type()); 815 GetNotification(notification_id())->type());
816 816
817 // Opens the message center. 817 // Opens the message center.
818 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); 818 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
819 819
820 // Try to open the downloaded item by clicking the notification. 820 // Try to open the downloaded item by clicking the notification.
821 EXPECT_FALSE(GetIncognitoDownloadManagerDelegate()->opened()); 821 EXPECT_FALSE(GetIncognitoDownloadManagerDelegate()->opened());
822 GetMessageCenter()->ClickOnNotification(notification_id()); 822 GetMessageCenter()->ClickOnNotification(notification_id());
823 EXPECT_TRUE(GetIncognitoDownloadManagerDelegate()->opened()); 823 EXPECT_TRUE(GetIncognitoDownloadManagerDelegate()->opened());
824 EXPECT_FALSE(GetDownloadManagerDelegate()->opened()); 824 EXPECT_FALSE(GetDownloadManagerDelegate()->opened());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); 884 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl));
885 885
886 // Waits for the completion of downloads. 886 // Waits for the completion of downloads.
887 while (download_normal->GetState() != content::DownloadItem::COMPLETE || 887 while (download_normal->GetState() != content::DownloadItem::COMPLETE ||
888 download_incognito->GetState() != content::DownloadItem::COMPLETE) { 888 download_incognito->GetState() != content::DownloadItem::COMPLETE) {
889 NotificationUpdateObserver download_change_notification_observer; 889 NotificationUpdateObserver download_change_notification_observer;
890 download_change_notification_observer.Wait(); 890 download_change_notification_observer.Wait();
891 } 891 }
892 892
893 // Confirms the types of download notifications are correct. 893 // Confirms the types of download notifications are correct.
894 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 894 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
895 GetNotification(notification_id1)->type()); 895 GetNotification(notification_id1)->type());
896 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 896 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
897 GetNotification(notification_id2)->type()); 897 GetNotification(notification_id2)->type());
898 898
899 chrome::CloseWindow(incognito_browser()); 899 chrome::CloseWindow(incognito_browser());
900 } 900 }
901 901
902 ////////////////////////////////////////////////// 902 //////////////////////////////////////////////////
903 // Test with multi profiles 903 // Test with multi profiles
904 ////////////////////////////////////////////////// 904 //////////////////////////////////////////////////
905 905
906 class MultiProfileDownloadNotificationTest 906 class MultiProfileDownloadNotificationTest
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1037
1038 // Waits for the completion of downloads. 1038 // Waits for the completion of downloads.
1039 while (download1->GetState() != content::DownloadItem::COMPLETE || 1039 while (download1->GetState() != content::DownloadItem::COMPLETE ||
1040 download2->GetState() != content::DownloadItem::COMPLETE || 1040 download2->GetState() != content::DownloadItem::COMPLETE ||
1041 download3->GetState() != content::DownloadItem::COMPLETE) { 1041 download3->GetState() != content::DownloadItem::COMPLETE) {
1042 NotificationUpdateObserver download_change_notification_observer; 1042 NotificationUpdateObserver download_change_notification_observer;
1043 download_change_notification_observer.Wait(); 1043 download_change_notification_observer.Wait();
1044 } 1044 }
1045 1045
1046 // Confirms the types of download notifications are correct. 1046 // Confirms the types of download notifications are correct.
1047 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 1047 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1048 GetNotification(notification_id1)->type()); 1048 GetNotification(notification_id1)->type());
1049 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 1049 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1050 GetNotification(notification_id2)->type()); 1050 GetNotification(notification_id2)->type());
1051 EXPECT_EQ(message_center::NOTIFICATION_TYPE_SIMPLE, 1051 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
1052 GetNotification(notification_id3)->type()); 1052 GetNotification(notification_id3)->type());
1053 } 1053 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/notification/download_notification_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698