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

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

Issue 2534443002: Use notification display service to collect persistent notifications. (Closed)
Patch Set: fix infinite loop Created 4 years 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_interactive_uitest.cc
diff --git a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc
index dcb0be23e3559d2a05f979b63fa8c3c8b99b7f10..e00df83973bf26ae81195b6dc865f2eb6c05b406 100644
--- a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc
+++ b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc
@@ -9,6 +9,8 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
+#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
@@ -577,6 +579,52 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
}
IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
+ GetDisplayedNotifications) {
+ RequestAndAcceptPermission();
+
+ std::string script_result;
+ std::string script_message;
+ ASSERT_TRUE(RunScript("DisplayNonPersistentNotification('NonPersistent')",
+ &script_result));
+ EXPECT_EQ("ok", script_result);
+ ASSERT_TRUE(RunScript("DisplayPersistentNotification('PersistentI')",
+ &script_result));
+ EXPECT_EQ("ok", script_result);
+ ASSERT_TRUE(RunScript("DisplayPersistentNotification('PersistentII')",
+ &script_result));
+ EXPECT_EQ("ok", script_result);
+
+ // Only the persistent ones should show.
+ ASSERT_TRUE(RunScript("GetDisplayedNotifications()", &script_result));
+ EXPECT_EQ("ok", script_result);
+
+ ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_message));
+
+ std::vector<std::string> notifications = base::SplitString(
+ script_message, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
+ ASSERT_EQ(2u, notifications.size());
+
+ // Now remove one of the notifications straight from the ui manager
+ // without going through the database.
+ const Notification& notification = ui_manager()->GetNotificationAt(1);
+
+ // p: is the prefix for persistent notifications. See
+ // content/browser/notifications/notification_id_generator.{h,cc} for details
+ ASSERT_TRUE(
+ base::StartsWith(notification.id(), "p:", base::CompareCase::SENSITIVE));
+ ASSERT_TRUE(ui_manager()->SilentDismissById(
+ notification.delegate_id(),
+ NotificationUIManager::GetProfileID(browser()->profile())));
+ ASSERT_TRUE(RunScript("GetDisplayedNotifications()", &script_result));
+ EXPECT_EQ("ok", script_result);
+
+ ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_message));
+ notifications = base::SplitString(script_message, ",", base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_ALL);
+ ASSERT_EQ(1u, notifications.size());
+}
+
+IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
TestShouldDisplayNormal) {
ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
EnableFullscreenNotifications();

Powered by Google App Engine
This is Rietveld 408576698