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

Unified Diff: chrome/browser/extensions/updater/extension_updater_unittest.cc

Issue 9718028: Allow autoupdate to update disabled extensions. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review fixes and added tests. Created 8 years, 9 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
Index: chrome/browser/extensions/updater/extension_updater_unittest.cc
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index 825921d65460c235f8834d711f80701ab6311fb9..20bd799badd1ac31b650e45ac1d661af0a81ba89 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -260,13 +260,20 @@ class ServiceForManifestTests : public MockService {
virtual const Extension* GetExtensionById(
const std::string& id, bool include_disabled) const OVERRIDE {
- return extensions_.GetByID(id);
+ const Extension* result = extensions_.GetByID(id);
+ if (result || !include_disabled)
+ return result;
+ return disabled_extensions_.GetByID(id);
}
virtual const ExtensionSet* extensions() const OVERRIDE {
return &extensions_;
}
+ virtual const ExtensionSet* disabled_extensions() const OVERRIDE {
+ return &disabled_extensions_;
+ }
+
virtual PendingExtensionManager* pending_extension_manager() OVERRIDE {
return &pending_extension_manager_;
}
@@ -278,8 +285,16 @@ class ServiceForManifestTests : public MockService {
}
}
+ void set_disabled_extensions(ExtensionList disabled_extensions) {
+ for (ExtensionList::const_iterator it = disabled_extensions.begin();
+ it != disabled_extensions.end(); ++it) {
+ disabled_extensions_.Insert(*it);
+ }
+ }
+
private:
ExtensionSet extensions_;
+ ExtensionSet disabled_extensions_;
};
class ServiceForDownloadTests : public MockService {
@@ -1340,12 +1355,12 @@ TEST_F(ExtensionUpdaterTest, TestNonAutoUpdateableLocations) {
service.CreateTestExtensions(1, 1, &extensions, NULL, Extension::INVALID);
service.CreateTestExtensions(2, 1, &extensions, NULL, Extension::INTERNAL);
ASSERT_EQ(2u, extensions.size());
- const std::string& id = extensions[1]->id();
+ const std::string& updateable_id = extensions[1]->id();
// These expectations fail if the delegate's methods are invoked for the
// first extension, which has a non-matching id.
- EXPECT_CALL(delegate, GetUpdateUrlData(id)).WillOnce(Return(""));
- EXPECT_CALL(delegate, GetPingDataForExtension(id, _));
+ EXPECT_CALL(delegate, GetUpdateUrlData(updateable_id)).WillOnce(Return(""));
+ EXPECT_CALL(delegate, GetPingDataForExtension(updateable_id, _));
service.set_extensions(extensions);
updater.set_blacklist_checks_enabled(false);
@@ -1353,6 +1368,39 @@ TEST_F(ExtensionUpdaterTest, TestNonAutoUpdateableLocations) {
updater.CheckNow();
}
+TEST_F(ExtensionUpdaterTest, TestUpdatingDisabledExtensions) {
+ TestURLFetcherFactory factory;
+ ServiceForManifestTests service;
+ ExtensionUpdater updater(&service, service.extension_prefs(),
+ service.pref_service(), service.profile(),
+ kUpdateFrequencySecs);
+ MockExtensionDownloaderDelegate delegate;
+ // Set the downloader directly, so that all its events end up in the mock
+ // |delegate|.
+ ExtensionDownloader* downloader =
+ new ExtensionDownloader(&delegate, service.request_context());
+ ResetDownloader(&updater, downloader);
+
+ // Non-internal non-external extensions should be rejected.
+ ExtensionList disabled_extensions;
+ service.CreateTestExtensions(1, 1, &disabled_extensions, NULL,
+ Extension::INVALID);
+ service.CreateTestExtensions(2, 1, &disabled_extensions, NULL,
+ Extension::INTERNAL);
+ ASSERT_EQ(2u, disabled_extensions.size());
+ const std::string& updateable_id = disabled_extensions[1]->id();
asargent_no_longer_on_chrome 2012/03/21 18:47:31 I think the test would be better if you removed th
Matt Tytel 2012/03/26 05:23:59 Done.
+
+ // These expectations fail if the delegate's methods are invoked for the
+ // first extension, which has a non-matching id.
+ EXPECT_CALL(delegate, GetUpdateUrlData(updateable_id)).WillOnce(Return(""));
+ EXPECT_CALL(delegate, GetPingDataForExtension(updateable_id, _));
+
+ service.set_disabled_extensions(disabled_extensions);
+ updater.set_blacklist_checks_enabled(false);
+ updater.Start();
+ updater.CheckNow();
+}
+
TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
TestURLFetcherFactory factory;
MockService service;

Powered by Google App Engine
This is Rietveld 408576698