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

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

Issue 1411653004: Remove last usage functions from HostContentSettingsMap Base URL: https://chromium.googlesource.com/chromium/src.git@simplify-host-content-settings
Patch Set: Created 5 years, 1 month 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 EXPECT_NE("-1", result); 738 EXPECT_NE("-1", result);
739 739
740 ASSERT_EQ(1, GetNotificationCount()); 740 ASSERT_EQ(1, GetNotificationCount());
741 message_center::NotificationList::Notifications notifications = 741 message_center::NotificationList::Notifications notifications =
742 message_center::MessageCenter::Get()->GetVisibleNotifications(); 742 message_center::MessageCenter::Get()->GetVisibleNotifications();
743 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); 743 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title());
744 EXPECT_EQ(base::ASCIIToUTF16("Body2"), 744 EXPECT_EQ(base::ASCIIToUTF16("Body2"),
745 (*notifications.rbegin())->message()); 745 (*notifications.rbegin())->message());
746 } 746 }
747 747
748 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) {
749 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
750
751 HostContentSettingsMap* settings_map =
752 HostContentSettingsMapFactory::GetForProfile(browser()->profile());
753 base::SimpleTestClock* clock = new base::SimpleTestClock();
754 settings_map->SetPrefClockForTesting(scoped_ptr<base::Clock>(clock));
755 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10));
756
757 // Creates a simple notification.
758 AllowAllOrigins();
759 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
760
761 std::string result = CreateSimpleNotification(browser(), true);
762 EXPECT_NE("-1", result);
763
764 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(),
765 GetTestPageURL().GetOrigin(),
766 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
767 .ToDoubleT(),
768 10);
769
770 clock->Advance(base::TimeDelta::FromSeconds(3));
771
772 result = CreateSimpleNotification(browser(), true);
773 EXPECT_NE("-1", result);
774
775 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(),
776 GetTestPageURL().GetOrigin(),
777 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
778 .ToDoubleT(),
779 13);
780 }
781
782 IN_PROC_BROWSER_TEST_F(NotificationsTest, 748 IN_PROC_BROWSER_TEST_F(NotificationsTest,
783 TestNotificationReplacementReappearance) { 749 TestNotificationReplacementReappearance) {
784 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 750 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
785 751
786 // Test that we can replace a notification using the tag, and that it will 752 // Test that we can replace a notification using the tag, and that it will
787 // cause the notification to reappear as a popup again. 753 // cause the notification to reappear as a popup again.
788 AllowAllOrigins(); 754 AllowAllOrigins();
789 755
790 ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); 756 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
791 757
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 true); // by_user 853 true); // by_user
888 854
889 ASSERT_EQ(0, GetNotificationCount()); 855 ASSERT_EQ(0, GetNotificationCount());
890 856
891 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did 857 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
892 // crash. Work around this timing issue by creating another notification, 858 // crash. Work around this timing issue by creating another notification,
893 // which requires interaction with the renderer process. 859 // which requires interaction with the renderer process.
894 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat"); 860 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
895 EXPECT_NE("-1", result); 861 EXPECT_NE("-1", result);
896 } 862 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698