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/installer/setup/install_worker.h" | 5 #include "chrome/installer/setup/install_worker.h" |
6 | 6 |
7 #include "base/win/registry.h" | 7 #include "base/win/registry.h" |
8 #include "base/version.h" | 8 #include "base/version.h" |
9 #include "chrome/common/chrome_constants.h" | 9 #include "chrome/common/chrome_constants.h" |
10 #include "chrome/installer/setup/setup_util.h" | 10 #include "chrome/installer/setup/setup_util.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 StrictMock<MockWorkItemList> work_item_list_; | 707 StrictMock<MockWorkItemList> work_item_list_; |
708 }; | 708 }; |
709 | 709 |
710 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] = | 710 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] = |
711 L"Software\\Google\\Update\\Clients\\" | 711 L"Software\\Google\\Update\\Clients\\" |
712 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; | 712 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; |
713 | 713 |
714 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) { | 714 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) { |
715 // Install single Chrome on a clean system. | 715 // Install single Chrome on a clean system. |
716 scoped_ptr<MockInstallerState> installer_state( | 716 scoped_ptr<MockInstallerState> installer_state( |
717 BuildChromeInstallerState(system_level_, false, *machine_state_, | |
718 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | |
719 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
720 *machine_state_, | |
721 setup_path_, | |
722 *new_version_.get(), | |
723 &work_item_list_); | |
724 } | |
725 | |
726 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChromeFrame) { | |
727 // Install single Chrome Frame on a clean system. | |
728 scoped_ptr<MockInstallerState> installer_state( | |
729 BuildChromeFrameInstallerState(system_level_, false, *machine_state_, | |
730 InstallerState::SINGLE_INSTALL_OR_UPDATE)); | |
731 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
732 *machine_state_, | |
733 setup_path_, | |
734 *new_version_.get(), | |
735 &work_item_list_); | |
736 } | |
737 | |
738 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeFrame) { | |
739 // Install multi Chrome Frame on a clean system. | |
740 scoped_ptr<MockInstallerState> installer_state( | |
741 BuildChromeFrameInstallerState(system_level_, true, *machine_state_, | |
742 InstallerState::MULTI_INSTALL)); | |
743 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
744 *machine_state_, | |
745 setup_path_, | |
746 *new_version_.get(), | |
747 &work_item_list_); | |
748 } | |
749 | |
750 TEST_F(QuickEnableAbsentTest, CleanInstallMultiChromeChromeFrame) { | |
751 // Install multi Chrome and Chrome Frame on a clean system. | |
752 scoped_ptr<MockInstallerState> installer_state( | |
753 BuildBasicInstallerState(system_level_, true, *machine_state_, | 717 BuildBasicInstallerState(system_level_, true, *machine_state_, |
754 InstallerState::MULTI_INSTALL)); | 718 InstallerState::MULTI_UPDATE)); |
755 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | 719 AddQuickEnableChromeFrameWorkItems(*installer_state, &work_item_list_); |
756 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
757 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); | |
758 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
759 *machine_state_, | |
760 setup_path_, | |
761 *new_version_.get(), | |
762 &work_item_list_); | |
763 } | |
764 | |
765 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveMultiChromeFrame) { | |
766 // Uninstall multi Chrome on a machine with multi Chrome Frame. | |
767 AddChromeToInstallationState(system_level_, true, machine_state_.get()); | |
768 AddChromeFrameToInstallationState(system_level_, true, machine_state_.get()); | |
769 scoped_ptr<MockInstallerState> installer_state( | |
770 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
771 InstallerState::UNINSTALL)); | |
772 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
773 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
774 *machine_state_, | |
775 setup_path_, | |
776 *new_version_.get(), | |
777 &work_item_list_); | |
778 } | |
779 | |
780 TEST_F(QuickEnableAbsentTest, UninstallMultiChromeLeaveSingleChromeFrame) { | |
781 // Uninstall multi Chrome on a machine with single Chrome Frame. | |
782 AddChromeToInstallationState(system_level_, true, machine_state_.get()); | |
783 AddChromeFrameToInstallationState(system_level_, false, machine_state_.get()); | |
784 scoped_ptr<MockInstallerState> installer_state( | |
785 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
786 InstallerState::UNINSTALL)); | |
787 AddChromeToInstallerState(*machine_state_, installer_state.get()); | |
788 AddChromeBinariesToInstallerState(*machine_state_, installer_state.get()); | |
789 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
790 *machine_state_, | |
791 setup_path_, | |
792 *new_version_.get(), | |
793 &work_item_list_); | |
794 } | |
795 | |
796 // Test scenarios under which the quick-enable-cf command should exist after the | |
797 // run. | |
798 class QuickEnablePresentTest : public InstallWorkerTest { | |
799 public: | |
800 virtual void SetUp() { | |
801 InstallWorkerTest::SetUp(); | |
802 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
803 create_reg_key_work_item_.reset( | |
804 WorkItem::CreateCreateRegKeyWorkItem(root_key_, kRegKeyPath)); | |
805 set_reg_value_work_item_.reset( | |
806 WorkItem::CreateSetRegValueWorkItem(root_key_, kRegKeyPath, L"", L"", | |
807 false)); | |
808 machine_state_.reset(new MockInstallationState()); | |
809 EXPECT_CALL(work_item_list_, | |
810 AddCreateRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) | |
811 .Times(1) | |
812 .WillOnce(Return(create_reg_key_work_item_.get())); | |
813 EXPECT_CALL(work_item_list_, | |
814 AddSetRegStringValueWorkItem(Eq(root_key_), | |
815 StrCaseEq(kRegKeyPath), | |
816 StrEq(L"CommandLine"), _, | |
817 Eq(true))) | |
818 .Times(1) | |
819 .WillOnce(Return(set_reg_value_work_item_.get())); | |
820 EXPECT_CALL(work_item_list_, | |
821 AddSetRegDwordValueWorkItem(Eq(root_key_), | |
822 StrCaseEq(kRegKeyPath), _, | |
823 Eq(static_cast<DWORD>(1)), | |
824 Eq(true))) | |
825 .Times(2) | |
826 .WillRepeatedly(Return(set_reg_value_work_item_.get())); | |
827 } | |
828 virtual void TearDown() { | |
829 machine_state_.reset(); | |
830 set_reg_value_work_item_.reset(); | |
831 create_reg_key_work_item_.reset(); | |
832 root_key_ = NULL; | |
833 InstallWorkerTest::TearDown(); | |
834 } | |
835 protected: | |
836 static const bool system_level_ = false; | |
837 static const wchar_t kRegKeyPath[]; | |
838 HKEY root_key_; | |
839 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item_; | |
840 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item_; | |
841 scoped_ptr<MockInstallationState> machine_state_; | |
842 StrictMock<MockWorkItemList> work_item_list_; | |
843 }; | |
844 | |
845 const wchar_t QuickEnablePresentTest::kRegKeyPath[] = | |
846 L"Software\\Google\\Update\\Clients\\" | |
847 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; | |
848 | |
849 TEST_F(QuickEnablePresentTest, CleanInstallMultiChrome) { | |
850 // Install multi Chrome on a clean system. | |
851 scoped_ptr<MockInstallerState> installer_state( | |
852 BuildChromeInstallerState(system_level_, true, *machine_state_, | |
853 InstallerState::MULTI_INSTALL)); | |
854 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
855 *machine_state_, | |
856 setup_path_, | |
857 *new_version_.get(), | |
858 &work_item_list_); | |
859 } | |
860 | |
861 TEST_F(QuickEnablePresentTest, UninstallSingleChromeFrame) { | |
862 // Uninstall single Chrome Frame on a machine with multi Chrome. | |
863 AddChromeToInstallationState(system_level_, true, machine_state_.get()); | |
864 AddChromeFrameToInstallationState(system_level_, false, machine_state_.get()); | |
865 scoped_ptr<MockInstallerState> installer_state( | |
866 BuildBasicInstallerState(system_level_, false, *machine_state_, | |
867 InstallerState::UNINSTALL)); | |
868 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); | |
869 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
870 *machine_state_, | |
871 setup_path_, | |
872 *new_version_.get(), | |
873 &work_item_list_); | |
874 } | |
875 | |
876 TEST_F(QuickEnablePresentTest, UninstallMultiChromeFrame) { | |
877 // Uninstall multi Chrome Frame on a machine with multi Chrome. | |
878 AddChromeToInstallationState(system_level_, true, machine_state_.get()); | |
879 AddChromeFrameToInstallationState(system_level_, true, machine_state_.get()); | |
880 scoped_ptr<MockInstallerState> installer_state( | |
881 BuildBasicInstallerState(system_level_, true, *machine_state_, | |
882 InstallerState::UNINSTALL)); | |
883 AddChromeFrameToInstallerState(*machine_state_, installer_state.get()); | |
884 AddQuickEnableChromeFrameWorkItems(*installer_state, | |
885 *machine_state_, | |
886 setup_path_, | |
887 *new_version_.get(), | |
888 &work_item_list_); | |
889 } | 720 } |
890 | 721 |
891 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) { | 722 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) { |
892 BrowserDistribution::Type prod_type_list[] = { | 723 BrowserDistribution::Type prod_type_list[] = { |
893 BrowserDistribution::CHROME_BROWSER, | 724 BrowserDistribution::CHROME_BROWSER, |
894 BrowserDistribution::CHROME_FRAME, | 725 BrowserDistribution::CHROME_FRAME, |
895 // Excluding BrowserDistribution::CHROME_BINARIES, since it is installed | 726 // Excluding BrowserDistribution::CHROME_BINARIES, since it is installed |
896 // along with other products. | 727 // along with other products. |
897 }; | 728 }; |
898 enum { // Index into prod_type_list[]. | 729 enum { // Index into prod_type_list[]. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 prod_type_list[i_type_check]); | 798 prod_type_list[i_type_check]); |
968 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; | 799 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; |
969 EXPECT_EQ(prod_expect, prod_res); | 800 EXPECT_EQ(prod_expect, prod_res); |
970 } | 801 } |
971 } | 802 } |
972 } | 803 } |
973 } | 804 } |
974 } | 805 } |
975 | 806 |
976 #endif // defined(GOOGLE_CHROME_BUILD) | 807 #endif // defined(GOOGLE_CHROME_BUILD) |
OLD | NEW |