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

Side by Side Diff: chrome/browser/extensions/extension_prefs_unittest.cc

Issue 10854009: Extension white and force lists (set by policy) should have priority over auto-updated Google black… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased and merged Created 8 years, 4 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 "extension_prefs_unittest.h" 5 #include "extension_prefs_unittest.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 485
486 // Install 5 extensions. 486 // Install 5 extensions.
487 for (int i = 0; i < 5; i++) { 487 for (int i = 0; i < 5; i++) {
488 std::string name = "test" + base::IntToString(i); 488 std::string name = "test" + base::IntToString(i);
489 extensions_.push_back(prefs_.AddExtension(name)); 489 extensions_.push_back(prefs_.AddExtension(name));
490 } 490 }
491 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); 491 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_));
492 492
493 ExtensionList::const_iterator iter; 493 ExtensionList::const_iterator iter;
494 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { 494 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) {
495 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); 495 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL));
496 } 496 }
497 // Blacklist one installed and one not-installed extension id. 497 // Blacklist one installed and one not-installed extension id.
498 std::set<std::string> blacklisted_ids; 498 std::set<std::string> blacklisted_ids;
499 blacklisted_ids.insert(extensions_[0]->id()); 499 blacklisted_ids.insert(extensions_[0]->id());
500 blacklisted_ids.insert(not_installed_id_); 500 blacklisted_ids.insert(not_installed_id_);
501 prefs()->UpdateBlacklist(blacklisted_ids); 501 prefs()->UpdateBlacklist(blacklisted_ids);
502 } 502 }
503 503
504 virtual void Verify() { 504 virtual void Verify() {
505 // Make sure the two id's we expect to be blacklisted are. 505 // Make sure the id we expect to be blacklisted is.
506 EXPECT_TRUE(prefs()->IsExtensionBlacklisted(extensions_[0]->id())); 506 EXPECT_FALSE(prefs()->UserMayLoad(extensions_[0], NULL));
507 EXPECT_TRUE(prefs()->IsExtensionBlacklisted(not_installed_id_));
508 507
509 // Make sure the other id's are not blacklisted. 508 // Make sure the other id's are not blacklisted.
510 ExtensionList::const_iterator iter; 509 ExtensionList::const_iterator iter;
511 for (iter = extensions_.begin() + 1; iter != extensions_.end(); ++iter) { 510 for (iter = extensions_.begin() + 1; iter != extensions_.end(); ++iter)
512 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); 511 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL));
513 }
514 512
515 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted 513 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted
516 // extensions data. 514 // extensions data.
517 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( 515 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info(
518 prefs()->GetInstalledExtensionsInfo()); 516 prefs()->GetInstalledExtensionsInfo());
519 EXPECT_EQ(4u, info->size()); 517 EXPECT_EQ(4u, info->size());
520 ExtensionPrefs::ExtensionsInfo::iterator info_iter; 518 ExtensionPrefs::ExtensionsInfo::iterator info_iter;
521 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) { 519 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) {
522 ExtensionInfo* extension_info = info_iter->get(); 520 ExtensionInfo* extension_info = info_iter->get();
523 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id); 521 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 EXPECT_EQ(string16(), error16); 1268 EXPECT_EQ(string16(), error16);
1271 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); 1269 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16));
1272 EXPECT_EQ(string16(), error16); 1270 EXPECT_EQ(string16(), error16);
1273 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); 1271 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16));
1274 EXPECT_EQ(string16(), error16); 1272 EXPECT_EQ(string16(), error16);
1275 } 1273 }
1276 }; 1274 };
1277 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} 1275 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {}
1278 1276
1279 } // namespace extensions 1277 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698