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

Unified Diff: chrome/browser/notifications/platform_notification_service_unittest.cc

Issue 2749453002: Make GetDisplayedNotifications asynchronous. (Closed)
Patch Set: review Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/platform_notification_service_unittest.cc
diff --git a/chrome/browser/notifications/platform_notification_service_unittest.cc b/chrome/browser/notifications/platform_notification_service_unittest.cc
index f26cae46a79145e3165d0a2cefcc3cb3afb25ba0..ae048892da1fa0020165dfe466966c60ec16d1f1 100644
--- a/chrome/browser/notifications/platform_notification_service_unittest.cc
+++ b/chrome/browser/notifications/platform_notification_service_unittest.cc
@@ -6,8 +6,10 @@
#include <utility>
+#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -107,6 +109,12 @@ class PlatformNotificationServiceTest : public testing::Test {
TestingBrowserProcess::DeleteInstance();
}
+ void DidGetDisplayedNotifications(
+ std::unique_ptr<std::set<std::string>> displayed_notifications,
+ bool supports_synchronization) const {
+ displayed_notifications_ = std::move(displayed_notifications);
+ }
+
protected:
// Displays a simple, fake notifications and returns a weak pointer to the
// delegate receiving events for it (ownership is transferred to the service).
@@ -143,9 +151,13 @@ class PlatformNotificationServiceTest : public testing::Test {
Profile* profile() const { return profile_; }
size_t GetNotificationCount() const {
- std::set<std::string> notifications;
- EXPECT_TRUE(display_service()->GetDisplayed(&notifications));
- return notifications.size();
+ display_service()->GetDisplayed(base::Bind(
+ &PlatformNotificationServiceTest::DidGetDisplayedNotifications,
+ base::Unretained(this)));
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_TRUE(displayed_notifications_.get());
+ return displayed_notifications_->size();
}
Notification GetDisplayedNotification() {
@@ -168,6 +180,7 @@ class PlatformNotificationServiceTest : public testing::Test {
std::unique_ptr<TestingProfileManager> profile_manager_;
TestingProfile* profile_;
content::TestBrowserThreadBundle thread_bundle_;
+ mutable std::unique_ptr<std::set<std::string>> displayed_notifications_;
};
TEST_F(PlatformNotificationServiceTest, DisplayPageDisplayedEvent) {

Powered by Google App Engine
This is Rietveld 408576698