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..f0cbcbaeb2ef0eba0a182a676ea09a45edd159f6 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,53 @@ 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. |
+ // GetNotifications should report the correct number. |
Peter Beverloo
2016/12/13 11:41:12
nit: 609 is a stray comment line? what does it rel
Miguel Garcia
2016/12/13 16:43:09
It meant that GetNotifications should still report
|
+ 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(); |