Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm

Issue 2817813006: Make progress notifications an alert. (Closed)
Patch Set: review Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ASSERT_EQ(1u, [displayedAlerts count]);
261 263
262 NSUserNotification* delivered_notification = [notifications objectAtIndex:0]; 264 NSDictionary* deliveredNotification = [displayedAlerts objectAtIndex:0];
263 base::string16 expected = 265 base::string16 expected =
264 base::FormatPercent(kSamplePercent) + base::UTF8ToUTF16(" - Title"); 266 base::FormatPercent(kSamplePercent) + base::UTF8ToUTF16(" - Title");
265 EXPECT_NSEQ(base::SysUTF16ToNSString(expected), 267 EXPECT_NSEQ(base::SysUTF16ToNSString(expected),
266 [delivered_notification title]); 268 [deliveredNotification objectForKey:@"title"]);
267 } 269 }
268 270
269 TEST_F(NotificationPlatformBridgeMacTest, TestCloseNotification) { 271 TEST_F(NotificationPlatformBridgeMacTest, TestCloseNotification) {
270 std::unique_ptr<Notification> notification = CreateBanner( 272 std::unique_ptr<Notification> notification = CreateBanner(
271 "Title", "Context", "https://gmail.com", "Button 1", nullptr); 273 "Title", "Context", "https://gmail.com", "Button 1", nullptr);
272 274
273 std::unique_ptr<NotificationPlatformBridgeMac> bridge( 275 std::unique_ptr<NotificationPlatformBridgeMac> bridge(
274 new NotificationPlatformBridgeMac(notification_center(), 276 new NotificationPlatformBridgeMac(notification_center(),
275 alert_dispatcher())); 277 alert_dispatcher()));
276 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); 278 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2", 413 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2",
412 "profile_id", false, *alert); 414 "profile_id", false, *alert);
413 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); 415 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]);
414 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); 416 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]);
415 } 417 }
416 418
417 // The destructor of the bridge should close all notifications. 419 // The destructor of the bridge should close all notifications.
418 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); 420 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]);
419 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); 421 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]);
420 } 422 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698