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

Side by Side Diff: chrome/browser/background/background_application_list_model_unittest.cc

Issue 8493017: Cleanup extension permissions module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TODO(rickcam): Bug 73183: Add unit tests for image loading 5 // TODO(rickcam): Bug 73183: Add unit tests for image loading
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 #include <set> 8 #include <set>
9 9
10 #include "chrome/browser/background/background_application_list_model.h" 10 #include "chrome/browser/background/background_application_list_model.h"
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "chrome/browser/extensions/extension_permissions_api.h"
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_service_unittest.h" 20 #include "chrome/browser/extensions/extension_service_unittest.h"
20 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_types.h" 24 #include "content/public/browser/notification_types.h"
24 #include "content/test/test_browser_thread.h" 25 #include "content/test/test_browser_thread.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 // This value is used to seed the PRNG at the beginning of a sequence of 28 // This value is used to seed the PRNG at the beginning of a sequence of
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 79 }
79 80
80 void AddBackgroundPermission(ExtensionService* service, 81 void AddBackgroundPermission(ExtensionService* service,
81 Extension* extension) { 82 Extension* extension) {
82 if (BackgroundApplicationListModel::IsBackgroundApp(*extension)) return; 83 if (BackgroundApplicationListModel::IsBackgroundApp(*extension)) return;
83 84
84 static scoped_refptr<Extension> temporary = 85 static scoped_refptr<Extension> temporary =
85 CreateExtension(GenerateUniqueExtensionName(), true); 86 CreateExtension(GenerateUniqueExtensionName(), true);
86 scoped_refptr<const ExtensionPermissionSet> permissions = 87 scoped_refptr<const ExtensionPermissionSet> permissions =
87 temporary->GetActivePermissions(); 88 temporary->GetActivePermissions();
88 ExtensionPermissionsManager(service).AddPermissions( 89 ExtensionPermissionsUpdater(service).AddPermissions(
89 extension, permissions.get()); 90 extension, permissions.get());
90 } 91 }
91 92
92 void RemoveBackgroundPermission(ExtensionService* service, 93 void RemoveBackgroundPermission(ExtensionService* service,
93 Extension* extension) { 94 Extension* extension) {
94 if (!BackgroundApplicationListModel::IsBackgroundApp(*extension)) return; 95 if (!BackgroundApplicationListModel::IsBackgroundApp(*extension)) return;
95 ExtensionPermissionsManager(service).RemovePermissions( 96 ExtensionPermissionsUpdater(service).RemovePermissions(
96 extension, extension->GetActivePermissions()); 97 extension, extension->GetActivePermissions());
97 } 98 }
98 } // namespace 99 } // namespace
99 100
100 // With minimal test logic, verifies behavior over an explicit set of 101 // With minimal test logic, verifies behavior over an explicit set of
101 // extensions, of which some are Background Apps and others are not. 102 // extensions, of which some are Background Apps and others are not.
102 TEST_F(BackgroundApplicationListModelTest, ExplicitTest) { 103 TEST_F(BackgroundApplicationListModelTest, ExplicitTest) {
103 InitializeAndLoadEmptyExtensionService(); 104 InitializeAndLoadEmptyExtensionService();
104 ExtensionService* service = profile_->GetExtensionService(); 105 ExtensionService* service = profile_->GetExtensionService();
105 ASSERT_TRUE(service); 106 ASSERT_TRUE(service);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 break; 331 break;
331 case 2: 332 case 2:
332 TogglePermission(service, &extensions, model.get(), &expected, &count); 333 TogglePermission(service, &extensions, model.get(), &expected, &count);
333 break; 334 break;
334 default: 335 default:
335 NOTREACHED(); 336 NOTREACHED();
336 break; 337 break;
337 } 338 }
338 } 339 }
339 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698