OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_temp_dir.h" | 5 #include "base/memory/scoped_temp_dir.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); | 604 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); |
605 } | 605 } |
606 | 606 |
607 private: | 607 private: |
608 scoped_refptr<Extension> extension_; | 608 scoped_refptr<Extension> extension_; |
609 }; | 609 }; |
610 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} | 610 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} |
611 | 611 |
612 namespace keys = extension_manifest_keys; | 612 namespace keys = extension_manifest_keys; |
613 | 613 |
| 614 // Tests that we gracefully handle changes in the ID generation function for |
| 615 // unpacked extensions. |
| 616 class ExtensionPrefsIdChange : public ExtensionPrefsTest { |
| 617 public: |
| 618 virtual void Initialize() { |
| 619 DictionaryValue manifest; |
| 620 manifest.SetString(keys::kVersion, "1.0.0.0"); |
| 621 manifest.SetString(keys::kName, "unused"); |
| 622 |
| 623 extension_ = prefs_.AddExtensionWithManifest( |
| 624 manifest, Extension::LOAD); |
| 625 extension_id_ = extension_->id(); |
| 626 |
| 627 DictionaryValue* extensions_dict = |
| 628 prefs()->pref_service()->GetMutableDictionary( |
| 629 ExtensionPrefs::kExtensionsPref); |
| 630 |
| 631 Value* extension_prefs; |
| 632 EXPECT_TRUE(extensions_dict->RemoveWithoutPathExpansion( |
| 633 extension_id_, &extension_prefs)); |
| 634 extensions_dict->SetWithoutPathExpansion( |
| 635 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", extension_prefs); |
| 636 } |
| 637 |
| 638 virtual void Verify() { |
| 639 prefs_.RecreateExtensionPrefs(); |
| 640 prefs()->SetExtensionState(extension_.get(), Extension::DISABLED); |
| 641 ExtensionPrefs::ExtensionIdSet extension_ids; |
| 642 prefs()->GetExtensions(&extension_ids); |
| 643 EXPECT_EQ(1U, extension_ids.size()); |
| 644 EXPECT_EQ(extension_id_, extension_ids[0]); |
| 645 } |
| 646 |
| 647 private: |
| 648 scoped_refptr<Extension> extension_; |
| 649 std::string extension_id_; |
| 650 }; |
| 651 TEST_F(ExtensionPrefsIdChange, IdChange) {} |
| 652 |
614 class ExtensionPrefsPreferencesBase : public ExtensionPrefsTest { | 653 class ExtensionPrefsPreferencesBase : public ExtensionPrefsTest { |
615 public: | 654 public: |
616 ExtensionPrefsPreferencesBase() | 655 ExtensionPrefsPreferencesBase() |
617 : ExtensionPrefsTest(), | 656 : ExtensionPrefsTest(), |
618 ext1_(NULL), | 657 ext1_(NULL), |
619 ext2_(NULL), | 658 ext2_(NULL), |
620 ext3_(NULL), | 659 ext3_(NULL), |
621 installed() { | 660 installed() { |
622 DictionaryValue simple_dict; | 661 DictionaryValue simple_dict; |
623 std::string error; | 662 std::string error; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 testing::Mock::VerifyAndClearExpectations(v1i); | 951 testing::Mock::VerifyAndClearExpectations(v1i); |
913 testing::Mock::VerifyAndClearExpectations(v2); | 952 testing::Mock::VerifyAndClearExpectations(v2); |
914 testing::Mock::VerifyAndClearExpectations(v2i); | 953 testing::Mock::VerifyAndClearExpectations(v2i); |
915 } | 954 } |
916 | 955 |
917 virtual void Verify() { | 956 virtual void Verify() { |
918 } | 957 } |
919 }; | 958 }; |
920 TEST_F(ExtensionPrefsSetExtensionControlledPref, | 959 TEST_F(ExtensionPrefsSetExtensionControlledPref, |
921 ExtensionPrefsSetExtensionControlledPref) {} | 960 ExtensionPrefsSetExtensionControlledPref) {} |
OLD | NEW |