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

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

Issue 1320173002: Ship Notifications requireInteraction by default (chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@requireinteraction1b
Patch Set: Added browser test Created 5 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/notifications/platform_notification_service_impl.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); 210 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result));
211 EXPECT_EQ("action_none", script_result); 211 EXPECT_EQ("action_none", script_result);
212 212
213 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 213 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
214 } 214 }
215 215
216 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, 216 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
217 WebNotificationOptionsReflection) { 217 WebNotificationOptionsReflection) {
218 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); 218 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
219 219
220 // First, test the default values.
221
220 std::string script_result; 222 std::string script_result;
221 ASSERT_TRUE(RunScript("DisplayPersistentAllOptionsNotification()", 223 ASSERT_TRUE(RunScript("DisplayPersistentNotification('', {})",
222 &script_result)); 224 &script_result));
223 EXPECT_EQ("ok", script_result); 225 EXPECT_EQ("ok", script_result);
224 226
225 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 227 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
226 228
227 // We don't use or check the notification's direction and language. 229 // We don't use or check the notification's direction and language.
228 const Notification& notification = ui_manager()->GetNotificationAt(0); 230 const Notification& default_notification = ui_manager()->GetNotificationAt(0);
229 EXPECT_EQ("Title", base::UTF16ToUTF8(notification.title())); 231 EXPECT_EQ("", base::UTF16ToUTF8(default_notification.title()));
Peter Beverloo 2015/09/08 09:46:02 Could you give this a title, even if it's just a s
johnme 2015/09/14 16:14:58 Done.
230 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); 232 EXPECT_EQ("", base::UTF16ToUTF8(default_notification.message()));
231 EXPECT_EQ("replace-id", notification.tag()); 233 EXPECT_EQ("", default_notification.tag());
232 EXPECT_FALSE(notification.icon().IsEmpty()); 234 EXPECT_TRUE(default_notification.icon().IsEmpty());
233 EXPECT_TRUE(notification.silent()); 235 EXPECT_FALSE(default_notification.silent());
236 EXPECT_FALSE(default_notification.never_timeout());
234 237
235 EXPECT_EQ(kIconWidth, notification.icon().Width()); 238 // Now, test the non-default values.
236 EXPECT_EQ(kIconHeight, notification.icon().Height()); 239
240 ASSERT_TRUE(RunScript("DisplayPersistentAllOptionsNotification()",
241 &script_result));
242 EXPECT_EQ("ok", script_result);
243
244 ASSERT_EQ(2u, ui_manager()->GetNotificationCount());
245
246 // We don't use or check the notification's direction and language.
247 const Notification& all_options_notification =
248 ui_manager()->GetNotificationAt(1);
249 EXPECT_EQ("Title", base::UTF16ToUTF8(all_options_notification.title()));
250 EXPECT_EQ("Contents", base::UTF16ToUTF8(all_options_notification.message()));
251 EXPECT_EQ("replace-id", all_options_notification.tag());
252 EXPECT_FALSE(all_options_notification.icon().IsEmpty());
253 EXPECT_TRUE(all_options_notification.silent());
254 EXPECT_TRUE(all_options_notification.never_timeout());
255
256 EXPECT_EQ(kIconWidth, all_options_notification.icon().Width());
257 EXPECT_EQ(kIconHeight, all_options_notification.icon().Height());
237 } 258 }
238 259
239 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, 260 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
240 WebNotificationOptionsVibrationPattern) { 261 WebNotificationOptionsVibrationPattern) {
241 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); 262 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
242 263
243 std::string script_result; 264 std::string script_result;
244 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()", 265 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()",
245 &script_result)); 266 &script_result));
246 EXPECT_EQ("ok", script_result); 267 EXPECT_EQ("ok", script_result);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 393
373 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 394 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
374 395
375 const Notification& notification = ui_manager()->GetNotificationAt(0); 396 const Notification& notification = ui_manager()->GetNotificationAt(0);
376 EXPECT_FALSE(notification.icon().IsEmpty()); 397 EXPECT_FALSE(notification.icon().IsEmpty());
377 398
378 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); 399 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title()));
379 EXPECT_EQ(kIconWidth, notification.icon().Width()); 400 EXPECT_EQ(kIconWidth, notification.icon().Width());
380 EXPECT_EQ(kIconHeight, notification.icon().Height()); 401 EXPECT_EQ(kIconHeight, notification.icon().Height());
381 } 402 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/platform_notification_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698