diff options
author | hnguyen@google.com <hnguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-12 20:13:27 +0000 |
---|---|---|
committer | hnguyen@google.com <hnguyen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-12 20:13:27 +0000 |
commit | 762482bbeaffe68b93674ed5e75e1c9515400961 (patch) | |
tree | 1717b7e276ea5e74fa116cbfaba7819947780317 /chrome/test/mini_installer_test | |
parent | d01223094fcd20d162d5819977ac83719bd87443 (diff) | |
download | chromium_src-762482bbeaffe68b93674ed5e75e1c9515400961.zip chromium_src-762482bbeaffe68b93674ed5e75e1c9515400961.tar.gz chromium_src-762482bbeaffe68b93674ed5e75e1c9515400961.tar.bz2 |
A few things in this change:
1) Add CF install using multi-install test.
2) Add new test classes to reflect system/user and Chrome/CF tests.
3) Remove unused code in the util class.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8216020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105145 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/mini_installer_test')
6 files changed, 100 insertions, 166 deletions
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index 9274587..7004d5c 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -95,18 +95,16 @@ bool FindNewestMatchingFile(const FilePath& root, } // namespace ChromeMiniInstaller::ChromeMiniInstaller(bool system_install, - bool is_chrome_frame) + bool is_chrome_frame, + const std::string& build) : is_chrome_frame_(is_chrome_frame), - system_install_(system_install) {} - -void ChromeMiniInstaller::SetBuildUnderTest(const std::string& build) { - build_ = build; + system_install_(system_install), + build_(build) { FilePath full_installer; FilePath previous_installer; if (!GetFullInstaller(&full_installer) || !GetPreviousInstaller(&previous_installer)) return; - current_build_ = full_installer.DirName().DirName().BaseName().MaybeAsASCII(); previous_build_ = @@ -139,14 +137,17 @@ void ChromeMiniInstaller::OverInstallOnFullInstaller( std::string got_prev_version; ASSERT_TRUE(GetChromeVersionFromRegistry(&got_prev_version)); + std::string expected_version; if (install_type == mini_installer_constants::kDiffInstall) { LOG(INFO) << "Over installing with latest differential installer: " << diff_installer.value(); + expected_version = current_diff_build_; InstallMiniInstaller(true, diff_installer); } else if (install_type == mini_installer_constants::kFullInstall) { LOG(INFO) << "Over installing with latest full installer: " << full_installer.value(); + expected_version = current_build_; InstallMiniInstaller(true, full_installer); } @@ -154,16 +155,16 @@ void ChromeMiniInstaller::OverInstallOnFullInstaller( ASSERT_TRUE(GetChromeVersionFromRegistry(&got_curr_version)); if (got_prev_version == previous_build_ && - got_curr_version == current_build_) { + got_curr_version == expected_version) { LOG(INFO) << "The over install was successful.\n" - << "Full installer: " << previous_build_; - LOG(INFO) << "Diff installer: " << current_build_; + << "Previously installed version: " << got_prev_version; + LOG(INFO) << "Currently installed: " << expected_version; } else { LOG(INFO) << "The over install was not successful.\n" - << "Expected full installer value: " << previous_build_; - LOG(INFO) << "Actual value is: " << got_prev_version; - LOG(INFO) << "Expected diff: " << current_build_ - << "Actual value is: " << got_curr_version; + << "Expected previous version: " << previous_build_; + LOG(INFO) << "Actual previous version: " << got_prev_version; + LOG(INFO) << "Expected new version: " << expected_version + << "\nActual new version: " << got_curr_version; FAIL(); } } @@ -202,16 +203,32 @@ void ChromeMiniInstaller::InstallUsingMultiInstall() { installer::ExpectValidInstallation(system_install_); BrowserDistribution* dist = GetCurrentBrowserDistribution(); ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); - if (is_chrome_frame_) { - EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); - VerifyChromeFrameInstall(); - } else { - EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); - } + EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI); FindChromeShortcut(); LaunchChrome(false); } +void ChromeMiniInstaller::InstallChromeFrameUsingMultiInstall() { + FilePath mini_installer; + ASSERT_TRUE(GetMiniInstaller(&mini_installer)); + CommandLine cmd(mini_installer); + cmd.AppendSwitch(installer::switches::kMultiInstall); + cmd.AppendSwitch(installer::switches::kChromeFrame); + RunInstaller(cmd); + + // Verify installation. + InstallationValidator::InstallationType type = + installer::ExpectValidInstallation(system_install_); + BrowserDistribution* dist = GetCurrentBrowserDistribution(); + ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_)); + EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI); + // Launch IE + LaunchIE(L"gcf:about:version"); + // Check if Chrome process got spawned. + MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, false); + FindChromeShortcut(); +} + // This method tests the standalone installer by verifying the steps listed at: // https://sites.google.com/a/google.com/chrome-pmo/ // standalone-installers/testing-standalone-installers @@ -339,48 +356,34 @@ void ChromeMiniInstaller::UnInstall() { if (!GetChromeVersionFromRegistry(&version)) return; - // Close running products. - if (is_chrome_frame_) { - MiniInstallerTestUtil::CloseProcesses( - mini_installer_constants::kIEProcessName); - } else { - MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); - } + // Attempt to kill all Chrome/Chrome Frame related processes. + MiniInstallerTestUtil::CloseProcesses( + mini_installer_constants::kIEProcessName); + MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); // Get uninstall command. CommandLine cmd = InstallUtil::GetChromeUninstallCmd( system_install_, dist->GetType()); - - LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString(); ASSERT_TRUE(file_util::PathExists(cmd.GetProgram())) << "Uninstall executable does not exist."; - cmd.AppendSwitch(installer::switches::kUninstall); cmd.AppendSwitch(installer::switches::kForceUninstall); - if (is_chrome_frame_) - cmd.AppendSwitch(installer::switches::kChromeFrame); - if (system_install_) - cmd.AppendSwitch(installer::switches::kSystemLevel); + LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString(); base::ProcessHandle setup_handle; ASSERT_TRUE(base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle)) << "Failed to launch uninstall command."; - if (is_chrome_frame_) - ASSERT_TRUE(CloseUninstallWindow()); + LOG(INFO) << (CloseUninstallWindow() ? "Succeeded " : "Failed ") + << "in attempt to closed uninstall window."; ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())) << "It appears Chrome was not completely uninstalled."; DeleteUserDataFolder(); // Close IE survey window that gets launched on uninstall. - if (!is_chrome_frame_) { - FindChromeShortcut(); - MiniInstallerTestUtil::CloseProcesses( - mini_installer_constants::kIEExecutable); - ASSERT_EQ(0, - base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); - } + MiniInstallerTestUtil::CloseProcesses( + mini_installer_constants::kIEExecutable); } void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { @@ -771,7 +774,10 @@ bool ChromeMiniInstaller::GetFullInstaller(FilePath* path) { bool ChromeMiniInstaller::GetDiffInstaller(FilePath* path) { std::string diff_installer_pattern("*_from_*"); - return GetInstaller(diff_installer_pattern, path); + bool retval = GetInstaller(diff_installer_pattern, path); + if (retval) + current_diff_build_ = path->DirName().DirName().BaseName().MaybeAsASCII(); + return retval; } bool ChromeMiniInstaller::GetMiniInstaller(FilePath* path) { diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h index 08081da..d95da94 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.h +++ b/chrome/test/mini_installer_test/chrome_mini_installer.h @@ -17,7 +17,8 @@ // This class has methods to install and uninstall Chrome mini installer. class ChromeMiniInstaller { public: - ChromeMiniInstaller(bool system_install, bool is_chrome_frame); + ChromeMiniInstaller(bool system_install, + bool is_chrome_frame, const std::string& build); ~ChromeMiniInstaller() {} enum RepairChrome { @@ -34,6 +35,8 @@ class ChromeMiniInstaller { void InstallUsingMultiInstall(); + void InstallChromeFrameUsingMultiInstall(); + // Installs chrome. void Install(); @@ -66,8 +69,6 @@ class ChromeMiniInstaller { // This method will perform a over install void OverInstall(); - void SetBuildUnderTest(const std::string& build); - private: // Will clean up the machine if Chrome install is messed up. void CleanChromeInstall(); @@ -150,7 +151,7 @@ class ChromeMiniInstaller { // Build under test. std::string build_; // Build numbers. - std::string current_build_, previous_build_; + std::string current_build_, current_diff_build_, previous_build_; DISALLOW_COPY_AND_ASSIGN(ChromeMiniInstaller); }; diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.cc b/chrome/test/mini_installer_test/mini_installer_test_util.cc index 03a8c56..a295984 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_util.cc +++ b/chrome/test/mini_installer_test/mini_installer_test_util.cc @@ -49,27 +49,6 @@ void MiniInstallerTestUtil::CloseProcesses( ASSERT_EQ(0, base::GetProcessCount(executable_name, NULL)); } -bool MiniInstallerTestUtil::CloseWindow(const wchar_t* window_name, - UINT message) { - int timer = 0; - bool return_val = false; - HWND hndl = FindWindow(NULL, window_name); - while (hndl == NULL && (timer < 60000)) { - hndl = FindWindow(NULL, window_name); - base::PlatformThread::Sleep(200); - timer = timer + 200; - } - if (hndl != NULL) { - LRESULT _result = SendMessage(hndl, message, 1, 0); - return_val = true; - } - return return_val; -} - -bool IsNewer(const FileInfo& file_rbegin, const FileInfo& file_rend) { - return (file_rbegin.creation_time_ > file_rend.creation_time_); -} - FilePath MiniInstallerTestUtil::GetFilePath(const wchar_t* exe_name) { FilePath installer_path; PathService::Get(base::DIR_EXE, &installer_path); diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.h b/chrome/test/mini_installer_test/mini_installer_test_util.h index 5fbf4b3..79e6f56 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_util.h +++ b/chrome/test/mini_installer_test/mini_installer_test_util.h @@ -12,29 +12,10 @@ #include <vector> -#include "base/basictypes.h" #include "base/process.h" class FilePath; -// This structure holds the name and creation time -// details of all the chrome nightly builds. -class FileInfo { - public: - FileInfo() {} - FileInfo(const std::wstring& in_name, int in_creation_time) { - name_.assign(in_name); - creation_time_ = in_creation_time; - } - // This is a predicate to sort file information. - bool IsNewer(const FileInfo& creation_time_begin, - const FileInfo& creation_time_end); - - std::wstring name_; - int creation_time_; -}; -typedef std::vector<FileInfo> FileInfoList; - // This class maintains all the utility methods that are needed by mini // installer test class. class MiniInstallerTestUtil { @@ -46,10 +27,6 @@ class MiniInstallerTestUtil { // Closes specified process. static void CloseProcesses(const std::wstring& executable_name); - // Close Window whose name is 'window_name', by sending Windows message - // 'message' to it. - static bool CloseWindow(const wchar_t* window_name, UINT message); - // Returns the directory containing exe_name. static FilePath GetFilePath(const wchar_t* exe_name); diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index 4e72844..1c72014 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -18,7 +18,7 @@ void BackUpProfile(bool chrome_frame) { "Please close Chrome and run the tests again.\n"); exit(1); } - ChromeMiniInstaller installer(false, chrome_frame); + ChromeMiniInstaller installer(false, chrome_frame, ""); FilePath path; installer.GetChromeInstallDirectoryLocation(&path); path = path.Append(mini_installer_constants::kChromeAppDir).DirName(); diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 1402589..5847998 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -19,52 +19,32 @@ using namespace mini_installer_constants; // NOLINT namespace { - class MiniInstallTest : public testing::Test { public: - MiniInstallTest() : chrome_frame_(false) {} - - static void CleanTheSystem() { - const CommandLine* cmd = CommandLine::ForCurrentProcess(); - if (cmd->HasSwitch(installer::switches::kChromeFrame)) { - ChromeMiniInstaller(true, true).UnInstall(); - } else { - ChromeMiniInstaller(false, false).UnInstall(); - ChromeMiniInstaller(true, false).UnInstall(); - } - } - - virtual void SetUp() { - // Parse test command-line arguments. + MiniInstallTest() { + std::string build; const CommandLine* cmd = CommandLine::ForCurrentProcess(); - std::string build = - cmd->GetSwitchValueASCII(switches::kInstallerTestBuild); - chrome_frame_ = cmd->HasSwitch(installer::switches::kChromeFrame); - - CleanTheSystem(); - - // Create a few differently configured installers that are used in - // the tests, for convenience. - user_inst_.reset(new ChromeMiniInstaller(false, chrome_frame_)); - sys_inst_.reset(new ChromeMiniInstaller(true, chrome_frame_)); - sys_inst_->SetBuildUnderTest(build); - user_inst_->SetBuildUnderTest(build); + build = cmd->GetSwitchValueASCII(switches::kInstallerTestBuild); + chrome_user_installer_.reset( + new ChromeMiniInstaller(false, false, build)); + chrome_sys_installer_.reset(new ChromeMiniInstaller(true, false, build)); + cf_user_installer_.reset(new ChromeMiniInstaller(false, true, build)); + cf_sys_installer_.reset(new ChromeMiniInstaller(true, true, build)); } - static void TearDownTestCase() { - // Uninstall Chrome from the system after tests are run. - CleanTheSystem(); + virtual void TearDown() { + chrome_user_installer_->UnInstall(); + chrome_sys_installer_->UnInstall(); + cf_user_installer_->UnInstall(); + cf_sys_installer_->UnInstall(); } protected: - // Decided if ChromeFrame tests should be run. - bool chrome_frame_; - - // Installers created in test fixture setup for convenience. - scoped_ptr<ChromeMiniInstaller> user_inst_; - scoped_ptr<ChromeMiniInstaller> sys_inst_; + scoped_ptr<ChromeMiniInstaller> chrome_user_installer_; + scoped_ptr<ChromeMiniInstaller> chrome_sys_installer_; + scoped_ptr<ChromeMiniInstaller> cf_user_installer_; + scoped_ptr<ChromeMiniInstaller> cf_sys_installer_; }; - } // namespace #if defined(GOOGLE_CHROME_BUILD) @@ -74,111 +54,102 @@ class MiniInstallTest : public testing::Test { // Install full installer at system level. TEST_F(MiniInstallTest, FullInstallerSys) { - sys_inst_->InstallFullInstaller(false); + chrome_sys_installer_->InstallFullInstaller(false); } // Install full installer at user level. TEST_F(MiniInstallTest, FullInstallerUser) { - if (!chrome_frame_) - user_inst_->InstallFullInstaller(false); + chrome_user_installer_->InstallFullInstaller(false); } // Overinstall full installer. TEST_F(MiniInstallTest, FullOverPreviousFullUser) { - if (!chrome_frame_) - user_inst_->OverInstallOnFullInstaller(kFullInstall, false); + chrome_user_installer_->OverInstallOnFullInstaller(kFullInstall, false); } TEST_F(MiniInstallTest, FullOverPreviousFullSys) { - sys_inst_->OverInstallOnFullInstaller(kFullInstall, false); + chrome_sys_installer_->OverInstallOnFullInstaller(kFullInstall, false); } // Overinstall full Chrome Frame installer while IE browser is running. TEST_F(MiniInstallTest, FullFrameOverPreviousFullIERunningSys) { - if (chrome_frame_) - sys_inst_->OverInstallOnFullInstaller(kFullInstall, true); + cf_sys_installer_->OverInstallOnFullInstaller(kFullInstall, true); } // Overinstall diff installer. TEST_F(MiniInstallTest, DiffOverPreviousFullUser) { - if (!chrome_frame_) - user_inst_->OverInstallOnFullInstaller(kDiffInstall, false); + chrome_user_installer_->OverInstallOnFullInstaller(kDiffInstall, false); } TEST_F(MiniInstallTest, DiffOverPreviousFullSys) { - sys_inst_->OverInstallOnFullInstaller(kDiffInstall, false); + chrome_sys_installer_->OverInstallOnFullInstaller(kDiffInstall, false); } // Overinstall diff Chrome Frame installer while IE browser is running. TEST_F(MiniInstallTest, DiffFrameOverPreviousFullIERunningSys) { - if (chrome_frame_) - sys_inst_->OverInstallOnFullInstaller(kDiffInstall, true); + cf_sys_installer_->OverInstallOnFullInstaller(kDiffInstall, true); } // Repair version folder. TEST_F(MiniInstallTest, RepairFolderOnFullUser) { - if (!chrome_frame_) - user_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); + chrome_user_installer_->Repair(ChromeMiniInstaller::VERSION_FOLDER); } TEST_F(MiniInstallTest, RepairFolderOnFullSys) { - sys_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); + chrome_sys_installer_->Repair(ChromeMiniInstaller::VERSION_FOLDER); } // Repair registry. TEST_F(MiniInstallTest, RepairRegistryOnFullUser) { - if (!chrome_frame_) - user_inst_->Repair(ChromeMiniInstaller::REGISTRY); + chrome_user_installer_->Repair(ChromeMiniInstaller::REGISTRY); } TEST_F(MiniInstallTest, RepairRegistryOnFullSys) { - sys_inst_->Repair(ChromeMiniInstaller::REGISTRY); + chrome_sys_installer_->Repair(ChromeMiniInstaller::REGISTRY); } // Run full Chrome Frame install then uninstall it while IE browser is running. TEST_F(MiniInstallTest, FullInstallAndUnInstallChromeFrameWithIERunning) { - if (chrome_frame_) { - sys_inst_->InstallFullInstaller(false); - sys_inst_->UnInstallChromeFrameWithIERunning(); - } + cf_sys_installer_->InstallFullInstaller(false); + cf_sys_installer_->UnInstallChromeFrameWithIERunning(); } // Install standalone. TEST_F(MiniInstallTest, InstallStandaloneUser) { - if (!chrome_frame_) - user_inst_->InstallStandaloneInstaller(); + chrome_user_installer_->InstallStandaloneInstaller(); } // This test doesn't make sense. Disabling for now. TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { - if (!chrome_frame_) - user_inst_->OverInstall(); + chrome_user_installer_->OverInstall(); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, - DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { - if (!chrome_frame_) - user_inst_->OverInstall(); + DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { + chrome_user_installer_->OverInstall(); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { - if (!chrome_frame_) - user_inst_->OverInstall(); + chrome_user_installer_->OverInstall(); } TEST_F(MiniInstallTest, InstallChromeUsingMultiInstallUser) { - user_inst_->InstallUsingMultiInstall(); + chrome_user_installer_->InstallUsingMultiInstall(); } TEST_F(MiniInstallTest, InstallChromeUsingMultiInstallSys) { - sys_inst_->InstallUsingMultiInstall(); + chrome_user_installer_->InstallUsingMultiInstall(); +} + +TEST_F(MiniInstallTest, InstallChromeFrameUsingMultiInstallUser) { + cf_user_installer_->InstallChromeFrameUsingMultiInstall(); } #endif TEST_F(MiniInstallTest, InstallMiniInstallerSys) { - sys_inst_->Install(); + chrome_user_installer_->Install(); } #if defined(OS_WIN) @@ -188,10 +159,10 @@ TEST_F(MiniInstallTest, InstallMiniInstallerSys) { #define MAYBE_InstallMiniInstallerUser InstallMiniInstallerUser #endif TEST_F(MiniInstallTest, MAYBE_InstallMiniInstallerUser) { - user_inst_->Install(); + chrome_user_installer_->Install(); } -TEST_F(MiniInstallTest, MiniInstallTestValidWindowsVersion) { +TEST(GenericInstallTest, MiniInstallTestValidWindowsVersion) { // We run the tests on all supported OSes. // Make sure the code agrees. EXPECT_TRUE(InstallUtil::IsOSSupported()); |