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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/extension_registry.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_registry_unittest.cc
diff --git a/extensions/browser/extension_registry_unittest.cc b/extensions/browser/extension_registry_unittest.cc
index 4243dea4f39fc0703500463f5f4d306d2ec0df64..da1eda5228c1dfac5089d3ad4e12ec766e3e76a0 100644
--- a/extensions/browser/extension_registry_unittest.cc
+++ b/extensions/browser/extension_registry_unittest.cc
@@ -98,5 +98,80 @@ TEST_F(ExtensionRegistryTest, AddExtensionToRegistryTwice) {
EXPECT_EQ(0u, registry.blacklisted_extensions().size());
}
+TEST_F(ExtensionRegistryTest, GetExtensionById) {
+ ExtensionRegistry registry;
+
+ // Trying to get an extension fails cleanly when the sets are empty.
+ EXPECT_FALSE(
+ registry.GetExtensionById("id", ExtensionRegistry::EVERYTHING));
+
+ scoped_refptr<Extension> enabled = CreateExtensionWithID("enabled");
+ scoped_refptr<Extension> disabled = CreateExtensionWithID("disabled");
+ scoped_refptr<Extension> terminated = CreateExtensionWithID("terminated");
+ scoped_refptr<Extension> blacklisted = CreateExtensionWithID("blacklisted");
+
+ // Add an extension to each set.
+ registry.AddEnabled(enabled);
+ registry.AddDisabled(disabled);
+ registry.AddTerminated(terminated);
+ registry.AddBlacklisted(blacklisted);
+
+ // Enabled is part of everything and the enabled list.
+ EXPECT_TRUE(
+ registry.GetExtensionById("enabled", ExtensionRegistry::EVERYTHING));
+ EXPECT_TRUE(
+ registry.GetExtensionById("enabled", ExtensionRegistry::ENABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("enabled", ExtensionRegistry::DISABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("enabled", ExtensionRegistry::TERMINATED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("enabled", ExtensionRegistry::BLACKLISTED));
+
+ // Disabled is part of everything and the disabled list.
+ EXPECT_TRUE(
+ registry.GetExtensionById("disabled", ExtensionRegistry::EVERYTHING));
+ EXPECT_FALSE(
+ registry.GetExtensionById("disabled", ExtensionRegistry::ENABLED));
+ EXPECT_TRUE(
+ registry.GetExtensionById("disabled", ExtensionRegistry::DISABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("disabled", ExtensionRegistry::TERMINATED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("disabled", ExtensionRegistry::BLACKLISTED));
+
+ // Terminated is part of everything and the terminated list.
+ EXPECT_TRUE(
+ registry.GetExtensionById("terminated", ExtensionRegistry::EVERYTHING));
+ EXPECT_FALSE(
+ registry.GetExtensionById("terminated", ExtensionRegistry::ENABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("terminated", ExtensionRegistry::DISABLED));
+ EXPECT_TRUE(
+ registry.GetExtensionById("terminated", ExtensionRegistry::TERMINATED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("terminated", ExtensionRegistry::BLACKLISTED));
+
+ // Blacklisted is part of everything and the blacklisted list.
+ EXPECT_TRUE(
+ registry.GetExtensionById("blacklisted", ExtensionRegistry::EVERYTHING));
+ EXPECT_FALSE(
+ registry.GetExtensionById("blacklisted", ExtensionRegistry::ENABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("blacklisted", ExtensionRegistry::DISABLED));
+ EXPECT_FALSE(
+ registry.GetExtensionById("blacklisted", ExtensionRegistry::TERMINATED));
+ EXPECT_TRUE(
+ registry.GetExtensionById("blacklisted", ExtensionRegistry::BLACKLISTED));
+
+ // Enabled can be found with multiple flags set.
+ EXPECT_TRUE(registry.GetExtensionById(
+ "enabled", ExtensionRegistry::ENABLED | ExtensionRegistry::TERMINATED));
+
+ // Enabled isn't found if the wrong flags are set.
+ EXPECT_FALSE(registry.GetExtensionById(
+ "enabled", ExtensionRegistry::DISABLED | ExtensionRegistry::BLACKLISTED));
+}
+
} // namespace
} // namespace extensions
« 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