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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const Notification& notification = ui_manager()->GetNotificationAt(0); | 327 const Notification& notification = ui_manager()->GetNotificationAt(0); |
328 notification.delegate()->Click(); | 328 notification.delegate()->Click(); |
329 | 329 |
330 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); | 330 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
331 EXPECT_EQ("action_close", script_result); | 331 EXPECT_EQ("action_close", script_result); |
332 | 332 |
333 ASSERT_EQ(0u, ui_manager()->GetNotificationCount()); | 333 ASSERT_EQ(0u, ui_manager()->GetNotificationCount()); |
334 } | 334 } |
335 | 335 |
336 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, | 336 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| 337 UserClosesPersistentNotification) { |
| 338 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| 339 |
| 340 std::string script_result; |
| 341 ASSERT_TRUE( |
| 342 RunScript("DisplayPersistentNotification('close_test')", &script_result)); |
| 343 EXPECT_EQ("ok", script_result); |
| 344 |
| 345 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| 346 const Notification& notification = ui_manager()->GetNotificationAt(0); |
| 347 notification.delegate()->Close(true /* by_user */); |
| 348 |
| 349 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| 350 EXPECT_EQ("closing notification: close_test", script_result); |
| 351 } |
| 352 |
| 353 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
337 TestDisplayOriginContextMessage) { | 354 TestDisplayOriginContextMessage) { |
338 RequestAndAcceptPermission(); | 355 RequestAndAcceptPermission(); |
339 | 356 |
340 // Creates a simple notification. | 357 // Creates a simple notification. |
341 std::string script_result; | 358 std::string script_result; |
342 ASSERT_TRUE(RunScript("DisplayPersistentNotification()", &script_result)); | 359 ASSERT_TRUE(RunScript("DisplayPersistentNotification()", &script_result)); |
343 | 360 |
344 net::HostPortPair host_port = ServerHostPort(); | 361 net::HostPortPair host_port = ServerHostPort(); |
345 | 362 |
346 const Notification& notification = ui_manager()->GetNotificationAt(0); | 363 const Notification& notification = ui_manager()->GetNotificationAt(0); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 437 |
421 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 438 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
422 | 439 |
423 const Notification& notification = ui_manager()->GetNotificationAt(0); | 440 const Notification& notification = ui_manager()->GetNotificationAt(0); |
424 EXPECT_FALSE(notification.icon().IsEmpty()); | 441 EXPECT_FALSE(notification.icon().IsEmpty()); |
425 | 442 |
426 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); | 443 EXPECT_EQ("Blob Title", base::UTF16ToUTF8(notification.title())); |
427 EXPECT_EQ(kIconWidth, notification.icon().Width()); | 444 EXPECT_EQ(kIconWidth, notification.icon().Width()); |
428 EXPECT_EQ(kIconHeight, notification.icon().Height()); | 445 EXPECT_EQ(kIconHeight, notification.icon().Height()); |
429 } | 446 } |
OLD | NEW |