Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 void NotificationDisplayed() override { displayed_ = true; } | 70 void NotificationDisplayed() override { displayed_ = true; } |
| 71 void NotificationClosed() override {} | 71 void NotificationClosed() override {} |
| 72 void NotificationClick() override { clicked_ = true; } | 72 void NotificationClick() override { clicked_ = true; } |
| 73 | 73 |
| 74 bool displayed() const { return displayed_; } | 74 bool displayed() const { return displayed_; } |
| 75 bool clicked() const { return clicked_; } | 75 bool clicked() const { return clicked_; } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 bool displayed_; | 78 bool displayed_; |
| 79 bool clicked_; | 79 bool clicked_; |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(MockDesktopNotificationDelegate); | |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 } // namespace | 84 } // namespace |
| 83 | 85 |
| 84 class PlatformNotificationServiceTest : public testing::Test { | 86 class PlatformNotificationServiceTest : public testing::Test { |
| 85 public: | 87 public: |
| 86 void SetUp() override { | 88 void SetUp() override { |
| 87 profile_manager_.reset( | 89 profile_manager_ = base::MakeUnique<TestingProfileManager>( |
| 88 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 90 TestingBrowserProcess::GetGlobal()); |
| 89 ASSERT_TRUE(profile_manager_->SetUp()); | 91 ASSERT_TRUE(profile_manager_->SetUp()); |
| 90 profile_ = profile_manager_->CreateTestingProfile("Miguel"); | 92 profile_ = profile_manager_->CreateTestingProfile("Miguel"); |
| 91 std::unique_ptr<NotificationUIManager> ui_manager( | 93 std::unique_ptr<NotificationUIManager> ui_manager = |
| 92 new StubNotificationUIManager); | 94 base::MakeUnique<StubNotificationUIManager>(); |
| 93 std::unique_ptr<NotificationPlatformBridge> notification_bridge( | 95 std::unique_ptr<NotificationPlatformBridge> notification_bridge = |
| 94 new StubNotificationPlatformBridge()); | 96 base::MakeUnique<StubNotificationPlatformBridge>(); |
| 95 | 97 |
| 96 TestingBrowserProcess::GetGlobal()->SetNotificationUIManager( | 98 TestingBrowserProcess::GetGlobal()->SetNotificationUIManager( |
| 97 std::move(ui_manager)); | 99 std::move(ui_manager)); |
| 98 TestingBrowserProcess::GetGlobal()->SetNotificationPlatformBridge( | 100 TestingBrowserProcess::GetGlobal()->SetNotificationPlatformBridge( |
| 99 std::move(notification_bridge)); | 101 std::move(notification_bridge)); |
| 100 } | 102 } |
| 101 | 103 |
| 102 void TearDown() override { | 104 void TearDown() override { |
| 103 profile_manager_.reset(); | 105 profile_manager_.reset(); |
| 104 TestingBrowserProcess::DeleteInstance(); | 106 TestingBrowserProcess::DeleteInstance(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 std::vector<int> vibration_pattern( | 249 std::vector<int> vibration_pattern( |
| 248 kNotificationVibrationPattern, | 250 kNotificationVibrationPattern, |
| 249 kNotificationVibrationPattern + arraysize(kNotificationVibrationPattern)); | 251 kNotificationVibrationPattern + arraysize(kNotificationVibrationPattern)); |
| 250 | 252 |
| 251 PlatformNotificationData notification_data; | 253 PlatformNotificationData notification_data; |
| 252 notification_data.title = base::ASCIIToUTF16("My notification's title"); | 254 notification_data.title = base::ASCIIToUTF16("My notification's title"); |
| 253 notification_data.body = base::ASCIIToUTF16("Hello, world!"); | 255 notification_data.body = base::ASCIIToUTF16("Hello, world!"); |
| 254 notification_data.vibration_pattern = vibration_pattern; | 256 notification_data.vibration_pattern = vibration_pattern; |
| 255 notification_data.silent = true; | 257 notification_data.silent = true; |
| 256 notification_data.actions.resize(2); | 258 notification_data.actions.resize(2); |
| 259 notification_data.actions[0].type = | |
|
awdf
2016/09/29 10:47:57
Am I correct in surmising that it was just the lac
awdf
2016/09/29 13:06:34
Peter's since explained that the test which gave t
| |
| 260 content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON; | |
| 257 notification_data.actions[0].title = base::ASCIIToUTF16("Button 1"); | 261 notification_data.actions[0].title = base::ASCIIToUTF16("Button 1"); |
| 262 notification_data.actions[1].type = | |
| 263 content::PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON; | |
| 258 notification_data.actions[1].title = base::ASCIIToUTF16("Button 2"); | 264 notification_data.actions[1].title = base::ASCIIToUTF16("Button 2"); |
| 259 | 265 |
| 260 NotificationResources notification_resources; | 266 NotificationResources notification_resources; |
| 261 notification_resources.action_icons.resize(notification_data.actions.size()); | 267 notification_resources.action_icons.resize(notification_data.actions.size()); |
| 262 | 268 |
| 263 service()->DisplayPersistentNotification( | 269 service()->DisplayPersistentNotification( |
| 264 profile(), kNotificationId, GURL() /* service_worker_scope */, | 270 profile(), kNotificationId, GURL() /* service_worker_scope */, |
| 265 GURL("https://chrome.com/"), notification_data, notification_resources); | 271 GURL("https://chrome.com/"), notification_data, notification_resources); |
| 266 | 272 |
| 267 ASSERT_EQ(1u, GetNotificationCount()); | 273 ASSERT_EQ(1u, GetNotificationCount()); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 profile(), | 433 profile(), |
| 428 GURL() /* service_worker_scope */, | 434 GURL() /* service_worker_scope */, |
| 429 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), | 435 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), |
| 430 notification_data, NotificationResources(), | 436 notification_data, NotificationResources(), |
| 431 new MockNotificationDelegate("hello")); | 437 new MockNotificationDelegate("hello")); |
| 432 EXPECT_EQ("NotificationTest", | 438 EXPECT_EQ("NotificationTest", |
| 433 base::UTF16ToUTF8(notification.context_message())); | 439 base::UTF16ToUTF8(notification.context_message())); |
| 434 } | 440 } |
| 435 | 441 |
| 436 #endif // defined(ENABLE_EXTENSIONS) | 442 #endif // defined(ENABLE_EXTENSIONS) |
| OLD | NEW |