Chromium Code Reviews| Index: chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm |
| diff --git a/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm b/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm |
| index fc3a98afd8fa2fb559439423d2ae6da96ecb5e97..a6737a431c4117bfa87029da14523a8af0a6ac53 100644 |
| --- a/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm |
| +++ b/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm |
| @@ -5,7 +5,9 @@ |
| #import <AppKit/AppKit.h> |
| #import <objc/runtime.h> |
| +#include "base/bind.h" |
| #include "base/mac/scoped_nsobject.h" |
| +#include "base/run_loop.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/notifications/notification.h" |
| #include "chrome/browser/notifications/notification_platform_bridge_mac.h" |
| @@ -16,12 +18,15 @@ |
| #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" |
| #include "chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.h" |
| #include "chrome/common/features.h" |
| +#include "content/public/test/test_browser_thread_bundle.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/gtest_mac.h" |
| #include "url/gurl.h" |
| class NotificationPlatformBridgeMacTest : public testing::Test { |
| public: |
| + NotificationPlatformBridgeMacTest() |
| + : thread_bundle_(content::TestBrowserThreadBundle::DEFAULT) {} |
| void SetUp() override { |
| notification_center_.reset([[StubNotificationCenter alloc] init]); |
| alert_dispatcher_.reset([[StubAlertDispatcher alloc] init]); |
| @@ -53,6 +58,13 @@ class NotificationPlatformBridgeMacTest : public testing::Test { |
| return [builder buildUserNotification]; |
| } |
| + static void CheckNotificationCount( |
| + size_t expected, |
| + std::unique_ptr<std::set<std::string>> notifications, |
| + bool supports_sync) { |
| + EXPECT_EQ(expected, notifications->size()); |
| + } |
| + |
| std::unique_ptr<Notification> CreateBanner(const char* title, |
| const char* subtitle, |
| const char* origin, |
| @@ -116,6 +128,7 @@ class NotificationPlatformBridgeMacTest : public testing::Test { |
| private: |
| base::scoped_nsobject<StubNotificationCenter> notification_center_; |
| base::scoped_nsobject<StubAlertDispatcher> alert_dispatcher_; |
| + content::TestBrowserThreadBundle thread_bundle_; |
| }; |
| TEST_F(NotificationPlatformBridgeMacTest, TestNotificationVerifyValidResponse) { |
| @@ -263,9 +276,9 @@ TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayed) { |
| "profile_id", false, *notification); |
| EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
| - std::set<std::string> notifications; |
| - EXPECT_TRUE(bridge->GetDisplayed("profile_id", false, ¬ifications)); |
| - EXPECT_EQ(1u, notifications.size()); |
| + bridge->GetDisplayed("profile_id", false /* incognito */, |
| + base::Bind(&CheckNotificationCount, 1u)); |
| + base::RunLoop().RunUntilIdle(); |
|
Peter Beverloo
2017/03/17 15:46:04
You need to confirm that CheckNotificationCount ac
Miguel Garcia
2017/03/20 14:11:21
Done.
|
| } |
| TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayedUnknownProfile) { |
| @@ -277,11 +290,9 @@ TEST_F(NotificationPlatformBridgeMacTest, TestGetDisplayedUnknownProfile) { |
| bridge->Display(NotificationCommon::PERSISTENT, "notification_id", |
| "profile_id", false, *notification); |
| EXPECT_EQ(1u, [[notification_center() deliveredNotifications] count]); |
| - |
| - std::set<std::string> notifications; |
| - EXPECT_TRUE( |
| - bridge->GetDisplayed("unknown_profile_id", false, ¬ifications)); |
| - EXPECT_EQ(0u, notifications.size()); |
| + bridge->GetDisplayed("unknown_profile_id", false /* incognito */, |
| + base::Bind(&CheckNotificationCount, 0u)); |
| + base::RunLoop().RunUntilIdle(); |
| } |
| TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesNotifications) { |