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

Side by Side Diff: extensions/browser/extension_registry_unittest.cc

Issue 125573002: Move ExtensionService::GetExtensionById() to ExtensionRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add test, get_extension_by_id Created 6 years, 11 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
« no previous file with comments | « extensions/browser/extension_registry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/extension_registry.h" 5 #include "extensions/browser/extension_registry.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // this functionality, but some users of ExtensionRegistry need it. 91 // this functionality, but some users of ExtensionRegistry need it.
92 EXPECT_TRUE(registry.AddEnabled(extension)); 92 EXPECT_TRUE(registry.AddEnabled(extension));
93 EXPECT_TRUE(registry.AddDisabled(extension)); 93 EXPECT_TRUE(registry.AddDisabled(extension));
94 94
95 EXPECT_EQ(1u, registry.enabled_extensions().size()); 95 EXPECT_EQ(1u, registry.enabled_extensions().size());
96 EXPECT_EQ(1u, registry.disabled_extensions().size()); 96 EXPECT_EQ(1u, registry.disabled_extensions().size());
97 EXPECT_EQ(0u, registry.terminated_extensions().size()); 97 EXPECT_EQ(0u, registry.terminated_extensions().size());
98 EXPECT_EQ(0u, registry.blacklisted_extensions().size()); 98 EXPECT_EQ(0u, registry.blacklisted_extensions().size());
99 } 99 }
100 100
101 TEST_F(ExtensionRegistryTest, GetExtensionById) {
102 ExtensionRegistry registry;
103
104 // Trying to get an extension fails cleanly when the sets are empty.
105 EXPECT_FALSE(
106 registry.GetExtensionById("id", ExtensionRegistry::EVERYTHING));
107
108 scoped_refptr<Extension> enabled = CreateExtensionWithID("enabled");
109 scoped_refptr<Extension> disabled = CreateExtensionWithID("disabled");
110 scoped_refptr<Extension> terminated = CreateExtensionWithID("terminated");
111 scoped_refptr<Extension> blacklisted = CreateExtensionWithID("blacklisted");
112
113 // Add an extension to each set.
114 registry.AddEnabled(enabled);
115 registry.AddDisabled(disabled);
116 registry.AddTerminated(terminated);
117 registry.AddBlacklisted(blacklisted);
118
119 // Enabled is part of everything and the enabled list.
120 EXPECT_TRUE(
121 registry.GetExtensionById("enabled", ExtensionRegistry::EVERYTHING));
122 EXPECT_TRUE(
123 registry.GetExtensionById("enabled", ExtensionRegistry::ENABLED));
124 EXPECT_FALSE(
125 registry.GetExtensionById("enabled", ExtensionRegistry::DISABLED));
126 EXPECT_FALSE(
127 registry.GetExtensionById("enabled", ExtensionRegistry::TERMINATED));
128 EXPECT_FALSE(
129 registry.GetExtensionById("enabled", ExtensionRegistry::BLACKLISTED));
130
131 // Disabled is part of everything and the disabled list.
132 EXPECT_TRUE(
133 registry.GetExtensionById("disabled", ExtensionRegistry::EVERYTHING));
134 EXPECT_FALSE(
135 registry.GetExtensionById("disabled", ExtensionRegistry::ENABLED));
136 EXPECT_TRUE(
137 registry.GetExtensionById("disabled", ExtensionRegistry::DISABLED));
138 EXPECT_FALSE(
139 registry.GetExtensionById("disabled", ExtensionRegistry::TERMINATED));
140 EXPECT_FALSE(
141 registry.GetExtensionById("disabled", ExtensionRegistry::BLACKLISTED));
142
143 // Terminated is part of everything and the terminated list.
144 EXPECT_TRUE(
145 registry.GetExtensionById("terminated", ExtensionRegistry::EVERYTHING));
146 EXPECT_FALSE(
147 registry.GetExtensionById("terminated", ExtensionRegistry::ENABLED));
148 EXPECT_FALSE(
149 registry.GetExtensionById("terminated", ExtensionRegistry::DISABLED));
150 EXPECT_TRUE(
151 registry.GetExtensionById("terminated", ExtensionRegistry::TERMINATED));
152 EXPECT_FALSE(
153 registry.GetExtensionById("terminated", ExtensionRegistry::BLACKLISTED));
154
155 // Blacklisted is part of everything and the blacklisted list.
156 EXPECT_TRUE(
157 registry.GetExtensionById("blacklisted", ExtensionRegistry::EVERYTHING));
158 EXPECT_FALSE(
159 registry.GetExtensionById("blacklisted", ExtensionRegistry::ENABLED));
160 EXPECT_FALSE(
161 registry.GetExtensionById("blacklisted", ExtensionRegistry::DISABLED));
162 EXPECT_FALSE(
163 registry.GetExtensionById("blacklisted", ExtensionRegistry::TERMINATED));
164 EXPECT_TRUE(
165 registry.GetExtensionById("blacklisted", ExtensionRegistry::BLACKLISTED));
166
167 // Enabled can be found with multiple flags set.
168 EXPECT_TRUE(registry.GetExtensionById(
169 "enabled", ExtensionRegistry::ENABLED | ExtensionRegistry::TERMINATED));
170
171 // Enabled isn't found if the wrong flags are set.
172 EXPECT_FALSE(registry.GetExtensionById(
173 "enabled", ExtensionRegistry::DISABLED | ExtensionRegistry::BLACKLISTED));
174 }
175
101 } // namespace 176 } // namespace
102 } // namespace extensions 177 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_registry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698