OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/string_number_conversions.h" | 5 #include "base/strings/string_number_conversions.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 10 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 449 } |
450 | 450 |
451 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestEvents) { | 451 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestEvents) { |
452 ASSERT_TRUE(RunExtensionTest("notifications/api/events")) << message_; | 452 ASSERT_TRUE(RunExtensionTest("notifications/api/events")) << message_; |
453 } | 453 } |
454 | 454 |
455 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { | 455 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { |
456 ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; | 456 ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; |
457 } | 457 } |
458 | 458 |
459 // MessaceCenter-specific test. | 459 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestByUser) { |
460 #if defined(RUN_MESSAGE_CENTER_TESTS) | |
461 #define MAYBE_TestByUser TestByUser | |
462 #else | |
463 #define MAYBE_TestByUser DISABLED_TestByUser | |
464 #endif | |
465 | |
466 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestByUser) { | |
467 ASSERT_TRUE(message_center::IsRichNotificationEnabled()); | |
468 | |
469 const extensions::Extension* extension = | 460 const extensions::Extension* extension = |
470 LoadExtensionAndWait("notifications/api/by_user"); | 461 LoadExtensionAndWait("notifications/api/by_user"); |
471 ASSERT_TRUE(extension) << message_; | 462 ASSERT_TRUE(extension) << message_; |
472 | 463 |
473 { | 464 { |
474 ResultCatcher catcher; | 465 ResultCatcher catcher; |
475 g_browser_process->message_center()->RemoveNotification( | 466 g_browser_process->message_center()->RemoveNotification( |
476 extension->id() + "-FOO", | 467 extension->id() + "-FOO", |
477 false); | 468 false); |
478 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 469 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 "\"priority\": 1," | 610 "\"priority\": 1," |
620 "\"eventTime\": 1234567890.12345678," | 611 "\"eventTime\": 1234567890.12345678," |
621 "\"progress\": 101" | 612 "\"progress\": 101" |
622 "}]", | 613 "}]", |
623 browser(), | 614 browser(), |
624 utils::NONE); | 615 utils::NONE); |
625 EXPECT_FALSE(notification_create_function->GetError().empty()); | 616 EXPECT_FALSE(notification_create_function->GetError().empty()); |
626 } | 617 } |
627 } | 618 } |
628 | 619 |
629 // MessaceCenter-specific test. | 620 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestPartialUpdate) { |
630 #if defined(RUN_MESSAGE_CENTER_TESTS) | |
631 #define MAYBE_TestPartialUpdate TestPartialUpdate | |
632 #else | |
633 #define MAYBE_TestPartialUpdate DISABLED_TestPartialUpdate | |
634 #endif | |
635 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestPartialUpdate) { | |
636 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 621 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
637 | 622 |
638 // Create a new notification. | 623 // Create a new notification. |
639 std::string notification_id; | 624 std::string notification_id; |
640 { | 625 { |
641 scoped_refptr<extensions::NotificationsCreateFunction> | 626 scoped_refptr<extensions::NotificationsCreateFunction> |
642 notification_function( | 627 notification_function( |
643 new extensions::NotificationsCreateFunction()); | 628 new extensions::NotificationsCreateFunction()); |
644 notification_function->set_extension(empty_extension.get()); | 629 notification_function->set_extension(empty_extension.get()); |
645 notification_function->set_has_callback(true); | 630 notification_function->set_has_callback(true); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 const message_center::NotificationList::Notifications& notifications = | 704 const message_center::NotificationList::Notifications& notifications = |
720 g_browser_process->message_center()->GetVisibleNotifications(); | 705 g_browser_process->message_center()->GetVisibleNotifications(); |
721 ASSERT_EQ(1u, notifications.size()); | 706 ASSERT_EQ(1u, notifications.size()); |
722 message_center::Notification* notification = *(notifications.begin()); | 707 message_center::Notification* notification = *(notifications.begin()); |
723 EXPECT_EQ(base::ASCIIToUTF16(kNewTitle), notification->title()); | 708 EXPECT_EQ(base::ASCIIToUTF16(kNewTitle), notification->title()); |
724 EXPECT_EQ(base::ASCIIToUTF16(kNewMessage), notification->message()); | 709 EXPECT_EQ(base::ASCIIToUTF16(kNewMessage), notification->message()); |
725 EXPECT_EQ(kNewPriority, notification->priority()); | 710 EXPECT_EQ(kNewPriority, notification->priority()); |
726 EXPECT_EQ(0u, notification->buttons().size()); | 711 EXPECT_EQ(0u, notification->buttons().size()); |
727 } | 712 } |
728 | 713 |
729 // MessaceCenter-specific test. | 714 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetPermissionLevel) { |
730 #if defined(RUN_MESSAGE_CENTER_TESTS) | |
731 #define MAYBE_TestGetPermissionLevel TestGetPermissionLevel | |
732 #else | |
733 #define MAYBE_TestGetPermissionLevel DISABLED_TestGetPermissionLevel | |
734 #endif | |
735 | |
736 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, MAYBE_TestGetPermissionLevel) { | |
737 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 715 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
738 | 716 |
739 // Get permission level for the extension whose notifications are enabled. | 717 // Get permission level for the extension whose notifications are enabled. |
740 { | 718 { |
741 scoped_refptr<extensions::NotificationsGetPermissionLevelFunction> | 719 scoped_refptr<extensions::NotificationsGetPermissionLevelFunction> |
742 notification_function( | 720 notification_function( |
743 new extensions::NotificationsGetPermissionLevelFunction()); | 721 new extensions::NotificationsGetPermissionLevelFunction()); |
744 | 722 |
745 notification_function->set_extension(empty_extension.get()); | 723 notification_function->set_extension(empty_extension.get()); |
746 notification_function->set_has_callback(true); | 724 notification_function->set_has_callback(true); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 browser(), | 757 browser(), |
780 utils::NONE)); | 758 utils::NONE)); |
781 | 759 |
782 EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); | 760 EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); |
783 std::string permission_level; | 761 std::string permission_level; |
784 EXPECT_TRUE(result->GetAsString(&permission_level)); | 762 EXPECT_TRUE(result->GetAsString(&permission_level)); |
785 EXPECT_EQ("denied", permission_level); | 763 EXPECT_EQ("denied", permission_level); |
786 } | 764 } |
787 } | 765 } |
788 | 766 |
789 // MessaceCenter-specific test. | 767 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestOnPermissionLevelChanged) { |
790 #if defined(RUN_MESSAGE_CENTER_TESTS) | |
791 #define MAYBE_TestOnPermissionLevelChanged TestOnPermissionLevelChanged | |
792 #else | |
793 #define MAYBE_TestOnPermissionLevelChanged DISABLED_TestOnPermissionLevelChanged | |
794 #endif | |
795 | |
796 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, | |
797 MAYBE_TestOnPermissionLevelChanged) { | |
798 const extensions::Extension* extension = | 768 const extensions::Extension* extension = |
799 LoadExtensionAndWait("notifications/api/permission"); | 769 LoadExtensionAndWait("notifications/api/permission"); |
800 ASSERT_TRUE(extension) << message_; | 770 ASSERT_TRUE(extension) << message_; |
801 | 771 |
802 // Test permission level changing from granted to denied. | 772 // Test permission level changing from granted to denied. |
803 { | 773 { |
804 ResultCatcher catcher; | 774 ResultCatcher catcher; |
805 | 775 |
806 message_center::NotifierId notifier_id( | 776 message_center::NotifierId notifier_id( |
807 message_center::NotifierId::APPLICATION, | 777 message_center::NotifierId::APPLICATION, |
(...skipping 12 matching lines...) Expand all Loading... |
820 message_center::NotifierId notifier_id( | 790 message_center::NotifierId notifier_id( |
821 message_center::NotifierId::APPLICATION, | 791 message_center::NotifierId::APPLICATION, |
822 extension->id()); | 792 extension->id()); |
823 message_center::Notifier notifier(notifier_id, base::string16(), false); | 793 message_center::Notifier notifier(notifier_id, base::string16(), false); |
824 g_browser_process->message_center()->GetNotifierSettingsProvider()-> | 794 g_browser_process->message_center()->GetNotifierSettingsProvider()-> |
825 SetNotifierEnabled(notifier, true); | 795 SetNotifierEnabled(notifier, true); |
826 | 796 |
827 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 797 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
828 } | 798 } |
829 } | 799 } |
OLD | NEW |