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

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

Issue 1312453005: Removed Profile::GetHostContentSettingsMap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed patch conflict Created 5 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "base/threading/platform_thread.h" 6 #include "base/threading/platform_thread.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/notifications/notification_delegate.h" 9 #include "chrome/browser/notifications/notification_delegate.h"
9 #include "chrome/browser/notifications/notification_test_util.h" 10 #include "chrome/browser/notifications/notification_test_util.h"
10 #include "chrome/browser/notifications/platform_notification_service_impl.h" 11 #include "chrome/browser/notifications/platform_notification_service_impl.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "components/content_settings/core/browser/host_content_settings_map.h" 13 #include "components/content_settings/core/browser/host_content_settings_map.h"
13 #include "content/public/browser/desktop_notification_delegate.h" 14 #include "content/public/browser/desktop_notification_delegate.h"
14 #include "content/public/common/platform_notification_data.h" 15 #include "content/public/common/platform_notification_data.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 16 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 224
224 TEST_F(PlatformNotificationServiceTest, NotificationPermissionLastUsage) { 225 TEST_F(PlatformNotificationServiceTest, NotificationPermissionLastUsage) {
225 // Both page and persistent notifications should update the last usage 226 // Both page and persistent notifications should update the last usage
226 // time of the notification permission for the origin. 227 // time of the notification permission for the origin.
227 GURL origin("https://chrome.com/"); 228 GURL origin("https://chrome.com/");
228 base::Time begin_time; 229 base::Time begin_time;
229 230
230 CreateSimplePageNotification(); 231 CreateSimplePageNotification();
231 232
232 base::Time after_page_notification = 233 base::Time after_page_notification =
233 profile()->GetHostContentSettingsMap()->GetLastUsage( 234 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage(
234 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 235 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
235 EXPECT_GT(after_page_notification, begin_time); 236 EXPECT_GT(after_page_notification, begin_time);
236 237
237 // Ensure that there is at least some time between the two calls. 238 // Ensure that there is at least some time between the two calls.
238 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 239 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
239 240
240 service()->DisplayPersistentNotification( 241 service()->DisplayPersistentNotification(
241 profile(), 42 /* sw_registration_id */, origin, SkBitmap(), 242 profile(), 42 /* sw_registration_id */, origin, SkBitmap(),
242 content::PlatformNotificationData()); 243 content::PlatformNotificationData());
243 244
244 base::Time after_persistent_notification = 245 base::Time after_persistent_notification =
245 profile()->GetHostContentSettingsMap()->GetLastUsage( 246 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage(
246 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 247 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
247 EXPECT_GT(after_persistent_notification, after_page_notification); 248 EXPECT_GT(after_persistent_notification, after_page_notification);
248 } 249 }
249 250
250 #if defined(ENABLE_EXTENSIONS) 251 #if defined(ENABLE_EXTENSIONS)
251 252
252 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) { 253 TEST_F(PlatformNotificationServiceTest, DisplayNameForContextMessage) {
253 base::string16 display_name = service()->DisplayNameForContextMessage( 254 base::string16 display_name = service()->DisplayNameForContextMessage(
254 profile(), GURL("https://chrome.com/")); 255 profile(), GURL("https://chrome.com/"));
255 256
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 359
359 notification = service()->CreateNotificationFromData( 360 notification = service()->CreateNotificationFromData(
360 profile(), 361 profile(),
361 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), 362 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"),
362 SkBitmap(), notification_data, new MockNotificationDelegate("hello")); 363 SkBitmap(), notification_data, new MockNotificationDelegate("hello"));
363 EXPECT_EQ("NotificationTest", 364 EXPECT_EQ("NotificationTest",
364 base::UTF16ToUTF8(notification.context_message())); 365 base::UTF16ToUTF8(notification.context_message()));
365 } 366 }
366 367
367 #endif // defined(ENABLE_EXTENSIONS) 368 #endif // defined(ENABLE_EXTENSIONS)
OLDNEW
« no previous file with comments | « chrome/browser/notifications/platform_notification_service_impl.cc ('k') | chrome/browser/pepper_broker_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698