| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 namespace extensions { | 46 namespace extensions { |
| 47 | 47 |
| 48 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 48 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { |
| 49 int schemes = URLPattern::SCHEME_ALL; | 49 int schemes = URLPattern::SCHEME_ALL; |
| 50 extent->AddPattern(URLPattern(schemes, pattern)); | 50 extent->AddPattern(URLPattern(schemes, pattern)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 ExtensionPrefsTest::ExtensionPrefsTest() | 53 ExtensionPrefsTest::ExtensionPrefsTest() |
| 54 : ui_thread_(BrowserThread::UI, &message_loop_), | 54 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 55 file_thread_(BrowserThread::FILE, &message_loop_) { | 55 file_thread_(BrowserThread::FILE, &message_loop_) { |
| 56 prefs_.reset(new TestExtensionPrefs(message_loop_.message_loop_proxy())); |
| 56 } | 57 } |
| 57 | 58 |
| 58 ExtensionPrefsTest::~ExtensionPrefsTest() {} | 59 ExtensionPrefsTest::~ExtensionPrefsTest() { |
| 60 prefs_.reset(NULL); |
| 61 } |
| 59 | 62 |
| 60 void ExtensionPrefsTest::RegisterPreferences() {} | 63 void ExtensionPrefsTest::RegisterPreferences() {} |
| 61 | 64 |
| 62 void ExtensionPrefsTest::SetUp() { | 65 void ExtensionPrefsTest::SetUp() { |
| 63 RegisterPreferences(); | 66 RegisterPreferences(); |
| 64 Initialize(); | 67 Initialize(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 void ExtensionPrefsTest::TearDown() { | 70 void ExtensionPrefsTest::TearDown() { |
| 68 Verify(); | 71 Verify(); |
| 69 | 72 |
| 70 // Reset ExtensionPrefs, and re-verify. | 73 // Reset ExtensionPrefs, and re-verify. |
| 71 prefs_.RecreateExtensionPrefs(); | 74 prefs_->RecreateExtensionPrefs(); |
| 72 RegisterPreferences(); | 75 RegisterPreferences(); |
| 73 Verify(); | 76 Verify(); |
| 77 prefs_->pref_service()->CommitPendingWrite(); |
| 78 message_loop_.RunAllPending(); |
| 74 } | 79 } |
| 75 | 80 |
| 76 // Tests the LastPingDay/SetLastPingDay functions. | 81 // Tests the LastPingDay/SetLastPingDay functions. |
| 77 class ExtensionPrefsLastPingDay : public ExtensionPrefsTest { | 82 class ExtensionPrefsLastPingDay : public ExtensionPrefsTest { |
| 78 public: | 83 public: |
| 79 ExtensionPrefsLastPingDay() | 84 ExtensionPrefsLastPingDay() |
| 80 : extension_time_(Time::Now() - TimeDelta::FromHours(4)), | 85 : extension_time_(Time::Now() - TimeDelta::FromHours(4)), |
| 81 blacklist_time_(Time::Now() - TimeDelta::FromHours(2)) {} | 86 blacklist_time_(Time::Now() - TimeDelta::FromHours(2)) {} |
| 82 | 87 |
| 83 virtual void Initialize() { | 88 virtual void Initialize() { |
| 84 extension_id_ = prefs_.AddExtensionAndReturnId("last_ping_day"); | 89 extension_id_ = prefs_->AddExtensionAndReturnId("last_ping_day"); |
| 85 EXPECT_TRUE(prefs()->LastPingDay(extension_id_).is_null()); | 90 EXPECT_TRUE(prefs()->LastPingDay(extension_id_).is_null()); |
| 86 prefs()->SetLastPingDay(extension_id_, extension_time_); | 91 prefs()->SetLastPingDay(extension_id_, extension_time_); |
| 87 prefs()->SetBlacklistLastPingDay(blacklist_time_); | 92 prefs()->SetBlacklistLastPingDay(blacklist_time_); |
| 88 } | 93 } |
| 89 | 94 |
| 90 virtual void Verify() { | 95 virtual void Verify() { |
| 91 Time result = prefs()->LastPingDay(extension_id_); | 96 Time result = prefs()->LastPingDay(extension_id_); |
| 92 EXPECT_FALSE(result.is_null()); | 97 EXPECT_FALSE(result.is_null()); |
| 93 EXPECT_TRUE(result == extension_time_); | 98 EXPECT_TRUE(result == extension_time_); |
| 94 result = prefs()->BlacklistLastPingDay(); | 99 result = prefs()->BlacklistLastPingDay(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 112 permission.has_permission = has_access; | 117 permission.has_permission = has_access; |
| 113 vector->push_back(permission); | 118 vector->push_back(permission); |
| 114 } | 119 } |
| 115 | 120 |
| 116 } // namspace | 121 } // namspace |
| 117 | 122 |
| 118 // Test the MediaGalleries permissions functions. | 123 // Test the MediaGalleries permissions functions. |
| 119 class MediaGalleriesPermissions : public ExtensionPrefsTest { | 124 class MediaGalleriesPermissions : public ExtensionPrefsTest { |
| 120 public: | 125 public: |
| 121 virtual void Initialize() { | 126 virtual void Initialize() { |
| 122 extension1_id_ = prefs_.AddExtensionAndReturnId("test1"); | 127 extension1_id_ = prefs_->AddExtensionAndReturnId("test1"); |
| 123 extension2_id_ = prefs_.AddExtensionAndReturnId("test2"); | 128 extension2_id_ = prefs_->AddExtensionAndReturnId("test2"); |
| 124 extension3_id_ = prefs_.AddExtensionAndReturnId("test3"); | 129 extension3_id_ = prefs_->AddExtensionAndReturnId("test3"); |
| 125 // Id4 isn't used to ensure that an empty permission list is ok. | 130 // Id4 isn't used to ensure that an empty permission list is ok. |
| 126 extension4_id_ = prefs_.AddExtensionAndReturnId("test4"); | 131 extension4_id_ = prefs_->AddExtensionAndReturnId("test4"); |
| 127 Verify(); | 132 Verify(); |
| 128 | 133 |
| 129 prefs()->SetMediaGalleryPermission(extension1_id_, 1, false); | 134 prefs()->SetMediaGalleryPermission(extension1_id_, 1, false); |
| 130 AddGalleryPermission(1, false, &extension1_expectation_); | 135 AddGalleryPermission(1, false, &extension1_expectation_); |
| 131 Verify(); | 136 Verify(); |
| 132 | 137 |
| 133 prefs()->SetMediaGalleryPermission(extension1_id_, 2, true); | 138 prefs()->SetMediaGalleryPermission(extension1_id_, 2, true); |
| 134 AddGalleryPermission(2, true, &extension1_expectation_); | 139 AddGalleryPermission(2, true, &extension1_expectation_); |
| 135 Verify(); | 140 Verify(); |
| 136 | 141 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 std::vector<chrome::MediaGalleryPermission> extension2_expectation_; | 201 std::vector<chrome::MediaGalleryPermission> extension2_expectation_; |
| 197 std::vector<chrome::MediaGalleryPermission> extension3_expectation_; | 202 std::vector<chrome::MediaGalleryPermission> extension3_expectation_; |
| 198 std::vector<chrome::MediaGalleryPermission> extension4_expectation_; | 203 std::vector<chrome::MediaGalleryPermission> extension4_expectation_; |
| 199 }; | 204 }; |
| 200 TEST_F(MediaGalleriesPermissions, MediaGalleries) {} | 205 TEST_F(MediaGalleriesPermissions, MediaGalleries) {} |
| 201 | 206 |
| 202 // Tests the GetToolbarOrder/SetToolbarOrder functions. | 207 // Tests the GetToolbarOrder/SetToolbarOrder functions. |
| 203 class ExtensionPrefsToolbarOrder : public ExtensionPrefsTest { | 208 class ExtensionPrefsToolbarOrder : public ExtensionPrefsTest { |
| 204 public: | 209 public: |
| 205 virtual void Initialize() { | 210 virtual void Initialize() { |
| 206 list_.push_back(prefs_.AddExtensionAndReturnId("1")); | 211 list_.push_back(prefs_->AddExtensionAndReturnId("1")); |
| 207 list_.push_back(prefs_.AddExtensionAndReturnId("2")); | 212 list_.push_back(prefs_->AddExtensionAndReturnId("2")); |
| 208 list_.push_back(prefs_.AddExtensionAndReturnId("3")); | 213 list_.push_back(prefs_->AddExtensionAndReturnId("3")); |
| 209 std::vector<std::string> before_list = prefs()->GetToolbarOrder(); | 214 std::vector<std::string> before_list = prefs()->GetToolbarOrder(); |
| 210 EXPECT_TRUE(before_list.empty()); | 215 EXPECT_TRUE(before_list.empty()); |
| 211 prefs()->SetToolbarOrder(list_); | 216 prefs()->SetToolbarOrder(list_); |
| 212 } | 217 } |
| 213 | 218 |
| 214 virtual void Verify() { | 219 virtual void Verify() { |
| 215 std::vector<std::string> result = prefs()->GetToolbarOrder(); | 220 std::vector<std::string> result = prefs()->GetToolbarOrder(); |
| 216 ASSERT_EQ(list_.size(), result.size()); | 221 ASSERT_EQ(list_.size(), result.size()); |
| 217 for (size_t i = 0; i < list_.size(); i++) { | 222 for (size_t i = 0; i < list_.size(); i++) { |
| 218 EXPECT_EQ(list_[i], result[i]); | 223 EXPECT_EQ(list_[i], result[i]); |
| 219 } | 224 } |
| 220 } | 225 } |
| 221 | 226 |
| 222 private: | 227 private: |
| 223 std::vector<std::string> list_; | 228 std::vector<std::string> list_; |
| 224 }; | 229 }; |
| 225 TEST_F(ExtensionPrefsToolbarOrder, ToolbarOrder) {} | 230 TEST_F(ExtensionPrefsToolbarOrder, ToolbarOrder) {} |
| 226 | 231 |
| 227 | 232 |
| 228 // Tests the IsExtensionDisabled/SetExtensionState functions. | 233 // Tests the IsExtensionDisabled/SetExtensionState functions. |
| 229 class ExtensionPrefsExtensionState : public ExtensionPrefsTest { | 234 class ExtensionPrefsExtensionState : public ExtensionPrefsTest { |
| 230 public: | 235 public: |
| 231 virtual void Initialize() { | 236 virtual void Initialize() { |
| 232 extension = prefs_.AddExtension("test"); | 237 extension = prefs_->AddExtension("test"); |
| 233 prefs()->SetExtensionState(extension->id(), Extension::DISABLED); | 238 prefs()->SetExtensionState(extension->id(), Extension::DISABLED); |
| 234 } | 239 } |
| 235 | 240 |
| 236 virtual void Verify() { | 241 virtual void Verify() { |
| 237 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension->id())); | 242 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension->id())); |
| 238 } | 243 } |
| 239 | 244 |
| 240 private: | 245 private: |
| 241 scoped_refptr<Extension> extension; | 246 scoped_refptr<Extension> extension; |
| 242 }; | 247 }; |
| 243 TEST_F(ExtensionPrefsExtensionState, ExtensionState) {} | 248 TEST_F(ExtensionPrefsExtensionState, ExtensionState) {} |
| 244 | 249 |
| 245 | 250 |
| 246 class ExtensionPrefsEscalatePermissions : public ExtensionPrefsTest { | 251 class ExtensionPrefsEscalatePermissions : public ExtensionPrefsTest { |
| 247 public: | 252 public: |
| 248 virtual void Initialize() { | 253 virtual void Initialize() { |
| 249 extension = prefs_.AddExtension("test"); | 254 extension = prefs_->AddExtension("test"); |
| 250 prefs()->SetDidExtensionEscalatePermissions(extension.get(), true); | 255 prefs()->SetDidExtensionEscalatePermissions(extension.get(), true); |
| 251 } | 256 } |
| 252 | 257 |
| 253 virtual void Verify() { | 258 virtual void Verify() { |
| 254 EXPECT_TRUE(prefs()->DidExtensionEscalatePermissions(extension->id())); | 259 EXPECT_TRUE(prefs()->DidExtensionEscalatePermissions(extension->id())); |
| 255 } | 260 } |
| 256 | 261 |
| 257 private: | 262 private: |
| 258 scoped_refptr<Extension> extension; | 263 scoped_refptr<Extension> extension; |
| 259 }; | 264 }; |
| 260 TEST_F(ExtensionPrefsEscalatePermissions, EscalatePermissions) {} | 265 TEST_F(ExtensionPrefsEscalatePermissions, EscalatePermissions) {} |
| 261 | 266 |
| 262 // Tests the AddGrantedPermissions / GetGrantedPermissions functions. | 267 // Tests the AddGrantedPermissions / GetGrantedPermissions functions. |
| 263 class ExtensionPrefsGrantedPermissions : public ExtensionPrefsTest { | 268 class ExtensionPrefsGrantedPermissions : public ExtensionPrefsTest { |
| 264 public: | 269 public: |
| 265 virtual void Initialize() { | 270 virtual void Initialize() { |
| 266 const APIPermissionInfo* permission_info = | 271 const APIPermissionInfo* permission_info = |
| 267 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); | 272 PermissionsInfo::GetInstance()->GetByID(APIPermission::kSocket); |
| 268 | 273 |
| 269 extension_id_ = prefs_.AddExtensionAndReturnId("test"); | 274 extension_id_ = prefs_->AddExtensionAndReturnId("test"); |
| 270 | 275 |
| 271 api_perm_set1_.insert(APIPermission::kTab); | 276 api_perm_set1_.insert(APIPermission::kTab); |
| 272 api_perm_set1_.insert(APIPermission::kBookmark); | 277 api_perm_set1_.insert(APIPermission::kBookmark); |
| 273 scoped_ptr<APIPermission> permission( | 278 scoped_ptr<APIPermission> permission( |
| 274 permission_info->CreateAPIPermission()); | 279 permission_info->CreateAPIPermission()); |
| 275 { | 280 { |
| 276 scoped_ptr<ListValue> value(new ListValue()); | 281 scoped_ptr<ListValue> value(new ListValue()); |
| 277 value->Append(Value::CreateStringValue("tcp-connect:*.example.com:80")); | 282 value->Append(Value::CreateStringValue("tcp-connect:*.example.com:80")); |
| 278 value->Append(Value::CreateStringValue("udp-bind::8080")); | 283 value->Append(Value::CreateStringValue("udp-bind::8080")); |
| 279 value->Append(Value::CreateStringValue("udp-send-to::8888")); | 284 value->Append(Value::CreateStringValue("udp-send-to::8888")); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 URLPatternSet ehost_permissions_; | 412 URLPatternSet ehost_permissions_; |
| 408 URLPatternSet shost_permissions_; | 413 URLPatternSet shost_permissions_; |
| 409 URLPatternSet effective_permissions_; | 414 URLPatternSet effective_permissions_; |
| 410 }; | 415 }; |
| 411 TEST_F(ExtensionPrefsGrantedPermissions, GrantedPermissions) {} | 416 TEST_F(ExtensionPrefsGrantedPermissions, GrantedPermissions) {} |
| 412 | 417 |
| 413 // Tests the SetActivePermissions / GetActivePermissions functions. | 418 // Tests the SetActivePermissions / GetActivePermissions functions. |
| 414 class ExtensionPrefsActivePermissions : public ExtensionPrefsTest { | 419 class ExtensionPrefsActivePermissions : public ExtensionPrefsTest { |
| 415 public: | 420 public: |
| 416 virtual void Initialize() { | 421 virtual void Initialize() { |
| 417 extension_id_ = prefs_.AddExtensionAndReturnId("test"); | 422 extension_id_ = prefs_->AddExtensionAndReturnId("test"); |
| 418 | 423 |
| 419 APIPermissionSet api_perms; | 424 APIPermissionSet api_perms; |
| 420 api_perms.insert(APIPermission::kTab); | 425 api_perms.insert(APIPermission::kTab); |
| 421 api_perms.insert(APIPermission::kBookmark); | 426 api_perms.insert(APIPermission::kBookmark); |
| 422 api_perms.insert(APIPermission::kHistory); | 427 api_perms.insert(APIPermission::kHistory); |
| 423 | 428 |
| 424 URLPatternSet ehosts; | 429 URLPatternSet ehosts; |
| 425 AddPattern(&ehosts, "http://*.google.com/*"); | 430 AddPattern(&ehosts, "http://*.google.com/*"); |
| 426 AddPattern(&ehosts, "http://example.com/*"); | 431 AddPattern(&ehosts, "http://example.com/*"); |
| 427 AddPattern(&ehosts, "chrome://favicon/*"); | 432 AddPattern(&ehosts, "chrome://favicon/*"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 455 private: | 460 private: |
| 456 std::string extension_id_; | 461 std::string extension_id_; |
| 457 scoped_refptr<PermissionSet> active_perms_; | 462 scoped_refptr<PermissionSet> active_perms_; |
| 458 }; | 463 }; |
| 459 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} | 464 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} |
| 460 | 465 |
| 461 // Tests the GetVersionString function. | 466 // Tests the GetVersionString function. |
| 462 class ExtensionPrefsVersionString : public ExtensionPrefsTest { | 467 class ExtensionPrefsVersionString : public ExtensionPrefsTest { |
| 463 public: | 468 public: |
| 464 virtual void Initialize() { | 469 virtual void Initialize() { |
| 465 extension = prefs_.AddExtension("test"); | 470 extension = prefs_->AddExtension("test"); |
| 466 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id())); | 471 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id())); |
| 467 prefs()->OnExtensionUninstalled(extension->id(), | 472 prefs()->OnExtensionUninstalled(extension->id(), |
| 468 Extension::INTERNAL, false); | 473 Extension::INTERNAL, false); |
| 469 } | 474 } |
| 470 | 475 |
| 471 virtual void Verify() { | 476 virtual void Verify() { |
| 472 EXPECT_EQ("", prefs()->GetVersionString(extension->id())); | 477 EXPECT_EQ("", prefs()->GetVersionString(extension->id())); |
| 473 } | 478 } |
| 474 | 479 |
| 475 private: | 480 private: |
| 476 scoped_refptr<Extension> extension; | 481 scoped_refptr<Extension> extension; |
| 477 }; | 482 }; |
| 478 TEST_F(ExtensionPrefsVersionString, VersionString) {} | 483 TEST_F(ExtensionPrefsVersionString, VersionString) {} |
| 479 | 484 |
| 480 // Tests various areas of blacklist functionality. | 485 // Tests various areas of blacklist functionality. |
| 481 class ExtensionPrefsBlacklist : public ExtensionPrefsTest { | 486 class ExtensionPrefsBlacklist : public ExtensionPrefsTest { |
| 482 public: | 487 public: |
| 483 virtual void Initialize() { | 488 virtual void Initialize() { |
| 484 not_installed_id_ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; | 489 not_installed_id_ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; |
| 485 | 490 |
| 486 // Install 5 extensions. | 491 // Install 5 extensions. |
| 487 for (int i = 0; i < 5; i++) { | 492 for (int i = 0; i < 5; i++) { |
| 488 std::string name = "test" + base::IntToString(i); | 493 std::string name = "test" + base::IntToString(i); |
| 489 extensions_.push_back(prefs_.AddExtension(name)); | 494 extensions_.push_back(prefs_->AddExtension(name)); |
| 490 } | 495 } |
| 491 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); | 496 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); |
| 492 | 497 |
| 493 ExtensionList::const_iterator iter; | 498 ExtensionList::const_iterator iter; |
| 494 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { | 499 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { |
| 495 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL)); | 500 EXPECT_TRUE(prefs()->UserMayLoad(*iter, NULL)); |
| 496 } | 501 } |
| 497 // Blacklist one installed and one not-installed extension id. | 502 // Blacklist one installed and one not-installed extension id. |
| 498 std::set<std::string> blacklisted_ids; | 503 std::set<std::string> blacklisted_ids; |
| 499 blacklisted_ids.insert(extensions_[0]->id()); | 504 blacklisted_ids.insert(extensions_[0]->id()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 TEST_F(ExtensionPrefsBlacklist, Blacklist) {} | 536 TEST_F(ExtensionPrefsBlacklist, Blacklist) {} |
| 532 | 537 |
| 533 class ExtensionPrefsAcknowledgment : public ExtensionPrefsTest { | 538 class ExtensionPrefsAcknowledgment : public ExtensionPrefsTest { |
| 534 public: | 539 public: |
| 535 virtual void Initialize() { | 540 virtual void Initialize() { |
| 536 not_installed_id_ = "pghjnghklobnfoidcldiidjjjhkeeaoi"; | 541 not_installed_id_ = "pghjnghklobnfoidcldiidjjjhkeeaoi"; |
| 537 | 542 |
| 538 // Install some extensions. | 543 // Install some extensions. |
| 539 for (int i = 0; i < 5; i++) { | 544 for (int i = 0; i < 5; i++) { |
| 540 std::string name = "test" + base::IntToString(i); | 545 std::string name = "test" + base::IntToString(i); |
| 541 extensions_.push_back(prefs_.AddExtension(name)); | 546 extensions_.push_back(prefs_->AddExtension(name)); |
| 542 } | 547 } |
| 543 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); | 548 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); |
| 544 | 549 |
| 545 ExtensionList::const_iterator iter; | 550 ExtensionList::const_iterator iter; |
| 546 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { | 551 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) { |
| 547 std::string id = (*iter)->id(); | 552 std::string id = (*iter)->id(); |
| 548 EXPECT_FALSE(prefs()->IsExternalExtensionAcknowledged(id)); | 553 EXPECT_FALSE(prefs()->IsExternalExtensionAcknowledged(id)); |
| 549 EXPECT_FALSE(prefs()->IsBlacklistedExtensionAcknowledged(id)); | 554 EXPECT_FALSE(prefs()->IsBlacklistedExtensionAcknowledged(id)); |
| 550 EXPECT_FALSE(prefs()->IsOrphanedExtensionAcknowledged(id)); | 555 EXPECT_FALSE(prefs()->IsOrphanedExtensionAcknowledged(id)); |
| 551 if (external_id_.empty()) { | 556 if (external_id_.empty()) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 }; | 611 }; |
| 607 TEST_F(ExtensionPrefsAcknowledgment, Acknowledgment) {} | 612 TEST_F(ExtensionPrefsAcknowledgment, Acknowledgment) {} |
| 608 | 613 |
| 609 // Tests force hiding browser actions. | 614 // Tests force hiding browser actions. |
| 610 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest { | 615 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest { |
| 611 public: | 616 public: |
| 612 virtual void Initialize() { | 617 virtual void Initialize() { |
| 613 // Install 5 extensions. | 618 // Install 5 extensions. |
| 614 for (int i = 0; i < 5; i++) { | 619 for (int i = 0; i < 5; i++) { |
| 615 std::string name = "test" + base::IntToString(i); | 620 std::string name = "test" + base::IntToString(i); |
| 616 extensions_.push_back(prefs_.AddExtension(name)); | 621 extensions_.push_back(prefs_->AddExtension(name)); |
| 617 } | 622 } |
| 618 | 623 |
| 619 ExtensionList::const_iterator iter; | 624 ExtensionList::const_iterator iter; |
| 620 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) | 625 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) |
| 621 EXPECT_TRUE(prefs()->GetBrowserActionVisibility(*iter)); | 626 EXPECT_TRUE(prefs()->GetBrowserActionVisibility(*iter)); |
| 622 | 627 |
| 623 prefs()->SetBrowserActionVisibility(extensions_[0], false); | 628 prefs()->SetBrowserActionVisibility(extensions_[0], false); |
| 624 prefs()->SetBrowserActionVisibility(extensions_[1], true); | 629 prefs()->SetBrowserActionVisibility(extensions_[1], true); |
| 625 } | 630 } |
| 626 | 631 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 &fetch_time)); | 668 &fetch_time)); |
| 664 ASSERT_EQ(crx_path.value(), | 669 ASSERT_EQ(crx_path.value(), |
| 665 basedir_.AppendASCII(base::IntToString(num)).value()); | 670 basedir_.AppendASCII(base::IntToString(num)).value()); |
| 666 ASSERT_EQ("1." + base::IntToString(num), version); | 671 ASSERT_EQ("1." + base::IntToString(num), version); |
| 667 ASSERT_TRUE(fetch_time == now_ + TimeDelta::FromSeconds(num)); | 672 ASSERT_TRUE(fetch_time == now_ + TimeDelta::FromSeconds(num)); |
| 668 } | 673 } |
| 669 | 674 |
| 670 virtual void Initialize() { | 675 virtual void Initialize() { |
| 671 PathService::Get(chrome::DIR_TEST_DATA, &basedir_); | 676 PathService::Get(chrome::DIR_TEST_DATA, &basedir_); |
| 672 now_ = Time::Now(); | 677 now_ = Time::Now(); |
| 673 id1_ = prefs_.AddExtensionAndReturnId("1"); | 678 id1_ = prefs_->AddExtensionAndReturnId("1"); |
| 674 id2_ = prefs_.AddExtensionAndReturnId("2"); | 679 id2_ = prefs_->AddExtensionAndReturnId("2"); |
| 675 id3_ = prefs_.AddExtensionAndReturnId("3"); | 680 id3_ = prefs_->AddExtensionAndReturnId("3"); |
| 676 id4_ = prefs_.AddExtensionAndReturnId("4"); | 681 id4_ = prefs_->AddExtensionAndReturnId("4"); |
| 677 | 682 |
| 678 // Set info for two extensions, then remove it. | 683 // Set info for two extensions, then remove it. |
| 679 SetIdleInfo(id1_, 1); | 684 SetIdleInfo(id1_, 1); |
| 680 SetIdleInfo(id2_, 2); | 685 SetIdleInfo(id2_, 2); |
| 681 VerifyIdleInfo(id1_, 1); | 686 VerifyIdleInfo(id1_, 1); |
| 682 VerifyIdleInfo(id2_, 2); | 687 VerifyIdleInfo(id2_, 2); |
| 683 std::set<std::string> ids = prefs()->GetIdleInstallInfoIds(); | 688 std::set<std::string> ids = prefs()->GetIdleInstallInfoIds(); |
| 684 EXPECT_EQ(2u, ids.size()); | 689 EXPECT_EQ(2u, ids.size()); |
| 685 EXPECT_TRUE(ContainsKey(ids, id1_)); | 690 EXPECT_TRUE(ContainsKey(ids, id1_)); |
| 686 EXPECT_TRUE(ContainsKey(ids, id2_)); | 691 EXPECT_TRUE(ContainsKey(ids, id2_)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 std::string id1_; | 735 std::string id1_; |
| 731 std::string id2_; | 736 std::string id2_; |
| 732 std::string id3_; | 737 std::string id3_; |
| 733 std::string id4_; | 738 std::string id4_; |
| 734 }; | 739 }; |
| 735 TEST_F(ExtensionPrefsIdleInstallInfo, IdleInstallInfo) {} | 740 TEST_F(ExtensionPrefsIdleInstallInfo, IdleInstallInfo) {} |
| 736 | 741 |
| 737 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { | 742 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { |
| 738 public: | 743 public: |
| 739 virtual void Initialize() { | 744 virtual void Initialize() { |
| 740 extension_ = prefs_.AddExtension("on_extension_installed"); | 745 extension_ = prefs_->AddExtension("on_extension_installed"); |
| 741 EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id())); | 746 EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id())); |
| 742 prefs()->OnExtensionInstalled( | 747 prefs()->OnExtensionInstalled( |
| 743 extension_.get(), Extension::DISABLED, | 748 extension_.get(), Extension::DISABLED, |
| 744 syncer::StringOrdinal()); | 749 syncer::StringOrdinal()); |
| 745 } | 750 } |
| 746 | 751 |
| 747 virtual void Verify() { | 752 virtual void Verify() { |
| 748 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension_->id())); | 753 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension_->id())); |
| 749 } | 754 } |
| 750 | 755 |
| 751 private: | 756 private: |
| 752 scoped_refptr<Extension> extension_; | 757 scoped_refptr<Extension> extension_; |
| 753 }; | 758 }; |
| 754 TEST_F(ExtensionPrefsOnExtensionInstalled, | 759 TEST_F(ExtensionPrefsOnExtensionInstalled, |
| 755 ExtensionPrefsOnExtensionInstalled) {} | 760 ExtensionPrefsOnExtensionInstalled) {} |
| 756 | 761 |
| 757 class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest { | 762 class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest { |
| 758 public: | 763 public: |
| 759 virtual void Initialize() { | 764 virtual void Initialize() { |
| 760 extension_ = prefs_.AddExtension("on_extension_installed"); | 765 extension_ = prefs_->AddExtension("on_extension_installed"); |
| 761 EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id())); | 766 EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id())); |
| 762 prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED, | 767 prefs()->OnExtensionInstalled(extension_.get(), Extension::ENABLED, |
| 763 syncer::StringOrdinal()); | 768 syncer::StringOrdinal()); |
| 764 } | 769 } |
| 765 | 770 |
| 766 virtual void Verify() { | 771 virtual void Verify() { |
| 767 // Set the flag and see if it persisted. | 772 // Set the flag and see if it persisted. |
| 768 prefs()->SetAppDraggedByUser(extension_->id()); | 773 prefs()->SetAppDraggedByUser(extension_->id()); |
| 769 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); | 774 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); |
| 770 | 775 |
| 771 // Make sure it doesn't change on consecutive calls. | 776 // Make sure it doesn't change on consecutive calls. |
| 772 prefs()->SetAppDraggedByUser(extension_->id()); | 777 prefs()->SetAppDraggedByUser(extension_->id()); |
| 773 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); | 778 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); |
| 774 } | 779 } |
| 775 | 780 |
| 776 private: | 781 private: |
| 777 scoped_refptr<Extension> extension_; | 782 scoped_refptr<Extension> extension_; |
| 778 }; | 783 }; |
| 779 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} | 784 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} |
| 780 | 785 |
| 781 class ExtensionPrefsFlags : public ExtensionPrefsTest { | 786 class ExtensionPrefsFlags : public ExtensionPrefsTest { |
| 782 public: | 787 public: |
| 783 virtual void Initialize() { | 788 virtual void Initialize() { |
| 784 { | 789 { |
| 785 base::DictionaryValue dictionary; | 790 base::DictionaryValue dictionary; |
| 786 dictionary.SetString(extension_manifest_keys::kName, "from_webstore"); | 791 dictionary.SetString(extension_manifest_keys::kName, "from_webstore"); |
| 787 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 792 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); |
| 788 webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 793 webstore_extension_ = prefs_->AddExtensionWithManifestAndFlags( |
| 789 dictionary, Extension::INTERNAL, Extension::FROM_WEBSTORE); | 794 dictionary, Extension::INTERNAL, Extension::FROM_WEBSTORE); |
| 790 } | 795 } |
| 791 | 796 |
| 792 { | 797 { |
| 793 base::DictionaryValue dictionary; | 798 base::DictionaryValue dictionary; |
| 794 dictionary.SetString(extension_manifest_keys::kName, "from_bookmark"); | 799 dictionary.SetString(extension_manifest_keys::kName, "from_bookmark"); |
| 795 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 800 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); |
| 796 bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 801 bookmark_extension_ = prefs_->AddExtensionWithManifestAndFlags( |
| 797 dictionary, Extension::INTERNAL, Extension::FROM_BOOKMARK); | 802 dictionary, Extension::INTERNAL, Extension::FROM_BOOKMARK); |
| 798 } | 803 } |
| 799 | 804 |
| 800 { | 805 { |
| 801 base::DictionaryValue dictionary; | 806 base::DictionaryValue dictionary; |
| 802 dictionary.SetString(extension_manifest_keys::kName, | 807 dictionary.SetString(extension_manifest_keys::kName, |
| 803 "was_installed_by_default"); | 808 "was_installed_by_default"); |
| 804 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); | 809 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); |
| 805 default_extension_ = prefs_.AddExtensionWithManifestAndFlags( | 810 default_extension_ = prefs_->AddExtensionWithManifestAndFlags( |
| 806 dictionary, | 811 dictionary, |
| 807 Extension::INTERNAL, | 812 Extension::INTERNAL, |
| 808 Extension::WAS_INSTALLED_BY_DEFAULT); | 813 Extension::WAS_INSTALLED_BY_DEFAULT); |
| 809 } | 814 } |
| 810 } | 815 } |
| 811 | 816 |
| 812 virtual void Verify() { | 817 virtual void Verify() { |
| 813 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id())); | 818 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id())); |
| 814 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id())); | 819 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id())); |
| 815 | 820 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 835 ext3_(NULL), | 840 ext3_(NULL), |
| 836 ext4_(NULL), | 841 ext4_(NULL), |
| 837 installed() { | 842 installed() { |
| 838 DictionaryValue simple_dict; | 843 DictionaryValue simple_dict; |
| 839 std::string error; | 844 std::string error; |
| 840 | 845 |
| 841 simple_dict.SetString(keys::kVersion, "1.0.0.0"); | 846 simple_dict.SetString(keys::kVersion, "1.0.0.0"); |
| 842 simple_dict.SetString(keys::kName, "unused"); | 847 simple_dict.SetString(keys::kName, "unused"); |
| 843 | 848 |
| 844 ext1_scoped_ = Extension::Create( | 849 ext1_scoped_ = Extension::Create( |
| 845 prefs_.temp_dir().AppendASCII("ext1_"), Extension::EXTERNAL_PREF, | 850 prefs_->temp_dir().AppendASCII("ext1_"), Extension::EXTERNAL_PREF, |
| 846 simple_dict, Extension::NO_FLAGS, &error); | 851 simple_dict, Extension::NO_FLAGS, &error); |
| 847 ext2_scoped_ = Extension::Create( | 852 ext2_scoped_ = Extension::Create( |
| 848 prefs_.temp_dir().AppendASCII("ext2_"), Extension::EXTERNAL_PREF, | 853 prefs_->temp_dir().AppendASCII("ext2_"), Extension::EXTERNAL_PREF, |
| 849 simple_dict, Extension::NO_FLAGS, &error); | 854 simple_dict, Extension::NO_FLAGS, &error); |
| 850 ext3_scoped_ = Extension::Create( | 855 ext3_scoped_ = Extension::Create( |
| 851 prefs_.temp_dir().AppendASCII("ext3_"), Extension::EXTERNAL_PREF, | 856 prefs_->temp_dir().AppendASCII("ext3_"), Extension::EXTERNAL_PREF, |
| 852 simple_dict, Extension::NO_FLAGS, &error); | 857 simple_dict, Extension::NO_FLAGS, &error); |
| 853 ext4_scoped_ = Extension::Create( | 858 ext4_scoped_ = Extension::Create( |
| 854 prefs_.temp_dir().AppendASCII("ext4_"), Extension::EXTERNAL_PREF, | 859 prefs_->temp_dir().AppendASCII("ext4_"), Extension::EXTERNAL_PREF, |
| 855 simple_dict, Extension::NO_FLAGS, &error); | 860 simple_dict, Extension::NO_FLAGS, &error); |
| 856 | 861 |
| 857 ext1_ = ext1_scoped_.get(); | 862 ext1_ = ext1_scoped_.get(); |
| 858 ext2_ = ext2_scoped_.get(); | 863 ext2_ = ext2_scoped_.get(); |
| 859 ext3_ = ext3_scoped_.get(); | 864 ext3_ = ext3_scoped_.get(); |
| 860 ext4_ = ext4_scoped_.get(); | 865 ext4_ = ext4_scoped_.get(); |
| 861 | 866 |
| 862 for (size_t i = 0; i < arraysize(installed); ++i) | 867 for (size_t i = 0; i < arraysize(installed); ++i) |
| 863 installed[i] = false; | 868 installed[i] = false; |
| 864 } | 869 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 TEST_F(ExtensionPrefsInstallOneExtension, ExtensionPrefsInstallOneExtension) {} | 959 TEST_F(ExtensionPrefsInstallOneExtension, ExtensionPrefsInstallOneExtension) {} |
| 955 | 960 |
| 956 // Check that we do not forget persistent incognito values after a reload. | 961 // Check that we do not forget persistent incognito values after a reload. |
| 957 class ExtensionPrefsInstallIncognitoPersistent | 962 class ExtensionPrefsInstallIncognitoPersistent |
| 958 : public ExtensionPrefsPrepopulatedTest { | 963 : public ExtensionPrefsPrepopulatedTest { |
| 959 public: | 964 public: |
| 960 virtual void Initialize() { | 965 virtual void Initialize() { |
| 961 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); | 966 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); |
| 962 InstallExtControlledPrefIncognito(ext1_, kPref1, | 967 InstallExtControlledPrefIncognito(ext1_, kPref1, |
| 963 Value::CreateStringValue("val2")); | 968 Value::CreateStringValue("val2")); |
| 964 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 969 scoped_ptr<PrefService> incog_prefs(prefs_->CreateIncognitoPrefService()); |
| 965 std::string actual = incog_prefs->GetString(kPref1); | 970 std::string actual = incog_prefs->GetString(kPref1); |
| 966 EXPECT_EQ("val2", actual); | 971 EXPECT_EQ("val2", actual); |
| 967 } | 972 } |
| 968 virtual void Verify() { | 973 virtual void Verify() { |
| 969 // Main pref service shall see only non-incognito settings. | 974 // Main pref service shall see only non-incognito settings. |
| 970 std::string actual = prefs()->pref_service()->GetString(kPref1); | 975 std::string actual = prefs()->pref_service()->GetString(kPref1); |
| 971 EXPECT_EQ("val1", actual); | 976 EXPECT_EQ("val1", actual); |
| 972 // Incognito pref service shall see incognito values. | 977 // Incognito pref service shall see incognito values. |
| 973 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 978 scoped_ptr<PrefService> incog_prefs(prefs_->CreateIncognitoPrefService()); |
| 974 actual = incog_prefs->GetString(kPref1); | 979 actual = incog_prefs->GetString(kPref1); |
| 975 EXPECT_EQ("val2", actual); | 980 EXPECT_EQ("val2", actual); |
| 976 } | 981 } |
| 977 }; | 982 }; |
| 978 TEST_F(ExtensionPrefsInstallIncognitoPersistent, | 983 TEST_F(ExtensionPrefsInstallIncognitoPersistent, |
| 979 ExtensionPrefsInstallOneExtension) {} | 984 ExtensionPrefsInstallOneExtension) {} |
| 980 | 985 |
| 981 // Check that we forget 'session only' incognito values after a reload. | 986 // Check that we forget 'session only' incognito values after a reload. |
| 982 class ExtensionPrefsInstallIncognitoSessionOnly | 987 class ExtensionPrefsInstallIncognitoSessionOnly |
| 983 : public ExtensionPrefsPrepopulatedTest { | 988 : public ExtensionPrefsPrepopulatedTest { |
| 984 public: | 989 public: |
| 985 ExtensionPrefsInstallIncognitoSessionOnly() : iteration_(0) {} | 990 ExtensionPrefsInstallIncognitoSessionOnly() : iteration_(0) {} |
| 986 | 991 |
| 987 virtual void Initialize() { | 992 virtual void Initialize() { |
| 988 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); | 993 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); |
| 989 InstallExtControlledPrefIncognitoSessionOnly( | 994 InstallExtControlledPrefIncognitoSessionOnly( |
| 990 ext1_, kPref1, Value::CreateStringValue("val2")); | 995 ext1_, kPref1, Value::CreateStringValue("val2")); |
| 991 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 996 scoped_ptr<PrefService> incog_prefs(prefs_->CreateIncognitoPrefService()); |
| 992 std::string actual = incog_prefs->GetString(kPref1); | 997 std::string actual = incog_prefs->GetString(kPref1); |
| 993 EXPECT_EQ("val2", actual); | 998 EXPECT_EQ("val2", actual); |
| 994 } | 999 } |
| 995 virtual void Verify() { | 1000 virtual void Verify() { |
| 996 // Main pref service shall see only non-incognito settings. | 1001 // Main pref service shall see only non-incognito settings. |
| 997 std::string actual = prefs()->pref_service()->GetString(kPref1); | 1002 std::string actual = prefs()->pref_service()->GetString(kPref1); |
| 998 EXPECT_EQ("val1", actual); | 1003 EXPECT_EQ("val1", actual); |
| 999 // Incognito pref service shall see session-only incognito values only | 1004 // Incognito pref service shall see session-only incognito values only |
| 1000 // during first run. Once the pref service was reloaded, all values shall be | 1005 // during first run. Once the pref service was reloaded, all values shall be |
| 1001 // discarded. | 1006 // discarded. |
| 1002 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 1007 scoped_ptr<PrefService> incog_prefs(prefs_->CreateIncognitoPrefService()); |
| 1003 actual = incog_prefs->GetString(kPref1); | 1008 actual = incog_prefs->GetString(kPref1); |
| 1004 if (iteration_ == 0) { | 1009 if (iteration_ == 0) { |
| 1005 EXPECT_EQ("val2", actual); | 1010 EXPECT_EQ("val2", actual); |
| 1006 } else { | 1011 } else { |
| 1007 EXPECT_EQ("val1", actual); | 1012 EXPECT_EQ("val1", actual); |
| 1008 } | 1013 } |
| 1009 ++iteration_; | 1014 ++iteration_; |
| 1010 } | 1015 } |
| 1011 int iteration_; | 1016 int iteration_; |
| 1012 }; | 1017 }; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 using testing::_; | 1053 using testing::_; |
| 1049 using testing::Mock; | 1054 using testing::Mock; |
| 1050 using testing::StrEq; | 1055 using testing::StrEq; |
| 1051 | 1056 |
| 1052 content::MockNotificationObserver observer; | 1057 content::MockNotificationObserver observer; |
| 1053 PrefChangeRegistrar registrar; | 1058 PrefChangeRegistrar registrar; |
| 1054 registrar.Init(prefs()->pref_service()); | 1059 registrar.Init(prefs()->pref_service()); |
| 1055 registrar.Add(kPref1, &observer); | 1060 registrar.Add(kPref1, &observer); |
| 1056 | 1061 |
| 1057 content::MockNotificationObserver incognito_observer; | 1062 content::MockNotificationObserver incognito_observer; |
| 1058 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 1063 scoped_ptr<PrefService> incog_prefs(prefs_->CreateIncognitoPrefService()); |
| 1059 PrefChangeRegistrar incognito_registrar; | 1064 PrefChangeRegistrar incognito_registrar; |
| 1060 incognito_registrar.Init(incog_prefs.get()); | 1065 incognito_registrar.Init(incog_prefs.get()); |
| 1061 incognito_registrar.Add(kPref1, &incognito_observer); | 1066 incognito_registrar.Add(kPref1, &incognito_observer); |
| 1062 | 1067 |
| 1063 // Write value and check notification. | 1068 // Write value and check notification. |
| 1064 EXPECT_CALL(observer, Observe(_, _, _)); | 1069 EXPECT_CALL(observer, Observe(_, _, _)); |
| 1065 EXPECT_CALL(incognito_observer, Observe(_, _, _)); | 1070 EXPECT_CALL(incognito_observer, Observe(_, _, _)); |
| 1066 InstallExtControlledPref(ext1_, kPref1, | 1071 InstallExtControlledPref(ext1_, kPref1, |
| 1067 Value::CreateStringValue("https://www.chromium.org")); | 1072 Value::CreateStringValue("https://www.chromium.org")); |
| 1068 Mock::VerifyAndClearExpectations(&observer); | 1073 Mock::VerifyAndClearExpectations(&observer); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 InstallExtControlledPrefIncognito(ext1_, kPref1, v1i); | 1179 InstallExtControlledPrefIncognito(ext1_, kPref1, v1i); |
| 1175 testing::Mock::VerifyAndClearExpectations(v1); | 1180 testing::Mock::VerifyAndClearExpectations(v1); |
| 1176 testing::Mock::VerifyAndClearExpectations(v1i); | 1181 testing::Mock::VerifyAndClearExpectations(v1i); |
| 1177 // Make sure there is no memory leak and both values are deleted. | 1182 // Make sure there is no memory leak and both values are deleted. |
| 1178 EXPECT_CALL(*v1, Die()).Times(1); | 1183 EXPECT_CALL(*v1, Die()).Times(1); |
| 1179 EXPECT_CALL(*v1i, Die()).Times(1); | 1184 EXPECT_CALL(*v1i, Die()).Times(1); |
| 1180 EXPECT_CALL(*v2, Die()).Times(1); | 1185 EXPECT_CALL(*v2, Die()).Times(1); |
| 1181 EXPECT_CALL(*v2i, Die()).Times(1); | 1186 EXPECT_CALL(*v2i, Die()).Times(1); |
| 1182 InstallExtControlledPref(ext1_, kPref1, v2); | 1187 InstallExtControlledPref(ext1_, kPref1, v2); |
| 1183 InstallExtControlledPrefIncognito(ext1_, kPref1, v2i); | 1188 InstallExtControlledPrefIncognito(ext1_, kPref1, v2i); |
| 1184 prefs_.RecreateExtensionPrefs(); | 1189 prefs_->RecreateExtensionPrefs(); |
| 1185 testing::Mock::VerifyAndClearExpectations(v1); | 1190 testing::Mock::VerifyAndClearExpectations(v1); |
| 1186 testing::Mock::VerifyAndClearExpectations(v1i); | 1191 testing::Mock::VerifyAndClearExpectations(v1i); |
| 1187 testing::Mock::VerifyAndClearExpectations(v2); | 1192 testing::Mock::VerifyAndClearExpectations(v2); |
| 1188 testing::Mock::VerifyAndClearExpectations(v2i); | 1193 testing::Mock::VerifyAndClearExpectations(v2i); |
| 1189 } | 1194 } |
| 1190 | 1195 |
| 1191 virtual void Verify() { | 1196 virtual void Verify() { |
| 1192 } | 1197 } |
| 1193 }; | 1198 }; |
| 1194 TEST_F(ExtensionPrefsSetExtensionControlledPref, | 1199 TEST_F(ExtensionPrefsSetExtensionControlledPref, |
| 1195 ExtensionPrefsSetExtensionControlledPref) {} | 1200 ExtensionPrefsSetExtensionControlledPref) {} |
| 1196 | 1201 |
| 1197 // Tests that the switches::kDisableExtensions command-line flag prevents | 1202 // Tests that the switches::kDisableExtensions command-line flag prevents |
| 1198 // extension controlled preferences from being enacted. | 1203 // extension controlled preferences from being enacted. |
| 1199 class ExtensionPrefsDisableExtensions : public ExtensionPrefsPrepopulatedTest { | 1204 class ExtensionPrefsDisableExtensions : public ExtensionPrefsPrepopulatedTest { |
| 1200 public: | 1205 public: |
| 1201 ExtensionPrefsDisableExtensions() | 1206 ExtensionPrefsDisableExtensions() |
| 1202 : iteration_(0) {} | 1207 : iteration_(0) {} |
| 1203 virtual ~ExtensionPrefsDisableExtensions() {} | 1208 virtual ~ExtensionPrefsDisableExtensions() {} |
| 1204 virtual void Initialize() { | 1209 virtual void Initialize() { |
| 1205 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); | 1210 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); |
| 1206 // This becomes only active in the second verification phase. | 1211 // This becomes only active in the second verification phase. |
| 1207 prefs_.set_extensions_disabled(true); | 1212 prefs_->set_extensions_disabled(true); |
| 1208 } | 1213 } |
| 1209 virtual void Verify() { | 1214 virtual void Verify() { |
| 1210 std::string actual = prefs()->pref_service()->GetString(kPref1); | 1215 std::string actual = prefs()->pref_service()->GetString(kPref1); |
| 1211 if (iteration_ == 0) { | 1216 if (iteration_ == 0) { |
| 1212 EXPECT_EQ("val1", actual); | 1217 EXPECT_EQ("val1", actual); |
| 1213 ++iteration_; | 1218 ++iteration_; |
| 1214 } else { | 1219 } else { |
| 1215 EXPECT_EQ(kDefaultPref1, actual); | 1220 EXPECT_EQ(kDefaultPref1, actual); |
| 1216 } | 1221 } |
| 1217 } | 1222 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1282 EXPECT_EQ(string16(), error16); | 1287 EXPECT_EQ(string16(), error16); |
| 1283 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); | 1288 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); |
| 1284 EXPECT_EQ(string16(), error16); | 1289 EXPECT_EQ(string16(), error16); |
| 1285 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); | 1290 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); |
| 1286 EXPECT_EQ(string16(), error16); | 1291 EXPECT_EQ(string16(), error16); |
| 1287 } | 1292 } |
| 1288 }; | 1293 }; |
| 1289 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} | 1294 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} |
| 1290 | 1295 |
| 1291 } // namespace extensions | 1296 } // namespace extensions |
| OLD | NEW |