| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 notification_data.vibration_pattern = vibration_pattern; | 259 notification_data.vibration_pattern = vibration_pattern; |
| 260 notification_data.silent = true; | 260 notification_data.silent = true; |
| 261 notification_data.actions.resize(2); | 261 notification_data.actions.resize(2); |
| 262 notification_data.actions[0].title = base::ASCIIToUTF16("Button 1"); | 262 notification_data.actions[0].title = base::ASCIIToUTF16("Button 1"); |
| 263 notification_data.actions[1].title = base::ASCIIToUTF16("Button 2"); | 263 notification_data.actions[1].title = base::ASCIIToUTF16("Button 2"); |
| 264 | 264 |
| 265 NotificationResources notification_resources; | 265 NotificationResources notification_resources; |
| 266 notification_resources.action_icons.resize(notification_data.actions.size()); | 266 notification_resources.action_icons.resize(notification_data.actions.size()); |
| 267 | 267 |
| 268 service()->DisplayPersistentNotification( | 268 service()->DisplayPersistentNotification( |
| 269 profile(), 0u /* persistent notification */, GURL("https://chrome.com/"), | 269 profile(), 0u /* persistent notification */, GURL(), |
| 270 notification_data, notification_resources); | 270 GURL("https://chrome.com/"), notification_data, notification_resources); |
| 271 | 271 |
| 272 ASSERT_EQ(1u, GetNotificationCount()); | 272 ASSERT_EQ(1u, GetNotificationCount()); |
| 273 | 273 |
| 274 Notification notification = GetDisplayedNotification(); | 274 Notification notification = GetDisplayedNotification(); |
| 275 EXPECT_EQ("https://chrome.com/", notification.origin_url().spec()); | 275 EXPECT_EQ("https://chrome.com/", notification.origin_url().spec()); |
| 276 EXPECT_EQ("My notification's title", base::UTF16ToUTF8(notification.title())); | 276 EXPECT_EQ("My notification's title", base::UTF16ToUTF8(notification.title())); |
| 277 EXPECT_EQ("Hello, world!", base::UTF16ToUTF8(notification.message())); | 277 EXPECT_EQ("Hello, world!", base::UTF16ToUTF8(notification.message())); |
| 278 | 278 |
| 279 EXPECT_THAT(notification.vibration_pattern(), | 279 EXPECT_THAT(notification.vibration_pattern(), |
| 280 testing::ElementsAreArray(kNotificationVibrationPattern)); | 280 testing::ElementsAreArray(kNotificationVibrationPattern)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 297 | 297 |
| 298 base::Time after_page_notification = | 298 base::Time after_page_notification = |
| 299 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage( | 299 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage( |
| 300 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 300 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 301 EXPECT_GT(after_page_notification, begin_time); | 301 EXPECT_GT(after_page_notification, begin_time); |
| 302 | 302 |
| 303 // Ensure that there is at least some time between the two calls. | 303 // Ensure that there is at least some time between the two calls. |
| 304 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); | 304 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); |
| 305 | 305 |
| 306 service()->DisplayPersistentNotification( | 306 service()->DisplayPersistentNotification( |
| 307 profile(), 42 /* sw_registration_id */, origin, | 307 profile(), 42 /* sw_registration_id */, GURL(), origin, |
| 308 PlatformNotificationData(), NotificationResources()); | 308 PlatformNotificationData(), NotificationResources()); |
| 309 | 309 |
| 310 base::Time after_persistent_notification = | 310 base::Time after_persistent_notification = |
| 311 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage( | 311 HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage( |
| 312 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 312 origin, origin, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 313 EXPECT_GT(after_persistent_notification, after_page_notification); | 313 EXPECT_GT(after_persistent_notification, after_page_notification); |
| 314 } | 314 } |
| 315 | 315 |
| 316 #if defined(ENABLE_EXTENSIONS) | 316 #if defined(ENABLE_EXTENSIONS) |
| 317 | 317 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 notification = service()->CreateNotificationFromData( | 430 notification = service()->CreateNotificationFromData( |
| 431 profile(), | 431 profile(), |
| 432 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), | 432 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), |
| 433 notification_data, NotificationResources(), | 433 notification_data, NotificationResources(), |
| 434 new MockNotificationDelegate("hello")); | 434 new MockNotificationDelegate("hello")); |
| 435 EXPECT_EQ("NotificationTest", | 435 EXPECT_EQ("NotificationTest", |
| 436 base::UTF16ToUTF8(notification.context_message())); | 436 base::UTF16ToUTF8(notification.context_message())); |
| 437 } | 437 } |
| 438 | 438 |
| 439 #endif // defined(ENABLE_EXTENSIONS) | 439 #endif // defined(ENABLE_EXTENSIONS) |
| OLD | NEW |