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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 254
255 class ServiceForManifestTests : public MockService { 255 class ServiceForManifestTests : public MockService {
256 public: 256 public:
257 ServiceForManifestTests() {} 257 ServiceForManifestTests() {}
258 258
259 virtual ~ServiceForManifestTests() {} 259 virtual ~ServiceForManifestTests() {}
260 260
261 virtual const Extension* GetExtensionById( 261 virtual const Extension* GetExtensionById(
262 const std::string& id, bool include_disabled) const OVERRIDE { 262 const std::string& id, bool include_disabled) const OVERRIDE {
263 return extensions_.GetByID(id); 263 const Extension* result = extensions_.GetByID(id);
264 if (result || !include_disabled)
265 return result;
266 return disabled_extensions_.GetByID(id);
264 } 267 }
265 268
266 virtual const ExtensionSet* extensions() const OVERRIDE { 269 virtual const ExtensionSet* extensions() const OVERRIDE {
267 return &extensions_; 270 return &extensions_;
268 } 271 }
269 272
273 virtual const ExtensionSet* disabled_extensions() const OVERRIDE {
274 return &disabled_extensions_;
275 }
276
270 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE { 277 virtual PendingExtensionManager* pending_extension_manager() OVERRIDE {
271 return &pending_extension_manager_; 278 return &pending_extension_manager_;
272 } 279 }
273 280
274 void set_extensions(ExtensionList extensions) { 281 void set_extensions(ExtensionList extensions) {
275 for (ExtensionList::const_iterator it = extensions.begin(); 282 for (ExtensionList::const_iterator it = extensions.begin();
276 it != extensions.end(); ++it) { 283 it != extensions.end(); ++it) {
277 extensions_.Insert(*it); 284 extensions_.Insert(*it);
278 } 285 }
279 } 286 }
280 287
288 void set_disabled_extensions(ExtensionList disabled_extensions) {
289 for (ExtensionList::const_iterator it = disabled_extensions.begin();
290 it != disabled_extensions.end(); ++it) {
291 disabled_extensions_.Insert(*it);
292 }
293 }
294
281 private: 295 private:
282 ExtensionSet extensions_; 296 ExtensionSet extensions_;
297 ExtensionSet disabled_extensions_;
283 }; 298 };
284 299
285 class ServiceForDownloadTests : public MockService { 300 class ServiceForDownloadTests : public MockService {
286 public: 301 public:
287 ServiceForDownloadTests() 302 ServiceForDownloadTests()
288 : MockService() { 303 : MockService() {
289 } 304 }
290 305
291 // Add a fake crx installer to be returned by a call to UpdateExtension() 306 // Add a fake crx installer to be returned by a call to UpdateExtension()
292 // with a specific ID. Caller keeps ownership of |crx_installer|. 307 // with a specific ID. Caller keeps ownership of |crx_installer|.
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 // |delegate|. 1348 // |delegate|.
1334 ExtensionDownloader* downloader = 1349 ExtensionDownloader* downloader =
1335 new ExtensionDownloader(&delegate, service.request_context()); 1350 new ExtensionDownloader(&delegate, service.request_context());
1336 ResetDownloader(&updater, downloader); 1351 ResetDownloader(&updater, downloader);
1337 1352
1338 // Non-internal non-external extensions should be rejected. 1353 // Non-internal non-external extensions should be rejected.
1339 ExtensionList extensions; 1354 ExtensionList extensions;
1340 service.CreateTestExtensions(1, 1, &extensions, NULL, Extension::INVALID); 1355 service.CreateTestExtensions(1, 1, &extensions, NULL, Extension::INVALID);
1341 service.CreateTestExtensions(2, 1, &extensions, NULL, Extension::INTERNAL); 1356 service.CreateTestExtensions(2, 1, &extensions, NULL, Extension::INTERNAL);
1342 ASSERT_EQ(2u, extensions.size()); 1357 ASSERT_EQ(2u, extensions.size());
1343 const std::string& id = extensions[1]->id(); 1358 const std::string& enabled_id = extensions[1]->id();
1359
1360 ExtensionList disabled_extensions;
1361 service.CreateTestExtensions(3, 1, &disabled_extensions, NULL,
1362 Extension::INVALID);
1363 service.CreateTestExtensions(4, 1, &disabled_extensions, NULL,
1364 Extension::INTERNAL);
1365 ASSERT_EQ(2u, disabled_extensions.size());
1366 const std::string& disabled_id = disabled_extensions[1]->id();
asargent_no_longer_on_chrome 2012/03/20 00:24:01 Since this test ("TestNonAutoUpdateableLocations")
Matt Tytel 2012/03/20 20:34:28 Done.
1344 1367
1345 // These expectations fail if the delegate's methods are invoked for the 1368 // These expectations fail if the delegate's methods are invoked for the
1346 // first extension, which has a non-matching id. 1369 // first extension, which has a non-matching id.
1347 EXPECT_CALL(delegate, GetUpdateUrlData(id)).WillOnce(Return("")); 1370 EXPECT_CALL(delegate, GetUpdateUrlData(enabled_id)).WillOnce(Return(""));
1348 EXPECT_CALL(delegate, GetPingDataForExtension(id, _)); 1371 EXPECT_CALL(delegate, GetPingDataForExtension(enabled_id, _));
1372
1373 EXPECT_CALL(delegate, GetUpdateUrlData(disabled_id)).WillOnce(Return(""));
1374 EXPECT_CALL(delegate, GetPingDataForExtension(disabled_id, _));
1349 1375
1350 service.set_extensions(extensions); 1376 service.set_extensions(extensions);
1377 service.set_disabled_extensions(disabled_extensions);
1351 updater.set_blacklist_checks_enabled(false); 1378 updater.set_blacklist_checks_enabled(false);
1352 updater.Start(); 1379 updater.Start();
1353 updater.CheckNow(); 1380 updater.CheckNow();
1354 } 1381 }
1355 1382
1356 TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) { 1383 TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
1357 TestURLFetcherFactory factory; 1384 TestURLFetcherFactory factory;
1358 MockService service; 1385 MockService service;
1359 MockExtensionDownloaderDelegate delegate; 1386 MockExtensionDownloaderDelegate delegate;
1360 scoped_ptr<ExtensionDownloader> downloader( 1387 scoped_ptr<ExtensionDownloader> downloader(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 // -prodversionmin (shouldn't update if browser version too old) 1472 // -prodversionmin (shouldn't update if browser version too old)
1446 // -manifests & updates arriving out of order / interleaved 1473 // -manifests & updates arriving out of order / interleaved
1447 // -malformed update url (empty, file://, has query, has a # fragment, etc.) 1474 // -malformed update url (empty, file://, has query, has a # fragment, etc.)
1448 // -An extension gets uninstalled while updates are in progress (so it doesn't 1475 // -An extension gets uninstalled while updates are in progress (so it doesn't
1449 // "come back from the dead") 1476 // "come back from the dead")
1450 // -An extension gets manually updated to v3 while we're downloading v2 (ie 1477 // -An extension gets manually updated to v3 while we're downloading v2 (ie
1451 // you don't get downgraded accidentally) 1478 // you don't get downgraded accidentally)
1452 // -An update manifest mentions multiple updates 1479 // -An update manifest mentions multiple updates
1453 1480
1454 } // namespace extensions 1481 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698