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

Unified Diff: extensions/browser/extension_registry_unittest.cc

Issue 279073003: Add a function triggering extension installed to ExtensionRegistryObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add more DCHECK and test code Created 6 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_observer.h ('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 f212f6c85c9cb8e8bf77378020c85e0d81fdbb15..8281ee0d51457b1f75a4b121163e057509de777a 100644
--- a/extensions/browser/extension_registry_unittest.cc
+++ b/extensions/browser/extension_registry_unittest.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/memory/ref_counted.h"
+#include "base/strings/string_util.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "extensions/common/test_util.h"
@@ -37,10 +38,12 @@ class TestObserver : public ExtensionRegistryObserver {
void Reset() {
loaded_.clear();
unloaded_.clear();
+ installed_.clear();
}
const ExtensionList& loaded() { return loaded_; }
const ExtensionList& unloaded() { return unloaded_; }
+ const ExtensionList& installed() { return installed_; }
private:
virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
@@ -55,8 +58,17 @@ class TestObserver : public ExtensionRegistryObserver {
unloaded_.push_back(extension);
}
+ virtual void OnExtensionWillBeInstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ const std::string& old_name) OVERRIDE {
+ installed_.push_back(extension);
+ }
+
ExtensionList loaded_;
ExtensionList unloaded_;
+ ExtensionList installed_;
};
TEST_F(ExtensionRegistryTest, FillAndClearRegistry) {
@@ -215,13 +227,19 @@ TEST_F(ExtensionRegistryTest, Observer) {
EXPECT_TRUE(observer.loaded().empty());
EXPECT_TRUE(observer.unloaded().empty());
+ EXPECT_TRUE(observer.installed().empty());
scoped_refptr<const Extension> extension =
test_util::CreateExtensionWithID("id");
+ registry.TriggerOnWillBeInstalled(extension, false, base::EmptyString());
+ EXPECT_TRUE(HasSingleExtension(observer.installed(), extension.get()));
+
registry.AddEnabled(extension);
registry.TriggerOnLoaded(extension);
+ registry.TriggerOnWillBeInstalled(extension, true, "foo");
+
EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get()));
EXPECT_TRUE(observer.unloaded().empty());
observer.Reset();
« no previous file with comments | « extensions/browser/extension_registry_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698