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 kNotificationVibrate[] = { 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 WebNotificationOptionsVibrate) { | |
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(kNotificationVibrate), notification.vibrate().size()); | |
Peter Beverloo
2015/04/26 23:26:41
What do you think about renaming "vibrate" to "vib
Sanghyun Park
2015/04/27 14:00:00
I like "vibration_pattern", too :)
I'll update
| |
293 for (size_t i = 0; i < arraysize(kNotificationVibrate); ++i) | |
294 EXPECT_EQ(kNotificationVibrate[i], notification.vibrate()[i]); | |
295 } | |
296 | |
297 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | |
274 CloseDisplayedPersistentNotification) { | 298 CloseDisplayedPersistentNotification) { |
275 std::string script_result; | 299 std::string script_result; |
276 | 300 |
277 InfoBarResponder accepting_responder(browser(), true); | 301 InfoBarResponder accepting_responder(browser(), true); |
278 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); | 302 ASSERT_TRUE(RunScript("RequestPermission()", &script_result)); |
279 EXPECT_EQ("granted", script_result); | 303 EXPECT_EQ("granted", script_result); |
280 | 304 |
281 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", | 305 ASSERT_TRUE(RunScript("DisplayPersistentNotification('action_close')", |
282 &script_result)); | 306 &script_result)); |
283 EXPECT_EQ("ok", script_result); | 307 EXPECT_EQ("ok", script_result); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 406 |
383 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 407 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
384 | 408 |
385 const Notification& notification = ui_manager()->GetNotificationAt(0); | 409 const Notification& notification = ui_manager()->GetNotificationAt(0); |
386 EXPECT_FALSE(notification.icon().IsEmpty()); | 410 EXPECT_FALSE(notification.icon().IsEmpty()); |
387 | 411 |
388 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); | 412 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); |
389 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 413 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
390 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 414 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
391 } | 415 } |
OLD | NEW |