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

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

Issue 2818373004: Use notification type to detect progress notifications (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"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/notifications/notification.h" 14 #include "chrome/browser/notifications/notification.h"
15 #include "chrome/browser/notifications/notification_platform_bridge_mac.h" 15 #include "chrome/browser/notifications/notification_platform_bridge_mac.h"
16 #include "chrome/browser/notifications/notification_test_util.h" 16 #include "chrome/browser/notifications/notification_test_util.h"
17 #include "chrome/browser/notifications/stub_alert_dispatcher_mac.h" 17 #include "chrome/browser/notifications/stub_alert_dispatcher_mac.h"
18 #include "chrome/browser/notifications/stub_notification_center_mac.h" 18 #include "chrome/browser/notifications/stub_notification_center_mac.h"
19 #include "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" 19 #include "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h"
20 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" 20 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h"
21 #include "chrome/browser/ui/cocoa/notifications/notification_response_builder_ma c.h" 21 #include "chrome/browser/ui/cocoa/notifications/notification_response_builder_ma c.h"
22 #include "chrome/common/features.h" 22 #include "chrome/common/features.h"
23 #include "content/public/test/test_browser_thread_bundle.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "testing/gtest_mac.h" 25 #include "testing/gtest_mac.h"
26 #include "ui/message_center/notification_types.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 class NotificationPlatformBridgeMacTest : public testing::Test { 29 class NotificationPlatformBridgeMacTest : public testing::Test {
29 public: 30 public:
30 NotificationPlatformBridgeMacTest() 31 NotificationPlatformBridgeMacTest()
31 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT) {} 32 : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT) {}
32 void SetUp() override { 33 void SetUp() override {
33 notification_center_.reset([[StubNotificationCenter alloc] init]); 34 notification_center_.reset([[StubNotificationCenter alloc] init]);
34 alert_dispatcher_.reset([[StubAlertDispatcher alloc] init]); 35 alert_dispatcher_.reset([[StubAlertDispatcher alloc] init]);
35 } 36 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 EXPECT_NSEQ(@"Close", [delivered_notification otherButtonTitle]); 243 EXPECT_NSEQ(@"Close", [delivered_notification otherButtonTitle]);
243 EXPECT_NSEQ(@"More", [delivered_notification actionButtonTitle]); 244 EXPECT_NSEQ(@"More", [delivered_notification actionButtonTitle]);
244 } 245 }
245 246
246 TEST_F(NotificationPlatformBridgeMacTest, TestDisplayProgress) { 247 TEST_F(NotificationPlatformBridgeMacTest, TestDisplayProgress) {
247 std::unique_ptr<Notification> notification = 248 std::unique_ptr<Notification> notification =
248 CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr); 249 CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr);
249 const int kSamplePercent = 10; 250 const int kSamplePercent = 10;
250 251
251 notification->set_progress(kSamplePercent); 252 notification->set_progress(kSamplePercent);
253 notification->set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
252 254
253 std::unique_ptr<NotificationPlatformBridgeMac> bridge( 255 std::unique_ptr<NotificationPlatformBridgeMac> bridge(
254 new NotificationPlatformBridgeMac(notification_center(), 256 new NotificationPlatformBridgeMac(notification_center(),
255 alert_dispatcher())); 257 alert_dispatcher()));
256 bridge->Display(NotificationCommon::PERSISTENT, "notification_id", 258 bridge->Display(NotificationCommon::PERSISTENT, "notification_id",
257 "profile_id", false, *notification); 259 "profile_id", false, *notification);
258 260
259 // Progress notifications are considered alerts 261 // Progress notifications are considered alerts
260 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); 262 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]);
261 NSArray* displayedAlerts = [alert_dispatcher() alerts]; 263 NSArray* displayedAlerts = [alert_dispatcher() alerts];
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2", 415 bridge->Display(NotificationCommon::PERSISTENT, "notification_id2",
414 "profile_id", false, *alert); 416 "profile_id", false, *alert);
415 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); 417 EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]);
416 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]); 418 EXPECT_EQ(1u, [[alert_dispatcher() alerts] count]);
417 } 419 }
418 420
419 // The destructor of the bridge should close all notifications. 421 // The destructor of the bridge should close all notifications.
420 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]); 422 EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]);
421 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]); 423 EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]);
422 } 424 }
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