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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 136 |
| 137 // Returns the Platform Notification Service these unit tests are for. | 137 // Returns the Platform Notification Service these unit tests are for. |
| 138 PlatformNotificationServiceImpl* service() const { | 138 PlatformNotificationServiceImpl* service() const { |
| 139 return PlatformNotificationServiceImpl::GetInstance(); | 139 return PlatformNotificationServiceImpl::GetInstance(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Returns the Profile to be used for these tests. | 142 // Returns the Profile to be used for these tests. |
| 143 Profile* profile() const { return profile_; } | 143 Profile* profile() const { return profile_; } |
| 144 | 144 |
| 145 size_t GetNotificationCount() const { | 145 size_t GetNotificationCount() const { |
| 146 std::set<std::string> notifications; | 146 size_t count = 0; |
| 147 EXPECT_TRUE(display_service()->GetDisplayed(¬ifications)); | 147 #if defined(OS_ANDROID) |
| 148 return notifications.size(); | 148 count = static_cast<StubNotificationPlatformBridge*>( |
| 149 g_browser_process->notification_platform_bridge()) | |
| 150 ->GetNotificationCount(); | |
| 151 #else | |
| 152 count = | |
| 153 static_cast<StubNotificationUIManager*>( | |
| 154 g_browser_process->notification_ui_manager()) | |
| 155 ->GetAllIdsByProfile(NotificationUIManager::GetProfileID(profile_)) | |
| 156 .size(); | |
| 157 #endif | |
|
Peter Beverloo
2017/03/17 15:46:04
Even if it won't break on Mac, my proposed code he
Miguel Garcia
2017/03/20 14:11:21
Discussed offline and agreed to change it to this
| |
| 158 return count; | |
| 149 } | 159 } |
| 150 | 160 |
| 151 Notification GetDisplayedNotification() { | 161 Notification GetDisplayedNotification() { |
| 152 #if defined(OS_ANDROID) | 162 #if defined(OS_ANDROID) |
| 153 return static_cast<StubNotificationPlatformBridge*>( | 163 return static_cast<StubNotificationPlatformBridge*>( |
| 154 g_browser_process->notification_platform_bridge()) | 164 g_browser_process->notification_platform_bridge()) |
| 155 ->GetNotificationAt(profile_->GetPath().BaseName().value(), 0); | 165 ->GetNotificationAt(profile_->GetPath().BaseName().value(), 0); |
| 156 #else | 166 #else |
| 157 return static_cast<StubNotificationUIManager*>( | 167 return static_cast<StubNotificationUIManager*>( |
| 158 g_browser_process->notification_ui_manager()) | 168 g_browser_process->notification_ui_manager()) |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 profile(), | 420 profile(), |
| 411 GURL() /* service_worker_scope */, | 421 GURL() /* service_worker_scope */, |
| 412 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), | 422 GURL("chrome-extension://honijodknafkokifofgiaalefdiedpko/main.html"), |
| 413 notification_data, NotificationResources(), | 423 notification_data, NotificationResources(), |
| 414 new MockNotificationDelegate("hello")); | 424 new MockNotificationDelegate("hello")); |
| 415 EXPECT_EQ("NotificationTest", | 425 EXPECT_EQ("NotificationTest", |
| 416 base::UTF16ToUTF8(notification.context_message())); | 426 base::UTF16ToUTF8(notification.context_message())); |
| 417 } | 427 } |
| 418 | 428 |
| 419 #endif // BUILDFLAG(ENABLE_EXTENSIONS) | 429 #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
| OLD | NEW |