Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / extensions / notifications_apitest.cc
blob10d95b63d7635482c329f42c88858514c326fe32
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/notifications/desktop_notification_service.h"
8 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/extensions/extension_process_manager.h"
12 #include "chrome/browser/extensions/lazy_background_page_test_util.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/extensions/extension.h"
15 #include "ui/message_center/message_center_switches.h"
16 #include "ui/message_center/message_center_util.h"
18 class NotificationIdleTest : public ExtensionApiTest {
19 protected:
20 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
21 ExtensionApiTest::SetUpCommandLine(command_line);
23 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1");
24 command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "1");
27 const extensions::Extension* LoadExtensionAndWait(
28 const std::string& test_name) {
29 LazyBackgroundObserver page_complete;
30 base::FilePath extdir = test_data_dir_.AppendASCII(test_name);
31 const extensions::Extension* extension = LoadExtension(extdir);
32 if (extension)
33 page_complete.Wait();
34 return extension;
38 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) {
39 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_;
42 // This test verifies that on RichNotification-enabled platforms HTML
43 // notificaitons are disabled.
44 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
45 // TODO(erg): linux_aura bringup: http://crbug.com/163931
46 #define MAYBE_NoHTMLNotifications DISABLED_NoHTMLNotifications
47 #elif defined(RUN_MESSAGE_CENTER_TESTS)
48 #define MAYBE_NoHTMLNotifications NoHTMLNotifications
49 #else
50 #define MAYBE_NoHTMLNotifications DISABLED_NoHTMLNotifications
51 #endif
52 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_NoHTMLNotifications) {
53 ASSERT_TRUE(message_center::IsRichNotificationEnabled());
54 ASSERT_TRUE(RunExtensionTest("notifications/no_html")) << message_;
57 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) {
58 DesktopNotificationServiceFactory::GetForProfile(browser()->profile())
59 ->GrantPermission(GURL(
60 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel"));
61 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs"))
62 << message_;
65 // MessaceCenter-specific test.
66 #if defined(RUN_MESSAGE_CENTER_TESTS)
67 #define MAYBE_NotificationsAllowUnload NotificationsAllowUnload
68 #else
69 #define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload
70 #endif
72 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) {
73 const extensions::Extension* extension =
74 LoadExtensionAndWait("notifications/api/unload");
75 ASSERT_TRUE(extension) << message_;
77 // Lazy Background Page has been shut down.
78 ExtensionProcessManager* pm =
79 extensions::ExtensionSystem::Get(profile())->process_manager();
80 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));