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

Unified Diff: extensions/browser/extension_registry_unittest.cc

Issue 2908513002: Include terminated extensions while retrieving extension version. (Closed)
Patch Set: fix browsertest Created 3 years, 7 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 fbf34c0cb6f49d541ecd6cc5a9687d41a0449b08..3d11f8be9684dbf3d0ecf0fa1c2d60c321633952 100644
--- a/extensions/browser/extension_registry_unittest.cc
+++ b/extensions/browser/extension_registry_unittest.cc
@@ -10,6 +10,7 @@
#include "base/memory/ref_counted.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/uninstall_reason.h"
+#include "extensions/common/extension_builder.h"
#include "extensions/common/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -72,11 +73,11 @@ class TestObserver : public ExtensionRegistryObserver {
void OnExtensionUninstalled(content::BrowserContext* browser_context,
const Extension* extension,
- extensions::UninstallReason reason) override {
+ UninstallReason reason) override {
uninstalled_.push_back(extension);
}
- void OnShutdown(extensions::ExtensionRegistry* registry) override { Reset(); }
+ void OnShutdown(ExtensionRegistry* registry) override { Reset(); }
ExtensionList loaded_;
ExtensionList unloaded_;
@@ -272,5 +273,41 @@ TEST_F(ExtensionRegistryTest, Observer) {
registry.RemoveObserver(&observer);
}
+// Regression test for https://crbug.com/724563.
+TEST_F(ExtensionRegistryTest, TerminatedExtensionStoredVersion) {
+ const std::string kVersionString = "1.2.3.4";
+ ExtensionRegistry registry(nullptr);
+ scoped_refptr<Extension> extension =
+ ExtensionBuilder()
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "Test")
+ .Set("version", kVersionString)
+ .Build())
+ .Build();
+ const ExtensionId extension_id = extension->id();
+
+ EXPECT_TRUE(registry.AddEnabled(extension));
+ EXPECT_FALSE(
+ registry.GetExtensionById(extension_id, ExtensionRegistry::TERMINATED));
+ {
+ base::Version version = registry.GetStoredVersion(extension_id);
+ ASSERT_TRUE(version.IsValid());
+ EXPECT_EQ(kVersionString,
+ registry.GetStoredVersion(extension_id).GetString());
+ }
+
+ // Simulate terminating |extension|.
+ EXPECT_TRUE(registry.RemoveEnabled(extension_id));
+ EXPECT_TRUE(registry.AddTerminated(extension));
+ EXPECT_TRUE(
+ registry.GetExtensionById(extension_id, ExtensionRegistry::TERMINATED));
+ {
+ base::Version version = registry.GetStoredVersion(extension_id);
+ ASSERT_TRUE(version.IsValid());
+ EXPECT_EQ(kVersionString,
+ registry.GetStoredVersion(extension_id).GetString());
+ }
+}
+
} // 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