OLD | NEW |
---|---|
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 Loading... | |
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) { | |
Yoyo Zhou
2014/01/07 02:26:13
Add at least one test that has a bitmask with more
| |
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::INCLUDE_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(registry.GetExtensionById( | |
121 "enabled", ExtensionRegistry::INCLUDE_EVERYTHING)); | |
122 EXPECT_TRUE(registry.GetExtensionById( | |
123 "enabled", ExtensionRegistry::INCLUDE_ENABLED)); | |
124 EXPECT_FALSE(registry.GetExtensionById( | |
125 "enabled", ExtensionRegistry::INCLUDE_DISABLED)); | |
126 EXPECT_FALSE(registry.GetExtensionById( | |
127 "enabled", ExtensionRegistry::INCLUDE_TERMINATED)); | |
128 EXPECT_FALSE(registry.GetExtensionById( | |
129 "enabled", ExtensionRegistry::INCLUDE_BLACKLISTED)); | |
130 | |
131 // Disabled is part of everything and the disabled list. | |
132 EXPECT_TRUE(registry.GetExtensionById( | |
133 "disabled", ExtensionRegistry::INCLUDE_EVERYTHING)); | |
134 EXPECT_FALSE(registry.GetExtensionById( | |
135 "disabled", ExtensionRegistry::INCLUDE_ENABLED)); | |
136 EXPECT_TRUE(registry.GetExtensionById( | |
137 "disabled", ExtensionRegistry::INCLUDE_DISABLED)); | |
138 EXPECT_FALSE(registry.GetExtensionById( | |
139 "disabled", ExtensionRegistry::INCLUDE_TERMINATED)); | |
140 EXPECT_FALSE(registry.GetExtensionById( | |
141 "disabled", ExtensionRegistry::INCLUDE_BLACKLISTED)); | |
142 | |
143 // Terminated is part of everything and the terminated list. | |
144 EXPECT_TRUE(registry.GetExtensionById( | |
145 "terminated", ExtensionRegistry::INCLUDE_EVERYTHING)); | |
146 EXPECT_FALSE(registry.GetExtensionById( | |
147 "terminated", ExtensionRegistry::INCLUDE_ENABLED)); | |
148 EXPECT_FALSE(registry.GetExtensionById( | |
149 "terminated", ExtensionRegistry::INCLUDE_DISABLED)); | |
150 EXPECT_TRUE(registry.GetExtensionById( | |
151 "terminated", ExtensionRegistry::INCLUDE_TERMINATED)); | |
152 EXPECT_FALSE(registry.GetExtensionById( | |
153 "terminated", ExtensionRegistry::INCLUDE_BLACKLISTED)); | |
154 | |
155 // Blacklisted is part of everything and the blacklisted list. | |
156 EXPECT_TRUE(registry.GetExtensionById( | |
157 "blacklisted", ExtensionRegistry::INCLUDE_EVERYTHING)); | |
158 EXPECT_FALSE(registry.GetExtensionById( | |
159 "blacklisted", ExtensionRegistry::INCLUDE_ENABLED)); | |
160 EXPECT_FALSE(registry.GetExtensionById( | |
161 "blacklisted", ExtensionRegistry::INCLUDE_DISABLED)); | |
162 EXPECT_FALSE(registry.GetExtensionById( | |
163 "blacklisted", ExtensionRegistry::INCLUDE_TERMINATED)); | |
164 EXPECT_TRUE(registry.GetExtensionById( | |
165 "blacklisted", ExtensionRegistry::INCLUDE_BLACKLISTED)); | |
166 } | |
167 | |
101 } // namespace | 168 } // namespace |
102 } // namespace extensions | 169 } // namespace extensions |
OLD | NEW |