| OLD | NEW |
| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 // Install 5 extensions. | 473 // Install 5 extensions. |
| 474 for (int i = 0; i < 5; i++) { | 474 for (int i = 0; i < 5; i++) { |
| 475 std::string name = "test" + base::IntToString(i); | 475 std::string name = "test" + base::IntToString(i); |
| 476 extensions_.push_back(prefs_.AddExtension(name)); | 476 extensions_.push_back(prefs_.AddExtension(name)); |
| 477 } | 477 } |
| 478 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); | 478 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); |
| 479 | 479 |
| 480 ExtensionList::const_iterator iter; | 480 ExtensionList::const_iterator iter; |
| 481 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { | 481 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { |
| 482 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); | 482 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL)); |
| 483 } | 483 } |
| 484 // Blacklist one installed and one not-installed extension id. | 484 // Blacklist one installed and one not-installed extension id. |
| 485 std::set<std::string> blacklisted_ids; | 485 std::set<std::string> blacklisted_ids; |
| 486 blacklisted_ids.insert(extensions_[0]->id()); | 486 blacklisted_ids.insert(extensions_[0]->id()); |
| 487 blacklisted_ids.insert(not_installed_id_); | 487 blacklisted_ids.insert(not_installed_id_); |
| 488 prefs()->UpdateBlacklist(blacklisted_ids); | 488 prefs()->UpdateBlacklist(blacklisted_ids); |
| 489 } | 489 } |
| 490 | 490 |
| 491 virtual void Verify() { | 491 virtual void Verify() { |
| 492 // Make sure the two id's we expect to be blacklisted are. | 492 // Make sure the id we expect to be blacklisted is. |
| 493 EXPECT_TRUE(prefs()->IsExtensionBlacklisted(extensions_[0]->id())); | 493 EXPECT_FALSE(prefs()->UserMayLoad(extensions_[0], NULL)); |
| 494 EXPECT_TRUE(prefs()->IsExtensionBlacklisted(not_installed_id_)); | |
| 495 | 494 |
| 496 // Make sure the other id's are not blacklisted. | 495 // Make sure the other id's are not blacklisted. |
| 497 ExtensionList::const_iterator iter; | 496 ExtensionList::const_iterator iter; |
| 498 for (iter = extensions_.begin() + 1; iter != extensions_.end(); ++iter) { | 497 for (iter = extensions_.begin() + 1; iter != extensions_.end(); ++iter) |
| 499 EXPECT_FALSE(prefs()->IsExtensionBlacklisted((*iter)->id())); | 498 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL)); |
| 500 } | |
| 501 | 499 |
| 502 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted | 500 // Make sure GetInstalledExtensionsInfo returns only the non-blacklisted |
| 503 // extensions data. | 501 // extensions data. |
| 504 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( | 502 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( |
| 505 prefs()->GetInstalledExtensionsInfo()); | 503 prefs()->GetInstalledExtensionsInfo()); |
| 506 EXPECT_EQ(4u, info->size()); | 504 EXPECT_EQ(4u, info->size()); |
| 507 ExtensionPrefs::ExtensionsInfo::iterator info_iter; | 505 ExtensionPrefs::ExtensionsInfo::iterator info_iter; |
| 508 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) { | 506 for (info_iter = info->begin(); info_iter != info->end(); ++info_iter) { |
| 509 ExtensionInfo* extension_info = info_iter->get(); | 507 ExtensionInfo* extension_info = info_iter->get(); |
| 510 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id); | 508 EXPECT_NE(extensions_[0]->id(), extension_info->extension_id); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 EXPECT_EQ(string16(), error16); | 1255 EXPECT_EQ(string16(), error16); |
| 1258 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); | 1256 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); |
| 1259 EXPECT_EQ(string16(), error16); | 1257 EXPECT_EQ(string16(), error16); |
| 1260 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); | 1258 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); |
| 1261 EXPECT_EQ(string16(), error16); | 1259 EXPECT_EQ(string16(), error16); |
| 1262 } | 1260 } |
| 1263 }; | 1261 }; |
| 1264 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} | 1262 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} |
| 1265 | 1263 |
| 1266 } // namespace extensions | 1264 } // namespace extensions |
| OLD | NEW |