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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 | 6 |
7 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 7 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
8 #include "chrome/browser/notifications/desktop_notification_service.h" | 8 #include "chrome/browser/notifications/desktop_notification_service.h" |
9 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 9 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 if (extension) | 34 if (extension) |
35 page_complete.Wait(); | 35 page_complete.Wait(); |
36 return extension; | 36 return extension; |
37 } | 37 } |
38 }; | 38 }; |
39 | 39 |
40 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { | 40 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { |
41 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; | 41 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; |
42 } | 42 } |
43 | 43 |
44 // This test verifies that on RichNotification-enabled platforms HTML | |
45 // notificaitons are disabled. | |
46 #if defined(RUN_MESSAGE_CENTER_TESTS) | |
47 #define MAYBE_NoHTMLNotifications NoHTMLNotifications | |
48 #else | |
49 #define MAYBE_NoHTMLNotifications DISABLED_NoHTMLNotifications | |
50 #endif | |
51 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_NoHTMLNotifications) { | |
52 ASSERT_TRUE(message_center::IsRichNotificationEnabled()); | |
53 ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_; | |
54 } | |
55 | |
56 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { | 44 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { |
57 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) | 45 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) |
58 ->GrantPermission(GURL( | 46 ->GrantPermission(GURL( |
59 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); | 47 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); |
60 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) | 48 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) |
61 << message_; | 49 << message_; |
62 } | 50 } |
63 | 51 |
64 // MessaceCenter-specific test. | 52 // MessaceCenter-specific test. |
65 #if defined(RUN_MESSAGE_CENTER_TESTS) | 53 #if defined(RUN_MESSAGE_CENTER_TESTS) |
66 #define MAYBE_NotificationsAllowUnload NotificationsAllowUnload | 54 #define MAYBE_NotificationsAllowUnload NotificationsAllowUnload |
67 #else | 55 #else |
68 #define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload | 56 #define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload |
69 #endif | 57 #endif |
70 | 58 |
71 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) { | 59 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) { |
72 const extensions::Extension* extension = | 60 const extensions::Extension* extension = |
73 LoadExtensionAndWait("notifications/api/unload"); | 61 LoadExtensionAndWait("notifications/api/unload"); |
74 ASSERT_TRUE(extension) << message_; | 62 ASSERT_TRUE(extension) << message_; |
75 | 63 |
76 // Lazy Background Page has been shut down. | 64 // Lazy Background Page has been shut down. |
77 extensions::ProcessManager* pm = | 65 extensions::ProcessManager* pm = |
78 extensions::ExtensionSystem::Get(profile())->process_manager(); | 66 extensions::ExtensionSystem::Get(profile())->process_manager(); |
79 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); | 67 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); |
80 } | 68 } |
OLD | NEW |