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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 void SetUp() override { | 91 void SetUp() override { |
| 92 profile_manager_ = base::MakeUnique<TestingProfileManager>( | 92 profile_manager_ = base::MakeUnique<TestingProfileManager>( |
| 93 TestingBrowserProcess::GetGlobal()); | 93 TestingBrowserProcess::GetGlobal()); |
| 94 ASSERT_TRUE(profile_manager_->SetUp()); | 94 ASSERT_TRUE(profile_manager_->SetUp()); |
| 95 profile_ = profile_manager_->CreateTestingProfile("Miguel"); | 95 profile_ = profile_manager_->CreateTestingProfile("Miguel"); |
| 96 std::unique_ptr<NotificationUIManager> ui_manager = | 96 std::unique_ptr<NotificationUIManager> ui_manager = |
| 97 base::MakeUnique<StubNotificationUIManager>(); | 97 base::MakeUnique<StubNotificationUIManager>(); |
| 98 std::unique_ptr<NotificationPlatformBridge> notification_bridge = | 98 std::unique_ptr<NotificationPlatformBridge> notification_bridge = |
| 99 base::MakeUnique<StubNotificationPlatformBridge>(); | 99 base::MakeUnique<StubNotificationPlatformBridge>(); |
| 100 | 100 |
| 101 // TODO(peter): These tests should use the NotificationDisplayService, which | |
| 102 // will allow the StubNotificationPlatformBridge to be removed. | |
| 101 TestingBrowserProcess::GetGlobal()->SetNotificationUIManager( | 103 TestingBrowserProcess::GetGlobal()->SetNotificationUIManager( |
| 102 std::move(ui_manager)); | 104 std::move(ui_manager)); |
| 103 TestingBrowserProcess::GetGlobal()->SetNotificationPlatformBridge( | 105 TestingBrowserProcess::GetGlobal()->SetNotificationPlatformBridge( |
| 104 std::move(notification_bridge)); | 106 std::move(notification_bridge)); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void TearDown() override { | 109 void TearDown() override { |
| 108 profile_manager_.reset(); | 110 profile_manager_.reset(); |
| 109 TestingBrowserProcess::DeleteInstance(); | 111 TestingBrowserProcess::DeleteInstance(); |
| 110 } | 112 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 } | 175 } |
| 174 | 176 |
| 175 private: | 177 private: |
| 176 NotificationDisplayService* display_service() const { | 178 NotificationDisplayService* display_service() const { |
| 177 return NotificationDisplayServiceFactory::GetForProfile(profile_); | 179 return NotificationDisplayServiceFactory::GetForProfile(profile_); |
| 178 } | 180 } |
| 179 | 181 |
| 180 std::unique_ptr<TestingProfileManager> profile_manager_; | 182 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 181 TestingProfile* profile_; | 183 TestingProfile* profile_; |
| 182 content::TestBrowserThreadBundle thread_bundle_; | 184 content::TestBrowserThreadBundle thread_bundle_; |
| 183 mutable std::unique_ptr<std::set<std::string>> displayed_notifications_; | 185 mutable std::unique_ptr<std::set<std::string>> displayed_notifications_; |
|
dewittj
2017/04/10 17:51:23
nit: const/mutable dance here seems like overkill.
Peter Beverloo
2017/04/11 00:39:21
No, you're right. Discussed this with Miguel today
| |
| 184 }; | 186 }; |
| 185 | 187 |
| 186 TEST_F(PlatformNotificationServiceTest, DisplayPageDisplayedEvent) { | 188 TEST_F(PlatformNotificationServiceTest, DisplayPageDisplayedEvent) { |
| 187 auto* delegate = CreateSimplePageNotification(); | 189 auto* delegate = CreateSimplePageNotification(); |
| 188 | 190 |
| 189 EXPECT_EQ(1u, GetNotificationCount()); | 191 EXPECT_EQ(1u, GetNotificationCount()); |
| 190 EXPECT_TRUE(delegate->displayed()); | 192 EXPECT_TRUE(delegate->displayed()); |
| 191 } | 193 } |
| 192 | 194 |
| 193 TEST_F(PlatformNotificationServiceTest, DisplayPageCloseClosure) { | 195 TEST_F(PlatformNotificationServiceTest, DisplayPageCloseClosure) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 profile(), | 425 profile(), |
| 424 GURL() /* service_worker_scope */, | 426 GURL() /* service_worker_scope */, |
| 425 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), | 427 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), |
| 426 notification_data, NotificationResources(), | 428 notification_data, NotificationResources(), |
| 427 new MockNotificationDelegate("hello")); | 429 new MockNotificationDelegate("hello")); |
| 428 EXPECT_EQ("NotificationTest", | 430 EXPECT_EQ("NotificationTest", |
| 429 base::UTF16ToUTF8(notification.context_message())); | 431 base::UTF16ToUTF8(notification.context_message())); |
| 430 } | 432 } |
| 431 | 433 |
| 432 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 434 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| OLD | NEW |