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/notifications/desktop_notification_service.h" | 7 #include "chrome/browser/notifications/desktop_notification_service.h" |
8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 8 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 | |
12 #if defined(ENABLE_MESSAGE_CENTER) | |
13 | |
14 #include "chrome/browser/extensions/extension_process_manager.h" | 11 #include "chrome/browser/extensions/extension_process_manager.h" |
15 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 12 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
16 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
18 #include "ui/message_center/message_center_switches.h" | 15 #include "ui/message_center/message_center_switches.h" |
19 #include "ui/message_center/message_center_util.h" | 16 #include "ui/message_center/message_center_util.h" |
20 | 17 |
21 class RichWebkitNotificationTest : public ExtensionApiTest { | 18 class RichWebkitNotificationTest : public ExtensionApiTest { |
22 protected: | 19 protected: |
23 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 20 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
(...skipping 25 matching lines...) Expand all Loading... | |
49 const std::string& test_name) { | 46 const std::string& test_name) { |
50 LazyBackgroundObserver page_complete; | 47 LazyBackgroundObserver page_complete; |
51 base::FilePath extdir = test_data_dir_.AppendASCII(test_name); | 48 base::FilePath extdir = test_data_dir_.AppendASCII(test_name); |
52 const extensions::Extension* extension = LoadExtension(extdir); | 49 const extensions::Extension* extension = LoadExtension(extdir); |
53 if (extension) | 50 if (extension) |
54 page_complete.Wait(); | 51 page_complete.Wait(); |
55 return extension; | 52 return extension; |
56 } | 53 } |
57 }; | 54 }; |
58 | 55 |
59 #endif | |
60 | |
61 // TODO(kbr): remove: http://crbug.com/222296 | 56 // TODO(kbr): remove: http://crbug.com/222296 |
62 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
63 #import "base/mac/mac_util.h" | 58 #import "base/mac/mac_util.h" |
64 #endif | 59 #endif |
65 | 60 |
66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { | 61 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { |
67 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | 62 if (!message_center::IsRichNotificationEnabled()) |
68 // Notifications not supported on linux/views yet. | 63 return; |
dewittj
2013/05/08 18:53:01
This is fine, but I wonder if this is a good place
Dmitry Titov
2013/05/08 23:03:26
Done, added a special macro for that.
| |
69 #else | |
70 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; | 64 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; |
71 #endif | |
72 } | 65 } |
73 | 66 |
74 #if defined(ENABLE_MESSAGE_CENTER) | |
75 IN_PROC_BROWSER_TEST_F(RichWebkitNotificationTest, NoHTMLNotifications) { | 67 IN_PROC_BROWSER_TEST_F(RichWebkitNotificationTest, NoHTMLNotifications) { |
68 if (!message_center::IsRichNotificationEnabled()) | |
69 return; | |
76 ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_; | 70 ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_; |
77 } | 71 } |
78 | 72 |
79 #if !defined(OS_CHROMEOS) | 73 #if !defined(OS_CHROMEOS) |
80 // HTML notifications fail on ChromeOS whether or not rich notifications | 74 // HTML notifications fail on ChromeOS whether or not rich notifications |
81 // are enabled. | 75 // are enabled. |
82 IN_PROC_BROWSER_TEST_F(DisabledRichWebkitNotificationTest, | 76 IN_PROC_BROWSER_TEST_F(DisabledRichWebkitNotificationTest, |
83 HasHTMLNotifications) { | 77 HasHTMLNotifications) { |
84 ASSERT_FALSE(message_center::IsRichNotificationEnabled()); | 78 ASSERT_FALSE(message_center::IsRichNotificationEnabled()); |
85 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) | 79 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) |
86 << message_; | 80 << message_; |
87 } | 81 } |
88 #endif | 82 #endif |
89 | 83 |
90 #elif !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | |
91 // Notifications not supported on linux/views yet. | |
92 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, | 84 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, |
93 NotificationsHasPermissionManifest) { | 85 NotificationsHasPermissionManifest) { |
86 // Test is looking for HTML Notificaitons. | |
dewittj
2013/05/08 18:53:01
nit: spelling
Dmitry Titov
2013/05/08 23:03:26
Removed the whole test. It's giving exactly the co
| |
87 if (message_center::IsRichNotificationEnabled()) | |
88 return; | |
89 | |
94 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) | 90 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) |
95 << message_; | 91 << message_; |
96 } | 92 } |
97 #endif | |
98 | 93 |
99 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { | 94 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { |
100 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | |
101 // Notifications not supported on linux/views yet. | |
102 #else | |
103 | |
104 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
105 // TODO(kbr): re-enable: http://crbug.com/222296 | 96 // TODO(kbr): re-enable: http://crbug.com/222296 |
106 if (base::mac::IsOSMountainLionOrLater()) | 97 if (base::mac::IsOSMountainLionOrLater()) |
107 return; | 98 return; |
108 #endif | 99 #endif |
109 | 100 |
110 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) | 101 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) |
111 ->GrantPermission(GURL( | 102 ->GrantPermission(GURL( |
112 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); | 103 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); |
113 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) | 104 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) |
114 << message_; | 105 << message_; |
115 #endif | |
116 } | 106 } |
117 | 107 |
118 #if defined(ENABLE_MESSAGE_CENTER) | |
119 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, NotificationsAllowUnload) { | 108 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, NotificationsAllowUnload) { |
109 if (!message_center::IsRichNotificationEnabled()) | |
110 return; | |
111 | |
120 const extensions::Extension* extension = | 112 const extensions::Extension* extension = |
121 LoadExtensionAndWait("notifications/api/unload"); | 113 LoadExtensionAndWait("notifications/api/unload"); |
122 ASSERT_TRUE(extension) << message_; | 114 ASSERT_TRUE(extension) << message_; |
123 | 115 |
124 // Lazy Background Page has been shut down. | 116 // Lazy Background Page has been shut down. |
125 ExtensionProcessManager* pm = | 117 ExtensionProcessManager* pm = |
126 extensions::ExtensionSystem::Get(profile())->process_manager(); | 118 extensions::ExtensionSystem::Get(profile())->process_manager(); |
127 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 119 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
128 } | 120 } |
129 #endif | |
OLD | NEW |