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

Side by Side Diff: chrome/browser/notifications/notification_browsertest.cc

Issue 752533002: Add a browser test to verify that double-closing a notification does not crash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/notifications/notification-double-close.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <deque> 5 #include <deque>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool CancelNotification(const char* notification_id, Browser* browser); 143 bool CancelNotification(const char* notification_id, Browser* browser);
144 bool PerformActionOnInfoBar(Browser* browser, 144 bool PerformActionOnInfoBar(Browser* browser,
145 InfobarAction action, 145 InfobarAction action,
146 size_t infobar_index, 146 size_t infobar_index,
147 int tab_index); 147 int tab_index);
148 void GetPrefsByContentSetting(ContentSetting setting, 148 void GetPrefsByContentSetting(ContentSetting setting,
149 ContentSettingsForOneType* settings); 149 ContentSettingsForOneType* settings);
150 bool CheckOriginInSetting(const ContentSettingsForOneType& settings, 150 bool CheckOriginInSetting(const ContentSettingsForOneType& settings,
151 const GURL& origin); 151 const GURL& origin);
152 152
153 GURL GetTestPageURLForFile(const std::string& file) const {
154 return embedded_test_server()->GetURL(
155 std::string("/notifications/") + file);
156 }
157
153 GURL GetTestPageURL() const { 158 GURL GetTestPageURL() const {
154 return embedded_test_server()->GetURL( 159 return GetTestPageURLForFile("notification_tester.html");
155 "/notifications/notification_tester.html");
156 } 160 }
157 161
158 private: 162 private:
159 void DropOriginPreference(const GURL& origin); 163 void DropOriginPreference(const GURL& origin);
160 }; 164 };
161 165
162 int NotificationsTest::GetNotificationCount() { 166 int NotificationsTest::GetNotificationCount() {
163 return message_center::MessageCenter::Get()->NotificationCount(); 167 return message_center::MessageCenter::Get()->NotificationCount();
164 } 168 }
165 169
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 result = CreateNotification( 886 result = CreateNotification(
883 browser(), true, "invalid.png", "Title1", "Body1", "chat"); 887 browser(), true, "invalid.png", "Title1", "Body1", "chat");
884 EXPECT_NE("-1", result); 888 EXPECT_NE("-1", result);
885 889
886 notifications = message_center::MessageCenter::Get()->GetPopupNotifications(); 890 notifications = message_center::MessageCenter::Get()->GetPopupNotifications();
887 ASSERT_EQ(1u, notifications.size()); 891 ASSERT_EQ(1u, notifications.size());
888 892
889 notification = *notifications.rbegin(); 893 notification = *notifications.rbegin();
890 EXPECT_TRUE(notification->icon().IsEmpty()); 894 EXPECT_TRUE(notification->icon().IsEmpty());
891 } 895 }
896
897 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationDoubleClose) {
898 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
899 AllowAllOrigins();
900
901 ui_test_utils::NavigateToURL(
902 browser(), GetTestPageURLForFile("notification-double-close.html"));
903 ASSERT_EQ(0, GetNotificationPopupCount());
904
905 std::string result = CreateNotification(
906 browser(), true, "", "Title1", "Body1", "chat");
907 EXPECT_NE("-1", result);
908
909 ASSERT_EQ(1, GetNotificationCount());
910 message_center::NotificationList::Notifications notifications =
911 message_center::MessageCenter::Get()->GetVisibleNotifications();
912 message_center::MessageCenter::Get()->RemoveNotification(
913 (*notifications.rbegin())->id(),
914 true); // by_user
915
916 ASSERT_EQ(0, GetNotificationCount());
917
918 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
919 // crash. Work around this timing issue by creating another notification,
920 // which requires interaction with the renderer process.
921 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
922 EXPECT_NE("-1", result);
923 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/notifications/notification-double-close.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698