OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 delegate->Accept(); | 80 delegate->Accept(); |
81 else | 81 else |
82 delegate->Cancel(); | 82 delegate->Cancel(); |
83 } | 83 } |
84 | 84 |
85 // ----------------------------------------------------------------------------- | 85 // ----------------------------------------------------------------------------- |
86 | 86 |
87 // Dimensions of the icon.png resource in the notification test data directory. | 87 // Dimensions of the icon.png resource in the notification test data directory. |
88 const int kIconWidth = 100; | 88 const int kIconWidth = 100; |
89 const int kIconHeight = 100; | 89 const int kIconHeight = 100; |
| 90 const int kNotificationVibratePattern[] = { 100, 200, 300 }; |
90 | 91 |
91 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { | 92 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
92 public: | 93 public: |
93 PlatformNotificationServiceBrowserTest(); | 94 PlatformNotificationServiceBrowserTest(); |
94 ~PlatformNotificationServiceBrowserTest() override {} | 95 ~PlatformNotificationServiceBrowserTest() override {} |
95 | 96 |
96 // InProcessBrowserTest overrides. | 97 // InProcessBrowserTest overrides. |
97 void SetUp() override; | 98 void SetUp() override; |
98 void SetUpOnMainThread() override; | 99 void SetUpOnMainThread() override; |
99 void TearDown() override; | 100 void TearDown() override; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); | 265 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); |
265 EXPECT_EQ("replace-id", notification.tag()); | 266 EXPECT_EQ("replace-id", notification.tag()); |
266 EXPECT_FALSE(notification.icon().IsEmpty()); | 267 EXPECT_FALSE(notification.icon().IsEmpty()); |
267 EXPECT_TRUE(notification.silent()); | 268 EXPECT_TRUE(notification.silent()); |
268 | 269 |
269 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 270 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
270 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 271 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
271 } | 272 } |
272 | 273 |
273 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 274 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 275 WebNotificationOptionsVibratePattern) { |
| 276 std::string script_result; |
| 277 |
| 278 InfoBarResponder accepting_responder(browser(), true); |
| 279 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); |
| 280 EXPECT_EQ("granted", script_result); |
| 281 |
| 282 ASSERT_TRUE(RunScript("DisplayPersistentNotificationVibrate()", |
| 283 &script_result)); |
| 284 EXPECT_EQ("ok", script_result); |
| 285 |
| 286 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| 287 |
| 288 const Notification& notification = ui_manager()->GetNotificationAt(0); |
| 289 EXPECT_EQ("Title", base::UTF16ToUTF8(notification.title())); |
| 290 EXPECT_EQ("Contents", base::UTF16ToUTF8(notification.message())); |
| 291 |
| 292 ASSERT_EQ(arraysize(kNotificationVibratePattern), |
| 293 notification.vibrate_pattern().size()); |
| 294 for (size_t i = 0; i < arraysize(kNotificationVibratePattern); ++i) { |
| 295 EXPECT_EQ(kNotificationVibratePattern[i], |
| 296 notification.vibrate_pattern()[i]); |
| 297 } |
| 298 } |
| 299 |
| 300 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
274 CloseDisplayedPersistentNotification) { | 301 CloseDisplayedPersistentNotification) { |
275 std::string script_result; | 302 std::string script_result; |
276 | 303 |
277 InfoBarResponder accepting_responder(browser(), true); | 304 InfoBarResponder accepting_responder(browser(), true); |
278 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); | 305 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); |
279 EXPECT_EQ("granted", script_result); | 306 EXPECT_EQ("granted", script_result); |
280 | 307 |
281 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", | 308 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", |
282 &script_result)); | 309 &script_result)); |
283 EXPECT_EQ("ok", script_result); | 310 EXPECT_EQ("ok", script_result); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 409 |
383 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 410 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
384 | 411 |
385 const Notification& notification = ui_manager()->GetNotificationAt(0); | 412 const Notification& notification = ui_manager()->GetNotificationAt(0); |
386 EXPECT_FALSE(notification.icon().IsEmpty()); | 413 EXPECT_FALSE(notification.icon().IsEmpty()); |
387 | 414 |
388 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); | 415 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); |
389 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 416 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
390 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 417 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
391 } | 418 } |
OLD | NEW |