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

Side by Side Diff: chrome/browser/notifications/notification_interactive_uitest.cc

Issue 2697473002: Remove last usage functions from HostContentSettingsMap and clean up prefs (Closed)
Patch Set: fix up unit test Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <deque> 5 #include <deque>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 EXPECT_NE("-1", result); 752 EXPECT_NE("-1", result);
753 753
754 ASSERT_EQ(1, GetNotificationCount()); 754 ASSERT_EQ(1, GetNotificationCount());
755 message_center::NotificationList::Notifications notifications = 755 message_center::NotificationList::Notifications notifications =
756 message_center::MessageCenter::Get()->GetVisibleNotifications(); 756 message_center::MessageCenter::Get()->GetVisibleNotifications();
757 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); 757 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title());
758 EXPECT_EQ(base::ASCIIToUTF16("Body2"), 758 EXPECT_EQ(base::ASCIIToUTF16("Body2"),
759 (*notifications.rbegin())->message()); 759 (*notifications.rbegin())->message());
760 } 760 }
761 761
762 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) {
763 ASSERT_TRUE(embedded_test_server()->Start());
764
765 HostContentSettingsMap* settings_map =
766 HostContentSettingsMapFactory::GetForProfile(browser()->profile());
767 base::SimpleTestClock* clock = new base::SimpleTestClock();
768 settings_map->SetPrefClockForTesting(std::unique_ptr<base::Clock>(clock));
769 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10));
770
771 // Creates a simple notification.
772 AllowAllOrigins();
773 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
774
775 std::string result = CreateSimpleNotification(browser(), true);
776 EXPECT_NE("-1", result);
777
778 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(),
779 GetTestPageURL().GetOrigin(),
780 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
781 .ToDoubleT(),
782 10);
783
784 clock->Advance(base::TimeDelta::FromSeconds(3));
785
786 result = CreateSimpleNotification(browser(), true);
787 EXPECT_NE("-1", result);
788
789 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(),
790 GetTestPageURL().GetOrigin(),
791 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
792 .ToDoubleT(),
793 13);
794 }
795
796 IN_PROC_BROWSER_TEST_F(NotificationsTest, 762 IN_PROC_BROWSER_TEST_F(NotificationsTest,
797 TestNotificationReplacementReappearance) { 763 TestNotificationReplacementReappearance) {
798 ASSERT_TRUE(embedded_test_server()->Start()); 764 ASSERT_TRUE(embedded_test_server()->Start());
799 765
800 // Test that we can replace a notification using the tag, and that it will 766 // Test that we can replace a notification using the tag, and that it will
801 // cause the notification to reappear as a popup again. 767 // cause the notification to reappear as a popup again.
802 AllowAllOrigins(); 768 AllowAllOrigins();
803 769
804 ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); 770 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
805 771
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 browser()->window()->GetNativeWindow())); 1046 browser()->window()->GetNativeWindow()));
1081 1047
1082 std::string result = CreateSimpleNotification(browser(), true); 1048 std::string result = CreateSimpleNotification(browser(), true);
1083 EXPECT_NE("-1", result); 1049 EXPECT_NE("-1", result);
1084 1050
1085 ASSERT_EQ(1, GetNotificationCount()); 1051 ASSERT_EQ(1, GetNotificationCount());
1086 message_center::NotificationList::PopupNotifications notifications = 1052 message_center::NotificationList::PopupNotifications notifications =
1087 message_center::MessageCenter::Get()->GetPopupNotifications(); 1053 message_center::MessageCenter::Get()->GetPopupNotifications();
1088 ASSERT_EQ(1u, notifications.size()); 1054 ASSERT_EQ(1u, notifications.size());
1089 } 1055 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698