OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import <AppKit/AppKit.h> | 5 #import <AppKit/AppKit.h> |
6 #import <objc/runtime.h> | 6 #import <objc/runtime.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 265 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
266 | 266 |
267 bridge->Close("profile_id_does_not_exist", "notification_id"); | 267 bridge->Close("profile_id_does_not_exist", "notification_id"); |
268 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 268 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
269 } | 269 } |
270 | 270 |
271 TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayed) { | 271 TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayed) { |
272 std::unique_ptr<Notification> notification = CreateBanner( | 272 std::unique_ptr<Notification> notification = CreateBanner( |
273 "Title", "Context", "https://gmail.com", "Button 1", nullptr); | 273 "Title", "Context", "https://gmail.com", "Button 1", nullptr); |
274 std::unique_ptr<NotificationPlatformBridgeMac> bridge( | 274 std::unique_ptr<NotificationPlatformBridgeMac> bridge( |
275 new NotificationPlatformBridgeMac(notification_center(), nil)); | 275 new NotificationPlatformBridgeMac(notification_center(), |
| 276 alert_dispatcher())); |
276 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); | 277 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); |
277 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", | 278 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", |
278 "profile_id", false, *notification); | 279 "profile_id", false, *notification); |
279 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 280 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
280 | 281 |
281 int notification_count = -1; | 282 int notification_count = -1; |
282 bridge->GetDisplayed( | 283 bridge->GetDisplayed( |
283 "profile_id", false /* incognito */, | 284 "profile_id", false /* incognito */, |
284 base::Bind(&StoreNotificationCount, ¬ification_count)); | 285 base::Bind(&StoreNotificationCount, ¬ification_count)); |
285 base::RunLoop().RunUntilIdle(); | 286 base::RunLoop().RunUntilIdle(); |
286 EXPECT_EQ(1, notification_count); | 287 EXPECT_EQ(1, notification_count); |
287 } | 288 } |
288 | 289 |
289 TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayedUnknownProfile) { | 290 TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayedUnknownProfile) { |
290 std::unique_ptr<Notification> notification = CreateBanner( | 291 std::unique_ptr<Notification> notification = CreateBanner( |
291 "Title", "Context", "https://gmail.com", "Button 1", nullptr); | 292 "Title", "Context", "https://gmail.com", "Button 1", nullptr); |
292 std::unique_ptr<NotificationPlatformBridgeMac> bridge( | 293 std::unique_ptr<NotificationPlatformBridgeMac> bridge( |
293 new NotificationPlatformBridgeMac(notification_center(), nil)); | 294 new NotificationPlatformBridgeMac(notification_center(), |
| 295 alert_dispatcher())); |
294 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); | 296 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); |
295 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", | 297 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", |
296 "profile_id", false, *notification); | 298 "profile_id", false, *notification); |
297 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 299 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
298 int notification_count = -1; | 300 int notification_count = -1; |
299 bridge->GetDisplayed( | 301 bridge->GetDisplayed( |
300 "unknown_profile_id", false /* incognito */, | 302 "unknown_profile_id", false /* incognito */, |
301 base::Bind(&StoreNotificationCount, ¬ification_count)); | 303 base::Bind(&StoreNotificationCount, ¬ification_count)); |
302 base::RunLoop().RunUntilIdle(); | 304 base::RunLoop().RunUntilIdle(); |
303 EXPECT_EQ(0, notification_count); | 305 EXPECT_EQ(0, notification_count); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 385 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
384 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); | 386 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); |
385 } | 387 } |
386 | 388 |
387 // The destructor of the bridge should close all notifications. | 389 // The destructor of the bridge should close all notifications. |
388 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); | 390 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); |
389 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); | 391 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); |
390 } | 392 } |
391 | 393 |
392 #endif | 394 #endif |
OLD | NEW |