| 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 base::FilePath path = | 478 base::FilePath path = |
| 479 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); | 479 prefs_.extensions_dir().AppendASCII(base::IntToString(num)); |
| 480 std::string errors; | 480 std::string errors; |
| 481 scoped_refptr<Extension> extension = Extension::Create( | 481 scoped_refptr<Extension> extension = Extension::Create( |
| 482 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); | 482 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id, &errors); |
| 483 ASSERT_TRUE(extension.get()) << errors; | 483 ASSERT_TRUE(extension.get()) << errors; |
| 484 ASSERT_EQ(id, extension->id()); | 484 ASSERT_EQ(id, extension->id()); |
| 485 prefs()->SetDelayedInstallInfo(extension.get(), | 485 prefs()->SetDelayedInstallInfo(extension.get(), |
| 486 Extension::ENABLED, | 486 Extension::ENABLED, |
| 487 false, | 487 false, |
| 488 false, |
| 488 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 489 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 489 syncer::StringOrdinal(), | 490 syncer::StringOrdinal(), |
| 490 std::string()); | 491 std::string()); |
| 491 } | 492 } |
| 492 | 493 |
| 493 // Verifies that we get back expected idle install information previously | 494 // Verifies that we get back expected idle install information previously |
| 494 // set by SetIdleInfo. | 495 // set by SetIdleInfo. |
| 495 void VerifyIdleInfo(const std::string& id, int num) { | 496 void VerifyIdleInfo(const std::string& id, int num) { |
| 496 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); | 497 scoped_ptr<ExtensionInfo> info(prefs()->GetDelayedInstallInfo(id)); |
| 497 ASSERT_TRUE(info); | 498 ASSERT_TRUE(info); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 base::FilePath path = | 604 base::FilePath path = |
| 604 prefs_.extensions_dir().AppendASCII("test_0.2"); | 605 prefs_.extensions_dir().AppendASCII("test_0.2"); |
| 605 std::string errors; | 606 std::string errors; |
| 606 scoped_refptr<Extension> new_extension = Extension::Create( | 607 scoped_refptr<Extension> new_extension = Extension::Create( |
| 607 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id_, &errors); | 608 path, Manifest::INTERNAL, manifest, Extension::NO_FLAGS, id_, &errors); |
| 608 ASSERT_TRUE(new_extension.get()) << errors; | 609 ASSERT_TRUE(new_extension.get()) << errors; |
| 609 ASSERT_EQ(id_, new_extension->id()); | 610 ASSERT_EQ(id_, new_extension->id()); |
| 610 prefs()->SetDelayedInstallInfo(new_extension.get(), | 611 prefs()->SetDelayedInstallInfo(new_extension.get(), |
| 611 Extension::ENABLED, | 612 Extension::ENABLED, |
| 612 false, | 613 false, |
| 614 false, |
| 613 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, | 615 ExtensionPrefs::DELAY_REASON_WAIT_FOR_IDLE, |
| 614 syncer::StringOrdinal(), | 616 syncer::StringOrdinal(), |
| 615 "Param"); | 617 "Param"); |
| 616 | 618 |
| 617 // Finish idle installation | 619 // Finish idle installation |
| 618 ASSERT_TRUE(prefs()->FinishDelayedInstallInfo(id_)); | 620 ASSERT_TRUE(prefs()->FinishDelayedInstallInfo(id_)); |
| 619 } | 621 } |
| 620 | 622 |
| 621 virtual void Verify() OVERRIDE { | 623 virtual void Verify() OVERRIDE { |
| 622 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id_)); | 624 EXPECT_FALSE(prefs()->GetDelayedInstallInfo(id_)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 642 TEST_F(ExtensionPrefsFinishDelayedInstallInfo, FinishDelayedInstallInfo) {} | 644 TEST_F(ExtensionPrefsFinishDelayedInstallInfo, FinishDelayedInstallInfo) {} |
| 643 | 645 |
| 644 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { | 646 class ExtensionPrefsOnExtensionInstalled : public ExtensionPrefsTest { |
| 645 public: | 647 public: |
| 646 virtual void Initialize() OVERRIDE { | 648 virtual void Initialize() OVERRIDE { |
| 647 extension_ = prefs_.AddExtension("on_extension_installed"); | 649 extension_ = prefs_.AddExtension("on_extension_installed"); |
| 648 EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id())); | 650 EXPECT_FALSE(prefs()->IsExtensionDisabled(extension_->id())); |
| 649 prefs()->OnExtensionInstalled(extension_.get(), | 651 prefs()->OnExtensionInstalled(extension_.get(), |
| 650 Extension::DISABLED, | 652 Extension::DISABLED, |
| 651 false, | 653 false, |
| 654 false, |
| 652 syncer::StringOrdinal(), | 655 syncer::StringOrdinal(), |
| 653 "Param"); | 656 "Param"); |
| 654 } | 657 } |
| 655 | 658 |
| 656 virtual void Verify() OVERRIDE { | 659 virtual void Verify() OVERRIDE { |
| 657 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension_->id())); | 660 EXPECT_TRUE(prefs()->IsExtensionDisabled(extension_->id())); |
| 658 EXPECT_EQ(std::string("Param"), prefs()->GetInstallParam(extension_->id())); | 661 EXPECT_EQ(std::string("Param"), prefs()->GetInstallParam(extension_->id())); |
| 659 } | 662 } |
| 660 | 663 |
| 661 private: | 664 private: |
| 662 scoped_refptr<Extension> extension_; | 665 scoped_refptr<Extension> extension_; |
| 663 }; | 666 }; |
| 664 TEST_F(ExtensionPrefsOnExtensionInstalled, | 667 TEST_F(ExtensionPrefsOnExtensionInstalled, |
| 665 ExtensionPrefsOnExtensionInstalled) {} | 668 ExtensionPrefsOnExtensionInstalled) {} |
| 666 | 669 |
| 667 class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest { | 670 class ExtensionPrefsAppDraggedByUser : public ExtensionPrefsTest { |
| 668 public: | 671 public: |
| 669 virtual void Initialize() OVERRIDE { | 672 virtual void Initialize() OVERRIDE { |
| 670 extension_ = prefs_.AddExtension("on_extension_installed"); | 673 extension_ = prefs_.AddExtension("on_extension_installed"); |
| 671 EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id())); | 674 EXPECT_FALSE(prefs()->WasAppDraggedByUser(extension_->id())); |
| 672 prefs()->OnExtensionInstalled(extension_.get(), | 675 prefs()->OnExtensionInstalled(extension_.get(), |
| 673 Extension::ENABLED, | 676 Extension::ENABLED, |
| 674 false, | 677 false, |
| 678 false, |
| 675 syncer::StringOrdinal(), | 679 syncer::StringOrdinal(), |
| 676 std::string()); | 680 std::string()); |
| 677 } | 681 } |
| 678 | 682 |
| 679 virtual void Verify() OVERRIDE { | 683 virtual void Verify() OVERRIDE { |
| 680 // Set the flag and see if it persisted. | 684 // Set the flag and see if it persisted. |
| 681 prefs()->SetAppDraggedByUser(extension_->id()); | 685 prefs()->SetAppDraggedByUser(extension_->id()); |
| 682 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); | 686 EXPECT_TRUE(prefs()->WasAppDraggedByUser(extension_->id())); |
| 683 | 687 |
| 684 // Make sure it doesn't change on consecutive calls. | 688 // Make sure it doesn't change on consecutive calls. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 EXPECT_FALSE(prefs()->IsExtensionBlacklisted(extension_a_->id())); | 909 EXPECT_FALSE(prefs()->IsExtensionBlacklisted(extension_a_->id())); |
| 906 EXPECT_EQ(empty_ids, prefs()->GetBlacklistedExtensions()); | 910 EXPECT_EQ(empty_ids, prefs()->GetBlacklistedExtensions()); |
| 907 } | 911 } |
| 908 | 912 |
| 909 private: | 913 private: |
| 910 scoped_refptr<const Extension> extension_a_; | 914 scoped_refptr<const Extension> extension_a_; |
| 911 }; | 915 }; |
| 912 TEST_F(ExtensionPrefsBlacklistState, ExtensionPrefsBlacklistState) {} | 916 TEST_F(ExtensionPrefsBlacklistState, ExtensionPrefsBlacklistState) {} |
| 913 | 917 |
| 914 } // namespace extensions | 918 } // namespace extensions |
| OLD | NEW |