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 | 11 |
| 12 #if defined(ENABLE_MESSAGE_CENTER) |
| 13 |
| 14 #include "ui/message_center/message_center_switches.h" |
| 15 #include "ui/message_center/message_center_util.h" |
| 16 |
| 17 class RichWebkitNotificationTest : public ExtensionApiTest { |
| 18 protected: |
| 19 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 20 ExtensionApiTest::SetUpCommandLine(command_line); |
| 21 command_line->AppendSwitch( |
| 22 message_center::switches::kEnableRichNotifications); |
| 23 } |
| 24 }; |
| 25 |
| 26 class DisabledRichWebkitNotificationTest : public ExtensionApiTest { |
| 27 protected: |
| 28 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 29 ExtensionApiTest::SetUpCommandLine(command_line); |
| 30 command_line->AppendSwitch( |
| 31 message_center::switches::kDisableRichNotifications); |
| 32 } |
| 33 }; |
| 34 |
| 35 #endif |
| 36 |
12 // TODO(kbr): remove: http://crbug.com/222296 | 37 // TODO(kbr): remove: http://crbug.com/222296 |
13 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
14 #import "base/mac/mac_util.h" | 39 #import "base/mac/mac_util.h" |
15 #endif | 40 #endif |
16 | 41 |
17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { | 42 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { |
18 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | 43 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) |
19 // Notifications not supported on linux/views yet. | 44 // Notifications not supported on linux/views yet. |
20 #else | 45 #else |
21 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; | 46 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; |
22 #endif | 47 #endif |
23 } | 48 } |
24 | 49 |
25 // Disabled after createHTMLNotification removal | 50 #if defined(ENABLE_MESSAGE_CENTER) |
26 // (http://trac.webkit.org/changeset/140983) | 51 IN_PROC_BROWSER_TEST_F(RichWebkitNotificationTest, NoHTMLNotifications) { |
27 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, | 52 ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_; |
28 DISABLED_NotificationsHasPermissionManifest) { | 53 } |
29 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | 54 |
30 // Notifications not supported on linux/views yet. | 55 #if !defined(OS_CHROMEOS) |
31 #else | 56 // HTML notifications fail on ChromeOS whether or not rich notifications |
| 57 // are enabled. |
| 58 IN_PROC_BROWSER_TEST_F(DisabledRichWebkitNotificationTest, |
| 59 HasHTMLNotifications) { |
| 60 ASSERT_FALSE(message_center::IsRichNotificationEnabled()); |
32 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) | 61 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) |
33 << message_; | 62 << message_; |
| 63 } |
34 #endif | 64 #endif |
| 65 |
| 66 #elif !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
| 67 // Notifications not supported on linux/views yet. |
| 68 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, |
| 69 NotificationsHasPermissionManifest) { |
| 70 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_manifest")) |
| 71 << message_; |
35 } | 72 } |
| 73 #endif |
36 | 74 |
37 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { | 75 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { |
38 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) | 76 #if defined(OS_LINUX) && defined(TOOLKIT_VIEWS) |
39 // Notifications not supported on linux/views yet. | 77 // Notifications not supported on linux/views yet. |
40 #else | 78 #else |
41 | 79 |
42 #if defined(OS_MACOSX) | 80 #if defined(OS_MACOSX) |
43 // TODO(kbr): re-enable: http://crbug.com/222296 | 81 // TODO(kbr): re-enable: http://crbug.com/222296 |
44 if (base::mac::IsOSMountainLionOrLater()) | 82 if (base::mac::IsOSMountainLionOrLater()) |
45 return; | 83 return; |
46 #endif | 84 #endif |
47 | 85 |
48 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) | 86 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) |
49 ->GrantPermission(GURL( | 87 ->GrantPermission(GURL( |
50 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); | 88 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); |
51 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) | 89 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) |
52 << message_; | 90 << message_; |
53 #endif | 91 #endif |
54 } | 92 } |
OLD | NEW |