Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: chrome/browser/extensions/notifications_apitest.cc

Issue 376253005: Migrate the notification permission to the new common permission classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_profile_util.h"
9 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
12 #include "extensions/browser/process_manager.h" 11 #include "extensions/browser/process_manager.h"
13 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
14 #include "extensions/common/switches.h" 13 #include "extensions/common/switches.h"
15 14
16 class NotificationIdleTest : public ExtensionApiTest { 15 class NotificationIdleTest : public ExtensionApiTest {
17 protected: 16 protected:
18 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
19 ExtensionApiTest::SetUpCommandLine(command_line); 18 ExtensionApiTest::SetUpCommandLine(command_line);
(...skipping 13 matching lines...) Expand all
33 page_complete.Wait(); 32 page_complete.Wait();
34 return extension; 33 return extension;
35 } 34 }
36 }; 35 };
37 36
38 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) { 37 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsNoPermission) {
39 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_; 38 ASSERT_TRUE(RunExtensionTest("notifications/has_not_permission")) << message_;
40 } 39 }
41 40
42 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) { 41 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NotificationsHasPermission) {
43 DesktopNotificationServiceFactory::GetForProfile(browser()->profile()) 42 DesktopNotificationProfileUtil::GrantPermission(browser()->profile(),
44 ->GrantPermission(GURL( 43 GURL("chrome-extension://peoadpeiejnhkmpaakpnompolbglelel"));
45 "chrome-extension://peoadpeiejnhkmpaakpnompolbglelel")); 44
46 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs")) 45 ASSERT_TRUE(RunExtensionTest("notifications/has_permission_prefs"))
47 << message_; 46 << message_;
48 } 47 }
49 48
50 // MessaceCenter-specific test. 49 // MessaceCenter-specific test.
51 #if defined(RUN_MESSAGE_CENTER_TESTS) 50 #if defined(RUN_MESSAGE_CENTER_TESTS)
52 #define MAYBE_NotificationsAllowUnload NotificationsAllowUnload 51 #define MAYBE_NotificationsAllowUnload NotificationsAllowUnload
53 #else 52 #else
54 #define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload 53 #define MAYBE_NotificationsAllowUnload DISABLED_NotificationsAllowUnload
55 #endif 54 #endif
56 55
57 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) { 56 IN_PROC_BROWSER_TEST_F(NotificationIdleTest, MAYBE_NotificationsAllowUnload) {
58 const extensions::Extension* extension = 57 const extensions::Extension* extension =
59 LoadExtensionAndWait("notifications/api/unload"); 58 LoadExtensionAndWait("notifications/api/unload");
60 ASSERT_TRUE(extension) << message_; 59 ASSERT_TRUE(extension) << message_;
61 60
62 // Lazy Background Page has been shut down. 61 // Lazy Background Page has been shut down.
63 extensions::ProcessManager* pm = 62 extensions::ProcessManager* pm =
64 extensions::ExtensionSystem::Get(profile())->process_manager(); 63 extensions::ExtensionSystem::Get(profile())->process_manager();
65 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id())); 64 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));
66 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698