| OLD | NEW |
| 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/time/time.h" | 7 #include "base/time/time.h" |
| 7 #include "chrome/browser/notifications/notification_test_util.h" | 8 #include "chrome/browser/notifications/notification_test_util.h" |
| 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 9 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 9 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 10 #include "components/content_settings/core/browser/host_content_settings_map.h" | 11 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 11 #include "content/public/browser/desktop_notification_delegate.h" | 12 #include "content/public/browser/desktop_notification_delegate.h" |
| 12 #include "content/public/common/platform_notification_data.h" | 13 #include "content/public/common/platform_notification_data.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 GURL origin("https://chrome.com/"); | 196 GURL origin("https://chrome.com/"); |
| 196 base::Time begin_time; | 197 base::Time begin_time; |
| 197 | 198 |
| 198 CreateSimplePageNotification(); | 199 CreateSimplePageNotification(); |
| 199 | 200 |
| 200 base::Time after_page_notification = | 201 base::Time after_page_notification = |
| 201 profile()->GetHostContentSettingsMap()->GetLastUsage( | 202 profile()->GetHostContentSettingsMap()->GetLastUsage( |
| 202 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 203 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 203 EXPECT_GT(after_page_notification, begin_time); | 204 EXPECT_GT(after_page_notification, begin_time); |
| 204 | 205 |
| 206 // Ensure that there is at least some time between the two calls. |
| 207 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| 208 |
| 205 service()->DisplayPersistentNotification(profile(), | 209 service()->DisplayPersistentNotification(profile(), |
| 206 42 /* sw_registration_id */, | 210 42 /* sw_registration_id */, |
| 207 origin, | 211 origin, |
| 208 SkBitmap(), | 212 SkBitmap(), |
| 209 content::PlatformNotificationData(), | 213 content::PlatformNotificationData(), |
| 210 0 /* render_process_id */); | 214 0 /* render_process_id */); |
| 211 | 215 |
| 212 base::Time after_persistent_notification = | 216 base::Time after_persistent_notification = |
| 213 profile()->GetHostContentSettingsMap()->GetLastUsage( | 217 profile()->GetHostContentSettingsMap()->GetLastUsage( |
| 214 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 218 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 215 EXPECT_GT(after_persistent_notification, after_page_notification); | 219 EXPECT_GT(after_persistent_notification, after_page_notification); |
| 216 } | 220 } |
| OLD | NEW |