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 "chrome/browser/extensions/extension_prefs_unittest.h" | 5 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/prefs/mock_pref_change_callback.h" | 10 #include "base/prefs/mock_pref_change_callback.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 prefs_(message_loop_.message_loop_proxy()) { | 58 prefs_(message_loop_.message_loop_proxy()) { |
59 } | 59 } |
60 | 60 |
61 ExtensionPrefsTest::~ExtensionPrefsTest() { | 61 ExtensionPrefsTest::~ExtensionPrefsTest() { |
62 } | 62 } |
63 | 63 |
64 void ExtensionPrefsTest::RegisterPreferences( | 64 void ExtensionPrefsTest::RegisterPreferences( |
65 user_prefs::PrefRegistrySyncable* registry) {} | 65 user_prefs::PrefRegistrySyncable* registry) {} |
66 | 66 |
67 void ExtensionPrefsTest::SetUp() { | 67 void ExtensionPrefsTest::SetUp() { |
68 RegisterPreferences(prefs_.pref_registry()); | 68 RegisterPreferences(prefs_.pref_registry().get()); |
69 Initialize(); | 69 Initialize(); |
70 } | 70 } |
71 | 71 |
72 void ExtensionPrefsTest::TearDown() { | 72 void ExtensionPrefsTest::TearDown() { |
73 Verify(); | 73 Verify(); |
74 | 74 |
75 // Reset ExtensionPrefs, and re-verify. | 75 // Reset ExtensionPrefs, and re-verify. |
76 prefs_.ResetPrefRegistry(); | 76 prefs_.ResetPrefRegistry(); |
77 RegisterPreferences(prefs_.pref_registry()); | 77 RegisterPreferences(prefs_.pref_registry().get()); |
78 prefs_.RecreateExtensionPrefs(); | 78 prefs_.RecreateExtensionPrefs(); |
79 Verify(); | 79 Verify(); |
80 prefs_.pref_service()->CommitPendingWrite(); | 80 prefs_.pref_service()->CommitPendingWrite(); |
81 message_loop_.RunUntilIdle(); | 81 message_loop_.RunUntilIdle(); |
82 } | 82 } |
83 | 83 |
84 // Tests the LastPingDay/SetLastPingDay functions. | 84 // Tests the LastPingDay/SetLastPingDay functions. |
85 class ExtensionPrefsLastPingDay : public ExtensionPrefsTest { | 85 class ExtensionPrefsLastPingDay : public ExtensionPrefsTest { |
86 public: | 86 public: |
87 ExtensionPrefsLastPingDay() | 87 ExtensionPrefsLastPingDay() |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 scoped_refptr<PermissionSet> active( | 347 scoped_refptr<PermissionSet> active( |
348 prefs()->GetActivePermissions(extension_id_)); | 348 prefs()->GetActivePermissions(extension_id_)); |
349 EXPECT_TRUE(active->IsEmpty()); | 349 EXPECT_TRUE(active->IsEmpty()); |
350 | 350 |
351 // Set the active permissions. | 351 // Set the active permissions. |
352 prefs()->SetActivePermissions(extension_id_, active_perms_.get()); | 352 prefs()->SetActivePermissions(extension_id_, active_perms_.get()); |
353 active = prefs()->GetActivePermissions(extension_id_); | 353 active = prefs()->GetActivePermissions(extension_id_); |
354 EXPECT_EQ(active_perms_->apis(), active->apis()); | 354 EXPECT_EQ(active_perms_->apis(), active->apis()); |
355 EXPECT_EQ(active_perms_->explicit_hosts(), active->explicit_hosts()); | 355 EXPECT_EQ(active_perms_->explicit_hosts(), active->explicit_hosts()); |
356 EXPECT_EQ(active_perms_->scriptable_hosts(), active->scriptable_hosts()); | 356 EXPECT_EQ(active_perms_->scriptable_hosts(), active->scriptable_hosts()); |
357 EXPECT_EQ(*active_perms_, *active); | 357 EXPECT_EQ(*active_perms_.get(), *active.get()); |
358 } | 358 } |
359 | 359 |
360 virtual void Verify() OVERRIDE { | 360 virtual void Verify() OVERRIDE { |
361 scoped_refptr<PermissionSet> permissions( | 361 scoped_refptr<PermissionSet> permissions( |
362 prefs()->GetActivePermissions(extension_id_)); | 362 prefs()->GetActivePermissions(extension_id_)); |
363 EXPECT_EQ(*active_perms_, *permissions); | 363 EXPECT_EQ(*active_perms_.get(), *permissions.get()); |
364 } | 364 } |
365 | 365 |
366 private: | 366 private: |
367 std::string extension_id_; | 367 std::string extension_id_; |
368 scoped_refptr<PermissionSet> active_perms_; | 368 scoped_refptr<PermissionSet> active_perms_; |
369 }; | 369 }; |
370 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} | 370 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} |
371 | 371 |
372 // Tests the GetVersionString function. | 372 // Tests the GetVersionString function. |
373 class ExtensionPrefsVersionString : public ExtensionPrefsTest { | 373 class ExtensionPrefsVersionString : public ExtensionPrefsTest { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 void SetIdleInfo(std::string id, int num) { | 458 void SetIdleInfo(std::string id, int num) { |
459 DictionaryValue manifest; | 459 DictionaryValue manifest; |
460 manifest.SetString(extension_manifest_keys::kName, "test"); | 460 manifest.SetString(extension_manifest_keys::kName, "test"); |
461 manifest.SetString(extension_manifest_keys::kVersion, | 461 manifest.SetString(extension_manifest_keys::kVersion, |
462 "1." + base::IntToString(num)); | 462 "1." + base::IntToString(num)); |
463 base::FilePath path = | 463 base::FilePath path = |
464 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); | 464 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); |
465 std::string errors; | 465 std::string errors; |
466 scoped_refptr<Extension> extension = Extension::Create( | 466 scoped_refptr<Extension> extension = Extension::Create( |
467 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); | 467 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); |
468 ASSERT_TRUE(extension) << errors; | 468 ASSERT_TRUE(extension.get()) << errors; |
469 ASSERT_EQ(id, extension->id()); | 469 ASSERT_EQ(id, extension->id()); |
470 prefs()->SetDelayedInstallInfo(extension.get(), Extension::ENABLED, | 470 prefs()->SetDelayedInstallInfo(extension.get(), Extension::ENABLED, |
471 syncer::StringOrdinal()); | 471 syncer::StringOrdinal()); |
472 } | 472 } |
473 | 473 |
474 // Verifies that we get back expected idle install information previously | 474 // Verifies that we get back expected idle install information previously |
475 // set by SetIdleInfo. | 475 // set by SetIdleInfo. |
476 void VerifyIdleInfo(std::string id, int num) { | 476 void VerifyIdleInfo(std::string id, int num) { |
477 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); | 477 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); |
478 ASSERT_TRUE(info); | 478 ASSERT_TRUE(info); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1118 |
1119 private: | 1119 private: |
1120 scoped_refptr<const Extension> extension_a_; | 1120 scoped_refptr<const Extension> extension_a_; |
1121 scoped_refptr<const Extension> extension_b_; | 1121 scoped_refptr<const Extension> extension_b_; |
1122 scoped_refptr<const Extension> extension_c_; | 1122 scoped_refptr<const Extension> extension_c_; |
1123 }; | 1123 }; |
1124 TEST_F(ExtensionPrefsBlacklistedExtensions, | 1124 TEST_F(ExtensionPrefsBlacklistedExtensions, |
1125 ExtensionPrefsBlacklistedExtensions) {} | 1125 ExtensionPrefsBlacklistedExtensions) {} |
1126 | 1126 |
1127 } // namespace extensions | 1127 } // namespace extensions |
OLD | NEW |