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

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

Issue 1054573002: Implement support for notification.vibrate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 12 matching lines...) Expand all
23 #include "content/public/test/browser_test_utils.h" 23 #include "content/public/test/browser_test_utils.h"
24 #include "net/base/filename_util.h" 24 #include "net/base/filename_util.h"
25 #include "net/test/spawned_test_server/spawned_test_server.h" 25 #include "net/test/spawned_test_server/spawned_test_server.h"
26 26
27 // ----------------------------------------------------------------------------- 27 // -----------------------------------------------------------------------------
28 28
29 // Dimensions of the icon.png resource in the notification test data directory. 29 // Dimensions of the icon.png resource in the notification test data directory.
30 const int kIconWidth = 100; 30 const int kIconWidth = 100;
31 const int kIconHeight = 100; 31 const int kIconHeight = 100;
32 32
33 const int kNotificationVibrationPattern[] = { 100, 200, 300 };
34
33 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { 35 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest {
34 public: 36 public:
35 PlatformNotificationServiceBrowserTest(); 37 PlatformNotificationServiceBrowserTest();
36 ~PlatformNotificationServiceBrowserTest() override {} 38 ~PlatformNotificationServiceBrowserTest() override {}
37 39
38 // InProcessBrowserTest overrides. 40 // InProcessBrowserTest overrides.
39 void SetUp() override; 41 void SetUp() override;
40 void SetUpOnMainThread() override; 42 void SetUpOnMainThread() override;
41 void TearDown() override; 43 void TearDown() override;
42 44
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); 214 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message()));
213 EXPECT_EQ("replace-id", notification.tag()); 215 EXPECT_EQ("replace-id", notification.tag());
214 EXPECT_FALSE(notification.icon().IsEmpty()); 216 EXPECT_FALSE(notification.icon().IsEmpty());
215 EXPECT_TRUE(notification.silent()); 217 EXPECT_TRUE(notification.silent());
216 218
217 EXPECT_EQ(kIconWidth, notification.icon().Width()); 219 EXPECT_EQ(kIconWidth, notification.icon().Width());
218 EXPECT_EQ(kIconHeight, notification.icon().Height()); 220 EXPECT_EQ(kIconHeight, notification.icon().Height());
219 } 221 }
220 222
221 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, 223 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
224 WebNotificationOptionsVibrationPattern) {
225 std::string script_result;
226
227 InfoBarResponder accepting_responder(GetInfoBarService(), true);
228 ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
229 EXPECT_EQ("granted", script_result);
230
231 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()",
232 &script_result));
233 EXPECT_EQ("ok", script_result);
234
235 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
236
237 const Notification& notification = ui_manager()->GetNotificationAt(0);
238 EXPECT_EQ("Title", base::UTF16ToUTF8(notification.title()));
239 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message()));
240
241 ASSERT_EQ(arraysize(kNotificationVibrationPattern),
242 notification.vibration_pattern().size());
243 for (size_t i = 0; i < arraysize(kNotificationVibrationPattern); ++i) {
244 EXPECT_EQ(kNotificationVibrationPattern[i],
245 notification.vibration_pattern()[i]);
246 }
247 }
248
249 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
222 CloseDisplayedPersistentNotification) { 250 CloseDisplayedPersistentNotification) {
223 std::string script_result; 251 std::string script_result;
224 252
225 InfoBarResponder accepting_responder(GetInfoBarService(), true); 253 InfoBarResponder accepting_responder(GetInfoBarService(), true);
226 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); 254 ASSERT_TRUE(RunScript("RequestPermission()", &script_result));
227 EXPECT_EQ("granted", script_result); 255 EXPECT_EQ("granted", script_result);
228 256
229 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", 257 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')",
230 &script_result)); 258 &script_result));
231 EXPECT_EQ("ok", script_result); 259 EXPECT_EQ("ok", script_result);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 358
331 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 359 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
332 360
333 const Notification& notification = ui_manager()->GetNotificationAt(0); 361 const Notification& notification = ui_manager()->GetNotificationAt(0);
334 EXPECT_FALSE(notification.icon().IsEmpty()); 362 EXPECT_FALSE(notification.icon().IsEmpty());
335 363
336 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); 364 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title()));
337 EXPECT_EQ(kIconWidth, notification.icon().Width()); 365 EXPECT_EQ(kIconWidth, notification.icon().Width());
338 EXPECT_EQ(kIconHeight, notification.icon().Height()); 366 EXPECT_EQ(kIconHeight, notification.icon().Height());
339 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698