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

Unified Diff: content/shell/browser/layout_test/layout_test_notification_manager.cc

Issue 1656823002: Add layout tests for ServiceWorker's notificationclose event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now the test actually works Created 4 years, 11 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: content/shell/browser/layout_test/layout_test_notification_manager.cc
diff --git a/content/shell/browser/layout_test/layout_test_notification_manager.cc b/content/shell/browser/layout_test/layout_test_notification_manager.cc
index f4f1864b15456d64180cb520fdec725a35079c51..77584f05124bae8d573b148a49f1e7e5724ce46a 100644
--- a/content/shell/browser/layout_test/layout_test_notification_manager.cc
+++ b/content/shell/browser/layout_test/layout_test_notification_manager.cc
@@ -134,6 +134,32 @@ void LayoutTestNotificationManager::SimulateClick(const std::string& title,
base::Bind(&OnEventDispatchComplete));
}
+void LayoutTestNotificationManager::SimulateClose(const std::string& title,
+ bool by_user) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ // First check for page-notifications with the given title.
+ const auto& page_iterator = page_notifications_.find(title);
+ if (page_iterator != page_notifications_.end()) {
+ page_iterator->second->NotificationClosed();
Peter Beverloo 2016/02/02 23:50:10 No need to check for in-page notifications here -
Nina 2016/02/03 15:04:23 Removed.
+ return;
+ }
+
+ // Then check for persistent notifications with the given title.
+ const auto& persistent_iterator = persistent_notifications_.find(title);
+ if (persistent_iterator == persistent_notifications_.end())
+ return;
+
+ const PersistentNotification& notification = persistent_iterator->second;
+ content::NotificationEventDispatcher::GetInstance()
+ ->DispatchNotificationCloseEvent(
+ notification.browser_context,
+ notification.persistent_id,
+ notification.origin,
+ by_user,
+ base::Bind(&OnEventDispatchComplete));
+}
+
blink::WebNotificationPermission
LayoutTestNotificationManager::CheckPermissionOnUIThread(
BrowserContext* browser_context,

Powered by Google App Engine
This is Rietveld 408576698