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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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/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/public/pref_change_registrar.h" 10 #include "base/prefs/public/pref_change_registrar.h"
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 }; 461 };
462 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} 462 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {}
463 463
464 // Tests the GetVersionString function. 464 // Tests the GetVersionString function.
465 class ExtensionPrefsVersionString : public ExtensionPrefsTest { 465 class ExtensionPrefsVersionString : public ExtensionPrefsTest {
466 public: 466 public:
467 virtual void Initialize() { 467 virtual void Initialize() {
468 extension = prefs_.AddExtension("test"); 468 extension = prefs_.AddExtension("test");
469 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id())); 469 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id()));
470 prefs()->OnExtensionUninstalled(extension->id(), 470 prefs()->OnExtensionUninstalled(extension->id(),
471 Extension::INTERNAL, false); 471 Manifest::INTERNAL, false);
472 } 472 }
473 473
474 virtual void Verify() { 474 virtual void Verify() {
475 EXPECT_EQ("", prefs()->GetVersionString(extension->id())); 475 EXPECT_EQ("", prefs()->GetVersionString(extension->id()));
476 } 476 }
477 477
478 private: 478 private:
479 scoped_refptr<Extension> extension; 479 scoped_refptr<Extension> extension;
480 }; 480 };
481 TEST_F(ExtensionPrefsVersionString, VersionString) {} 481 TEST_F(ExtensionPrefsVersionString, VersionString) {}
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 public: 584 public:
585 // Sets idle install information for one test extension. 585 // Sets idle install information for one test extension.
586 void SetIdleInfo(std::string id, int num) { 586 void SetIdleInfo(std::string id, int num) {
587 DictionaryValue manifest; 587 DictionaryValue manifest;
588 manifest.SetString(extension_manifest_keys::kName, "test"); 588 manifest.SetString(extension_manifest_keys::kName, "test");
589 manifest.SetString(extension_manifest_keys::kVersion, 589 manifest.SetString(extension_manifest_keys::kVersion,
590 "1." + base::IntToString(num)); 590 "1." + base::IntToString(num));
591 FilePath path = prefs_.extensions_dir().AppendASCII(base::IntToString(num)); 591 FilePath path = prefs_.extensions_dir().AppendASCII(base::IntToString(num));
592 std::string errors; 592 std::string errors;
593 scoped_refptr<Extension> extension = Extension::Create( 593 scoped_refptr<Extension> extension = Extension::Create(
594 path, Extension::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); 594 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors);
595 ASSERT_TRUE(extension) << errors; 595 ASSERT_TRUE(extension) << errors;
596 ASSERT_EQ(id, extension->id()); 596 ASSERT_EQ(id, extension->id());
597 prefs()->SetDelayedInstallInfo(extension.get(), Extension::ENABLED, 597 prefs()->SetDelayedInstallInfo(extension.get(), Extension::ENABLED,
598 syncer::StringOrdinal()); 598 syncer::StringOrdinal());
599 } 599 }
600 600
601 // Verifies that we get back expected idle install information previously 601 // Verifies that we get back expected idle install information previously
602 // set by SetIdleInfo. 602 // set by SetIdleInfo.
603 void VerifyIdleInfo(std::string id, int num) { 603 void VerifyIdleInfo(std::string id, int num) {
604 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); 604 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {} 733 TEST_F(ExtensionPrefsAppDraggedByUser, ExtensionPrefsAppDraggedByUser) {}
734 734
735 class ExtensionPrefsFlags : public ExtensionPrefsTest { 735 class ExtensionPrefsFlags : public ExtensionPrefsTest {
736 public: 736 public:
737 virtual void Initialize() { 737 virtual void Initialize() {
738 { 738 {
739 base::DictionaryValue dictionary; 739 base::DictionaryValue dictionary;
740 dictionary.SetString(extension_manifest_keys::kName, "from_webstore"); 740 dictionary.SetString(extension_manifest_keys::kName, "from_webstore");
741 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 741 dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
742 webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags( 742 webstore_extension_ = prefs_.AddExtensionWithManifestAndFlags(
743 dictionary, Extension::INTERNAL, Extension::FROM_WEBSTORE); 743 dictionary, Manifest::INTERNAL, Extension::FROM_WEBSTORE);
744 } 744 }
745 745
746 { 746 {
747 base::DictionaryValue dictionary; 747 base::DictionaryValue dictionary;
748 dictionary.SetString(extension_manifest_keys::kName, "from_bookmark"); 748 dictionary.SetString(extension_manifest_keys::kName, "from_bookmark");
749 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 749 dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
750 bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags( 750 bookmark_extension_ = prefs_.AddExtensionWithManifestAndFlags(
751 dictionary, Extension::INTERNAL, Extension::FROM_BOOKMARK); 751 dictionary, Manifest::INTERNAL, Extension::FROM_BOOKMARK);
752 } 752 }
753 753
754 { 754 {
755 base::DictionaryValue dictionary; 755 base::DictionaryValue dictionary;
756 dictionary.SetString(extension_manifest_keys::kName, 756 dictionary.SetString(extension_manifest_keys::kName,
757 "was_installed_by_default"); 757 "was_installed_by_default");
758 dictionary.SetString(extension_manifest_keys::kVersion, "0.1"); 758 dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
759 default_extension_ = prefs_.AddExtensionWithManifestAndFlags( 759 default_extension_ = prefs_.AddExtensionWithManifestAndFlags(
760 dictionary, 760 dictionary,
761 Extension::INTERNAL, 761 Manifest::INTERNAL,
762 Extension::WAS_INSTALLED_BY_DEFAULT); 762 Extension::WAS_INSTALLED_BY_DEFAULT);
763 } 763 }
764 } 764 }
765 765
766 virtual void Verify() { 766 virtual void Verify() {
767 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id())); 767 EXPECT_TRUE(prefs()->IsFromWebStore(webstore_extension_->id()));
768 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id())); 768 EXPECT_FALSE(prefs()->IsFromBookmark(webstore_extension_->id()));
769 769
770 EXPECT_TRUE(prefs()->IsFromBookmark(bookmark_extension_->id())); 770 EXPECT_TRUE(prefs()->IsFromBookmark(bookmark_extension_->id()));
771 EXPECT_FALSE(prefs()->IsFromWebStore(bookmark_extension_->id())); 771 EXPECT_FALSE(prefs()->IsFromWebStore(bookmark_extension_->id()));
(...skipping 17 matching lines...) Expand all
789 ext3_(NULL), 789 ext3_(NULL),
790 ext4_(NULL), 790 ext4_(NULL),
791 installed() { 791 installed() {
792 DictionaryValue simple_dict; 792 DictionaryValue simple_dict;
793 std::string error; 793 std::string error;
794 794
795 simple_dict.SetString(keys::kVersion, "1.0.0.0"); 795 simple_dict.SetString(keys::kVersion, "1.0.0.0");
796 simple_dict.SetString(keys::kName, "unused"); 796 simple_dict.SetString(keys::kName, "unused");
797 797
798 ext1_scoped_ = Extension::Create( 798 ext1_scoped_ = Extension::Create(
799 prefs_.temp_dir().AppendASCII("ext1_"), Extension::EXTERNAL_PREF, 799 prefs_.temp_dir().AppendASCII("ext1_"), Manifest::EXTERNAL_PREF,
800 simple_dict, Extension::NO_FLAGS, &error); 800 simple_dict, Extension::NO_FLAGS, &error);
801 ext2_scoped_ = Extension::Create( 801 ext2_scoped_ = Extension::Create(
802 prefs_.temp_dir().AppendASCII("ext2_"), Extension::EXTERNAL_PREF, 802 prefs_.temp_dir().AppendASCII("ext2_"), Manifest::EXTERNAL_PREF,
803 simple_dict, Extension::NO_FLAGS, &error); 803 simple_dict, Extension::NO_FLAGS, &error);
804 ext3_scoped_ = Extension::Create( 804 ext3_scoped_ = Extension::Create(
805 prefs_.temp_dir().AppendASCII("ext3_"), Extension::EXTERNAL_PREF, 805 prefs_.temp_dir().AppendASCII("ext3_"), Manifest::EXTERNAL_PREF,
806 simple_dict, Extension::NO_FLAGS, &error); 806 simple_dict, Extension::NO_FLAGS, &error);
807 ext4_scoped_ = Extension::Create( 807 ext4_scoped_ = Extension::Create(
808 prefs_.temp_dir().AppendASCII("ext4_"), Extension::EXTERNAL_PREF, 808 prefs_.temp_dir().AppendASCII("ext4_"), Manifest::EXTERNAL_PREF,
809 simple_dict, Extension::NO_FLAGS, &error); 809 simple_dict, Extension::NO_FLAGS, &error);
810 810
811 ext1_ = ext1_scoped_.get(); 811 ext1_ = ext1_scoped_.get();
812 ext2_ = ext2_scoped_.get(); 812 ext2_ = ext2_scoped_.get();
813 ext3_ = ext3_scoped_.get(); 813 ext3_ = ext3_scoped_.get();
814 ext4_ = ext4_scoped_.get(); 814 ext4_ = ext4_scoped_.get();
815 815
816 for (size_t i = 0; i < arraysize(installed); ++i) 816 for (size_t i = 0; i < arraysize(installed); ++i)
817 installed[i] = false; 817 installed[i] = false;
818 } 818 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 881
882 void ExtensionPrefsPrepopulatedTest::EnsureExtensionUninstalled( 882 void ExtensionPrefsPrepopulatedTest::EnsureExtensionUninstalled(
883 const std::string& extension_id) { 883 const std::string& extension_id) {
884 Extension* extensions[] = {ext1_, ext2_, ext3_, ext4_}; 884 Extension* extensions[] = {ext1_, ext2_, ext3_, ext4_};
885 for (size_t i = 0; i < arraysize(extensions); ++i) { 885 for (size_t i = 0; i < arraysize(extensions); ++i) {
886 if (extensions[i]->id() == extension_id) { 886 if (extensions[i]->id() == extension_id) {
887 installed[i] = false; 887 installed[i] = false;
888 break; 888 break;
889 } 889 }
890 } 890 }
891 prefs()->OnExtensionUninstalled(extension_id, Extension::INTERNAL, false); 891 prefs()->OnExtensionUninstalled(extension_id, Manifest::INTERNAL, false);
892 } 892 }
893 893
894 class ExtensionPrefsInstallOneExtension 894 class ExtensionPrefsInstallOneExtension
895 : public ExtensionPrefsPrepopulatedTest { 895 : public ExtensionPrefsPrepopulatedTest {
896 virtual void Initialize() { 896 virtual void Initialize() {
897 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1")); 897 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1"));
898 } 898 }
899 virtual void Verify() { 899 virtual void Verify() {
900 std::string actual = prefs()->pref_service()->GetString(kPref1); 900 std::string actual = prefs()->pref_service()->GetString(kPref1);
901 EXPECT_EQ("val1", actual); 901 EXPECT_EQ("val1", actual);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1244
1245 private: 1245 private:
1246 scoped_refptr<const Extension> extension_a_; 1246 scoped_refptr<const Extension> extension_a_;
1247 scoped_refptr<const Extension> extension_b_; 1247 scoped_refptr<const Extension> extension_b_;
1248 scoped_refptr<const Extension> extension_c_; 1248 scoped_refptr<const Extension> extension_c_;
1249 }; 1249 };
1250 TEST_F(ExtensionPrefsBlacklistedExtensions, 1250 TEST_F(ExtensionPrefsBlacklistedExtensions,
1251 ExtensionPrefsBlacklistedExtensions) {} 1251 ExtensionPrefsBlacklistedExtensions) {}
1252 1252
1253 } // namespace extensions 1253 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_protocols_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698