Chromium Code Reviews| 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/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr); | 248 CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr); |
| 249 const int kSamplePercent = 10; | 249 const int kSamplePercent = 10; |
| 250 | 250 |
| 251 notification->set_progress(kSamplePercent); | 251 notification->set_progress(kSamplePercent); |
| 252 | 252 |
| 253 std::unique_ptr<NotificationPlatformBridgeMac> bridge( | 253 std::unique_ptr<NotificationPlatformBridgeMac> bridge( |
| 254 new NotificationPlatformBridgeMac(notification_center(), | 254 new NotificationPlatformBridgeMac(notification_center(), |
| 255 alert_dispatcher())); | 255 alert_dispatcher())); |
| 256 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", | 256 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", |
| 257 "profile_id", false, *notification); | 257 "profile_id", false, *notification); |
| 258 NSArray* notifications = [notification_center() deliveredNotifications]; | |
| 259 | 258 |
| 260 EXPECT_EQ(1u, [notifications count]); | 259 // Progress notifications are considered alerts |
| 260 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); | |
| 261 NSArray* displayedAlerts = [alert_dispatcher() alerts]; | |
| 262 EXPECT_EQ(1u, [displayedAlerts count]); | |
|
Peter Beverloo
2017/04/13 14:14:14
micro nit: ASSERT_EQ
Miguel Garcia
2017/04/13 16:36:19
Done.
| |
| 261 | 263 |
| 262 NSUserNotification* delivered_notification = [notifications objectAtIndex:0]; | 264 NSUserNotification* delivered_notification = |
| 265 [displayedAlerts objectAtIndex:0]; | |
| 263 base::string16 expected = | 266 base::string16 expected = |
| 264 base::FormatPercent(kSamplePercent) + base::UTF8ToUTF16(" - Title"); | 267 base::FormatPercent(kSamplePercent) + base::UTF8ToUTF16(" - Title"); |
| 265 EXPECT_NSEQ(base::SysUTF16ToNSString(expected), | 268 EXPECT_NSEQ(base::SysUTF16ToNSString(expected), |
| 266 [delivered_notification title]); | 269 [delivered_notification title]); |
| 267 } | 270 } |
| 268 | 271 |
| 269 TEST_F(NotificationPlatformBridgeMacTest, TestCloseNotification) { | 272 TEST_F(NotificationPlatformBridgeMacTest, TestCloseNotification) { |
| 270 std::unique_ptr<Notification> notification = CreateBanner( | 273 std::unique_ptr<Notification> notification = CreateBanner( |
| 271 "Title", "Context", "https://gmail.com", "Button 1", nullptr); | 274 "Title", "Context", "https://gmail.com", "Button 1", nullptr); |
| 272 | 275 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2", | 414 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2", |
| 412 "profile_id", false, *alert); | 415 "profile_id", false, *alert); |
| 413 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); | 416 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
| 414 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); | 417 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); |
| 415 } | 418 } |
| 416 | 419 |
| 417 // The destructor of the bridge should close all notifications. | 420 // The destructor of the bridge should close all notifications. |
| 418 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); | 421 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); |
| 419 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); | 422 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); |
| 420 } | 423 } |
| OLD | NEW |