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

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

Issue 2534443002: Use notification display service to collect persistent notifications. (Closed)
Patch Set: revert unit test 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..af4567f69a238b4a0d24821fdefa50729691cca0 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,49 @@ 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(
Peter Beverloo 2016/12/02 13:43:34 Consider using (from <algorithm>): ASSERT_EQ(1,
Miguel Garcia 2016/12/06 12:01:18 I rather count the elements, if I count the separa
+ script_message, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
+ ASSERT_EQ(2u, notifications.size());
+
+ // Now remove one notifications straight from the ui manager
+ // without going through the database.
+ // GetNotifications should report the correct number.
+ const Notification& notification = ui_manager()->GetNotificationAt(1);
+ base::StringPiece notification_id(notification.id());
+ ASSERT_TRUE(notification_id.starts_with("p:"));
Peter Beverloo 2016/12/02 13:43:34 ASSERT_TRUE( base::StartsWith(notification.i
Miguel Garcia 2016/12/06 12:01:18 Done.
+ ASSERT_TRUE(ui_manager()->ClearNotificationById(
+ 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