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

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

Issue 439073002: Web Notifications should always reappear as popups when updated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/message_center/notification_list.cc » ('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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 }; 115 };
116 116
117 } // namespace 117 } // namespace
118 118
119 class NotificationsTest : public InProcessBrowserTest { 119 class NotificationsTest : public InProcessBrowserTest {
120 public: 120 public:
121 NotificationsTest() {} 121 NotificationsTest() {}
122 122
123 protected: 123 protected:
124 int GetNotificationCount(); 124 int GetNotificationCount();
125 int GetNotificationPopupCount();
125 126
126 void CloseBrowserWindow(Browser* browser); 127 void CloseBrowserWindow(Browser* browser);
127 void CrashTab(Browser* browser, int index); 128 void CrashTab(Browser* browser, int index);
128 129
129 void DenyOrigin(const GURL& origin); 130 void DenyOrigin(const GURL& origin);
130 void AllowOrigin(const GURL& origin); 131 void AllowOrigin(const GURL& origin);
131 void AllowAllOrigins(); 132 void AllowAllOrigins();
132 void SetDefaultContentSetting(ContentSetting setting); 133 void SetDefaultContentSetting(ContentSetting setting);
133 134
134 void VerifyInfoBar(const Browser* browser, int index); 135 void VerifyInfoBar(const Browser* browser, int index);
(...skipping 22 matching lines...) Expand all
157 } 158 }
158 159
159 private: 160 private:
160 void DropOriginPreference(const GURL& origin); 161 void DropOriginPreference(const GURL& origin);
161 }; 162 };
162 163
163 int NotificationsTest::GetNotificationCount() { 164 int NotificationsTest::GetNotificationCount() {
164 return message_center::MessageCenter::Get()->NotificationCount(); 165 return message_center::MessageCenter::Get()->NotificationCount();
165 } 166 }
166 167
168 int NotificationsTest::GetNotificationPopupCount() {
169 return message_center::MessageCenter::Get()->GetPopupNotifications().size();
170 }
171
167 void NotificationsTest::CloseBrowserWindow(Browser* browser) { 172 void NotificationsTest::CloseBrowserWindow(Browser* browser) {
168 content::WindowedNotificationObserver observer( 173 content::WindowedNotificationObserver observer(
169 chrome::NOTIFICATION_BROWSER_CLOSED, 174 chrome::NOTIFICATION_BROWSER_CLOSED,
170 content::Source<Browser>(browser)); 175 content::Source<Browser>(browser));
171 browser->window()->Close(); 176 browser->window()->Close();
172 observer.Wait(); 177 observer.Wait();
173 } 178 }
174 179
175 void NotificationsTest::CrashTab(Browser* browser, int index) { 180 void NotificationsTest::CrashTab(Browser* browser, int index) {
176 content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index)); 181 content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index));
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 800
796 result = CreateSimpleNotification(browser(), true); 801 result = CreateSimpleNotification(browser(), true);
797 EXPECT_NE("-1", result); 802 EXPECT_NE("-1", result);
798 803
799 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(), 804 EXPECT_EQ(settings_map->GetLastUsage(GetTestPageURL().GetOrigin(),
800 GetTestPageURL().GetOrigin(), 805 GetTestPageURL().GetOrigin(),
801 CONTENT_SETTINGS_TYPE_NOTIFICATIONS) 806 CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
802 .ToDoubleT(), 807 .ToDoubleT(),
803 13); 808 13);
804 } 809 }
810
811 IN_PROC_BROWSER_TEST_F(NotificationsTest,
812 TestNotificationReplacementReappearance) {
813 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
814
815 // Test that we can replace a notification using the tag, and that it will
816 // cause the notification to reappear as a popup again.
817 AllowAllOrigins();
818
819 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
820
821 ASSERT_EQ(0, GetNotificationPopupCount());
822
823 std::string result = CreateNotification(
824 browser(), true, "abc.png", "Title1", "Body1", "chat");
825 EXPECT_NE("-1", result);
826
827 ASSERT_EQ(1, GetNotificationPopupCount());
828
829 message_center::NotificationList::Notifications notifications =
830 message_center::MessageCenter::Get()->GetVisibleNotifications();
831 message_center::MessageCenter::Get()->ClickOnNotification(
832 (*notifications.rbegin())->id());
833
834 ASSERT_EQ(0, GetNotificationPopupCount());
835
836 result = CreateNotification(
837 browser(), true, "abc.png", "Title2", "Body2", "chat");
838 EXPECT_NE("-1", result);
839
840 ASSERT_EQ(1, GetNotificationPopupCount());
841 }
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/notification_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698