diff options
author | kkania@google.com <kkania@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 18:31:22 +0000 |
---|---|---|
committer | kkania@google.com <kkania@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 18:31:22 +0000 |
commit | ebb5063bcf5e814fb1fe249a75849abc1425a4e5 (patch) | |
tree | 90f48c39e419e809b6dd0679b0b0b026735bb2d2 /chrome/test/mini_installer_test | |
parent | 782dbfb3308173d51905addd039041bdf040ea89 (diff) | |
download | chromium_src-ebb5063bcf5e814fb1fe249a75849abc1425a4e5.zip chromium_src-ebb5063bcf5e814fb1fe249a75849abc1425a4e5.tar.gz chromium_src-ebb5063bcf5e814fb1fe249a75849abc1425a4e5.tar.bz2 |
Revert 29668 - Add a commandline option for specifying a particular build to test and for permitting the tests to be run regardless of underlying platform. Also some minor fixes and cleanup.
BUG=none
TEST=none
REVIEW=http://codereview.chromium.org/269016/
TBR=kkania@chromium.org
Review URL: http://codereview.chromium.org/293054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29674 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/mini_installer_test')
6 files changed, 256 insertions, 263 deletions
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index ff96c072..6c16075 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -16,110 +16,93 @@ #include "chrome/test/mini_installer_test/mini_installer_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -// Constructor. -ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type) { - install_type_ = install_type; - installer_name_ = StringPrintf(L"%ls (%ls)", - mini_installer_constants::kChromeBuildType, install_type_.c_str()); - - has_diff_installer_ = false; - has_full_installer_ = false; - has_prev_installer_ = false; -} - -void ChromeMiniInstaller::SetBuildUnderTest(const std::wstring& build) { - // Locate the full, diff, and previous installers. - const wchar_t * build_prefix; - if (LowerCaseEqualsASCII(build, "dev")) - build_prefix = mini_installer_constants::kDevChannelBuild; - else if (LowerCaseEqualsASCII(build, "stable")) - build_prefix = mini_installer_constants::kStableChannelBuild; - else if (LowerCaseEqualsASCII(build, "latest")) - build_prefix = L""; - else - build_prefix = build.c_str(); - - // Do not fail here if cannot find the installer. Set the bool and allow - // to fail in the particular test. - has_full_installer_ = MiniInstallerTestUtil::GetInstaller( - mini_installer_constants::kFullInstallerPattern, - &full_installer_, build_prefix); - has_diff_installer_ = MiniInstallerTestUtil::GetInstaller( - mini_installer_constants::kDiffInstallerPattern, - &diff_installer_, build_prefix); - - if (has_diff_installer_) { - has_prev_installer_ = MiniInstallerTestUtil::GetPreviousFullInstaller( - diff_installer_, &prev_installer_); - } - - // Find the version names. The folder two-levels up from the installer - // is named this. - if (has_full_installer_) { - FilePath folder = FilePath(full_installer_).DirName().DirName(); - curr_version_ = folder.BaseName().value(); - } - if (has_prev_installer_) { - FilePath folder = FilePath(prev_installer_).DirName().DirName(); - prev_version_ = folder.BaseName().value(); - } -} - // Installs Chrome. void ChromeMiniInstaller::Install() { std::wstring installer_path = MiniInstallerTestUtil::GetFilePath( mini_installer_constants::kChromeMiniInstallerExecutable); - InstallMiniInstaller(false, installer_path); + InstallMiniInstaller(false, installer_path); } // This method will get the previous latest full installer from // nightly location, install it and over install with specified install_type. void ChromeMiniInstaller::OverInstallOnFullInstaller( - const std::wstring& install_type) { - ASSERT_TRUE(has_full_installer_ && has_diff_installer_ && - has_prev_installer_); - - InstallMiniInstaller(false, prev_installer_); - - std::wstring got_prev_version; - GetChromeVersionFromRegistry(&got_prev_version); + const std::wstring& install_type, const wchar_t* channel_type) { + std::wstring diff_installer; + ASSERT_TRUE(MiniInstallerTestUtil::GetInstaller( + mini_installer_constants::kDiffInstallerPattern, + &diff_installer, channel_type)); + std::wstring prev_full_installer; + ASSERT_TRUE(MiniInstallerTestUtil::GetPreviousFullInstaller( + diff_installer, &prev_full_installer, channel_type)); + printf("\nPrevious full installer name is %ls\n", + prev_full_installer.c_str()); + InstallMiniInstaller(false, prev_full_installer); + std::wstring full_installer_value; + GetChromeVersionFromRegistry(&full_installer_value); printf("\n\nPreparing to overinstall...\n"); - if (install_type == mini_installer_constants::kDiffInstall) { printf("\nOver installing with latest differential installer: %ls\n", - diff_installer_.c_str()); - InstallMiniInstaller(true, diff_installer_); - + diff_installer.c_str()); + InstallMiniInstaller(true, diff_installer); } else if (install_type == mini_installer_constants::kFullInstall) { + std::wstring latest_full_installer; + ASSERT_TRUE(MiniInstallerTestUtil::GetInstaller( + mini_installer_constants::kFullInstallerPattern, + &latest_full_installer, channel_type)); printf("\nOver installing with latest full insatller: %ls\n", - full_installer_.c_str()); - InstallMiniInstaller(true, full_installer_); + latest_full_installer.c_str()); + InstallMiniInstaller(true, latest_full_installer); } - - std::wstring got_curr_version; - GetChromeVersionFromRegistry(&got_curr_version); - - if (got_prev_version == prev_version_ && - got_curr_version == curr_version_) { - printf("\n The over install was successful. Here are the values:\n"); + std::wstring diff_installer_value; + GetChromeVersionFromRegistry(&diff_installer_value); + ASSERT_TRUE(VerifyDifferentialInstall(full_installer_value, + diff_installer_value, diff_installer, channel_type)); +} + +// This method will get the diff installer file name and +// then derives the previous and latest build numbers. +bool ChromeMiniInstaller::VerifyDifferentialInstall( + const std::wstring& full_installer_value, + const std::wstring& diff_installer_value, + const std::wstring& diff_path, + const wchar_t* channel_type) { + std::wstring actual_full_installer_value; + std::wstring diff_installer_name = file_util::GetFilenameFromPath(diff_path); + MiniInstallerTestUtil::GetPreviousBuildNumber(diff_path, + &actual_full_installer_value, channel_type); + // This substring will give the full installer build number. + std::wstring actual_diff_installer_value; + actual_diff_installer_value.assign(channel_type); + // This substring will give the diff installer build number. + actual_diff_installer_value.append(diff_installer_name.substr(0, + diff_installer_name.find(L'_'))); + if ((actual_full_installer_value == full_installer_value) && + (actual_diff_installer_value == diff_installer_value)) { + printf("\n The diff installer is successful. Here are the values:\n"); printf("\n full installer value: %ls and diff installer value is %ls\n", - prev_version_.c_str(), curr_version_.c_str()); + full_installer_value.c_str(), diff_installer_value.c_str()); + return true; } else { - printf("\n The over install was not successful. Here are the values:\n"); + printf("\n The diff installer is not successful. Here are the values:\n"); printf("\n Expected full installer value: %ls and actual value is %ls\n", - prev_version_.c_str(), got_prev_version.c_str()); + full_installer_value.c_str(), actual_full_installer_value.c_str()); printf("\n Expected diff installer value: %ls and actual value is %ls\n", - curr_version_.c_str(), got_curr_version.c_str()); - FAIL(); + diff_installer_value.c_str(), actual_diff_installer_value.c_str()); + return false; } } - // This method will get the latest full installer from nightly location // and installs it. -void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { - ASSERT_TRUE(has_full_installer_); - InstallMiniInstaller(over_install, full_installer_); +void ChromeMiniInstaller::InstallFullInstaller(bool over_install, + const wchar_t* channel_type) { + std::wstring full_installer_file_name; + ASSERT_TRUE(MiniInstallerTestUtil::GetInstaller( + mini_installer_constants::kFullInstallerPattern, + &full_installer_file_name, channel_type)); + printf("The latest full installer is %ls\n\n", + full_installer_file_name.c_str()); + InstallMiniInstaller(over_install, full_installer_file_name); } // Installs the Chrome mini-installer, checks the registry and shortcuts. @@ -184,13 +167,13 @@ void ChromeMiniInstaller::InstallMetaInstaller() { // If the build type is Google Chrome, then it first installs meta installer // and then over installs with mini_installer. It also verifies if Chrome can // be launched successfully after overinstall. -void ChromeMiniInstaller::OverInstall() { +void ChromeMiniInstaller::OverInstall(const wchar_t* channel_type) { InstallMetaInstaller(); std::wstring reg_key_value_returned; // gets the registry key value before overinstall. GetChromeVersionFromRegistry(®_key_value_returned); printf("\n\nPreparing to overinstall...\n"); - InstallFullInstaller(true); + InstallFullInstaller(true, channel_type); std::wstring reg_key_value_after_overinstall; // Get the registry key value after over install GetChromeVersionFromRegistry(®_key_value_after_overinstall); @@ -202,8 +185,9 @@ void ChromeMiniInstaller::OverInstall() { // folder based on the passed argument, then tries to launch Chrome. // Then installs Chrome again to repair. void ChromeMiniInstaller::Repair( - ChromeMiniInstaller::RepairChrome repair_type) { - InstallFullInstaller(false); + ChromeMiniInstaller::RepairChrome repair_type, + const wchar_t* channel_type) { + InstallFullInstaller(false, channel_type); MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { DeleteFolder(L"version_folder"); @@ -216,7 +200,7 @@ void ChromeMiniInstaller::Repair( ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); VerifyChromeLaunch(false); printf("\nInstalling Chrome again to see if it can be repaired\n\n"); - InstallFullInstaller(true); + InstallFullInstaller(true, channel_type); printf("Chrome repair successful.\n"); // Set the current directory back to original path. ::SetCurrentDirectory(current_path.c_str()); diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h index 0a0c956..58d43fb2 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.h +++ b/chrome/test/mini_installer_test/chrome_mini_installer.h @@ -2,19 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H_ -#define CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H_ +#ifndef CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__ +#define CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__ #include <windows.h> #include <string> #include "base/basictypes.h" -#include "base/string_util.h" // This class has methods to install and uninstall Chrome mini installer. class ChromeMiniInstaller { public: - explicit ChromeMiniInstaller(const std::wstring& install_type); + explicit ChromeMiniInstaller(std::wstring install_type) { + install_type_ = install_type; + } ~ChromeMiniInstaller() {} @@ -28,14 +29,15 @@ class ChromeMiniInstaller { std::wstring GetChromeInstallDirectoryLocation(); // Installs the latest full installer. - void InstallFullInstaller(bool over_install); + void InstallFullInstaller(bool over_install, const wchar_t* channel_type); // Installs chrome. void Install(); // This method will first install the full installer and // then over installs with diff installer. - void OverInstallOnFullInstaller(const std::wstring& install_type); + void OverInstallOnFullInstaller(const std::wstring& install_type, + const wchar_t* channel_type); // Installs Google Chrome through meta installer. void InstallMetaInstaller(); @@ -48,15 +50,13 @@ class ChromeMiniInstaller { void InstallStandaloneInstaller(); // Repairs Chrome based on the passed argument. - void Repair(RepairChrome repair_type); + void Repair(RepairChrome repair_type, const wchar_t* channel_type); // Uninstalls Chrome. void UnInstall(); // This method will perform a over install - void OverInstall(); - - void SetBuildUnderTest(const std::wstring& build); + void OverInstall(const wchar_t* channel_type); private: // This variable holds the install type. @@ -65,20 +65,6 @@ class ChromeMiniInstaller { bool standalone_installer; - // Name of the browser (Chrome or Chromium) and install type (sys or user) - std::wstring installer_name_; - - // The full path to the various installers. - std::wstring full_installer_, diff_installer_, prev_installer_; - - // Whether the path to the associated installer could be found. - // This is because we do not want to assert that these paths exist - // except in the tests that use them. - bool has_full_installer_, has_diff_installer_, has_prev_installer_; - - // The version string of the current and previous builds. - std::wstring curr_version_, prev_version_; - // Will clean up the machine if Chrome install is messed up. void CleanChromeInstall(); @@ -138,11 +124,16 @@ class ChromeMiniInstaller { bool VerifyOverInstall(const std::wstring& reg_key_value_before_overinstall, const std::wstring& reg_key_value_after_overinstall); + // Checks if the differential install is correct. + bool VerifyDifferentialInstall(const std::wstring& full_installer_value, + const std::wstring& diff_installer_value, + const std::wstring& diff_installer_name, + const wchar_t* channel_type); + // This method will verify if the installed build is correct. bool VerifyStandaloneInstall(); DISALLOW_COPY_AND_ASSIGN(ChromeMiniInstaller); }; -#endif // CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H_ - +#endif // CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__ 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 f076ee0..3593f10 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_util.cc +++ b/chrome/test/mini_installer_test/mini_installer_test_util.cc @@ -46,7 +46,7 @@ bool MiniInstallerTestUtil::CloseWindow(const wchar_t* window_name, int timer = 0; bool return_val = false; HWND hndl = FindWindow(NULL, window_name); - while (hndl == NULL && (timer < 20000)) { + while (hndl == NULL && (timer < 60000)) { hndl = FindWindow(NULL, window_name); PlatformThread::Sleep(200); timer = timer + 200; @@ -101,17 +101,16 @@ bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, FileInfoList exe_list; std::wstring chrome_diff_installer( mini_installer_constants::kChromeDiffInstallerLocation); - chrome_diff_installer.append(L"*"); if (!GetLatestFile(chrome_diff_installer.c_str(), channel_type, &builds_list)) return false; - FileInfoList::const_reverse_iterator builds_list_size = builds_list.rbegin(); while (builds_list_size != builds_list.rend()) { path->assign(mini_installer_constants::kChromeDiffInstallerLocation); file_util::AppendToPath(path, builds_list_size->name_); - file_util::AppendToPath(path, L"win"); + if (channel_type == mini_installer_constants::kDevChannelBuild) + file_util::AppendToPath(path, L"win"); std::wstring installer_path(path->c_str()); file_util::AppendToPath(&installer_path, L"*.exe"); if (!GetLatestFile(installer_path.c_str(), pattern, &exe_list)) { @@ -131,7 +130,6 @@ bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, // This method will get the latest installer filename from the directory. bool MiniInstallerTestUtil::GetLatestFile(const wchar_t* file_name, const wchar_t* pattern, FileInfoList *file_details) { - WIN32_FIND_DATA find_file_data; HANDLE file_handle = FindFirstFile(file_name, &find_file_data); if (file_handle == INVALID_HANDLE_VALUE) { @@ -164,58 +162,47 @@ bool MiniInstallerTestUtil::GetLatestFile(const wchar_t* file_name, return return_val; } -// This method retrieves the previous build version for the given diff -// installer path. -bool MiniInstallerTestUtil::GetPreviousBuildNumber(const std::wstring& path, - std::wstring *build_number) { - - std::wstring diff_name = file_util::GetFilenameFromPath(path); - // We want to remove 'from_', so add its length to found index (which is 5) - std::wstring::size_type start_position = diff_name.find(L"from_") + 5; - std::wstring::size_type end_position = diff_name.find(L"_c"); - std::wstring::size_type size = end_position - start_position; - - std::wstring build_no = diff_name.substr(start_position, size); - - // Search for a build folder with this build suffix. - std::wstring pattern = L"*" + build_no; - - file_util::FileEnumerator files(FilePath( - mini_installer_constants::kChromeDiffInstallerLocation), - false, file_util::FileEnumerator::DIRECTORIES, pattern); - FilePath folder = files.Next(); - if (folder.empty()) - return false; - - build_number->assign(folder.BaseName().ToWStringHack()); - return true; +void MiniInstallerTestUtil::GetPreviousBuildNumber(const std::wstring& path, + std::wstring *build_number, const wchar_t* channel_type) { + std::wstring diff_installer_name = file_util::GetFilenameFromPath(path); + std::wstring::size_type start_position = diff_installer_name.find(L"f"); + std::wstring::size_type end_position = diff_installer_name.find(L"_c"); + end_position = end_position - start_position; + std::wstring file_name = diff_installer_name.substr(start_position, + end_position); + file_name = file_name.substr(file_name.find(L'_')+1, file_name.size()); + file_name = channel_type + file_name; + build_number->assign(file_name); + LOG(INFO) << "Previous build number: " << file_name.c_str(); } - // This method will get the previous full installer path // from given diff installer path. It will first get the // filename from the diff installer path, gets the previous // build information from the filename, then computes the // path for previous full installer. bool MiniInstallerTestUtil::GetPreviousFullInstaller( - const std::wstring& diff_path, std::wstring *previous) { - std::wstring build_no; - - if (!GetPreviousBuildNumber(diff_path, &build_no)) + const std::wstring& diff_file_name, std::wstring *previous, + const wchar_t* channel_type) { + std::wstring diff_file = diff_file_name; + std::wstring build_number; + GetPreviousBuildNumber(diff_file, &build_number, channel_type); + file_util::UpOneDirectory(&diff_file); + file_util::UpOneDirectory(&diff_file); + if (channel_type == mini_installer_constants::kDevChannelBuild) + file_util::UpOneDirectory(&diff_file); + file_util::AppendToPath(&diff_file, build_number.c_str()); + if (channel_type == mini_installer_constants::kDevChannelBuild) + file_util::AppendToPath(&diff_file, L"win"); + previous->assign(diff_file); + file_util::AppendToPath(&diff_file, L"*.exe"); + FileInfoList directory_list; + if (!GetLatestFile(diff_file.c_str(), + mini_installer_constants::kFullInstallerPattern, + &directory_list)) return false; - - // Use the fifth and onward characters of the build version string - // to compose the full installer name. - std::wstring name = build_no.substr(4) + - mini_installer_constants::kFullInstallerPattern + L".exe"; - - // Create the full installer path. - FilePath installer = FilePath( - mini_installer_constants::kChromeDiffInstallerLocation); - installer = installer.Append(build_no).Append(L"win").Append(name); - previous->assign(installer.value()); - - return file_util::PathExists(installer); + file_util::AppendToPath(previous, directory_list.at(0).name_); + return file_util::PathExists(FilePath::FromWStringHack(*previous)); } bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( @@ -243,7 +230,7 @@ bool MiniInstallerTestUtil::GetStandaloneVersion( file_name = file_name.substr(0, last_dot); std::wstring::size_type pos = file_name.find(L'_'); file_name.replace(pos, 1, L"."); - file_name = L"3.0." + file_name; + file_name = L"2.0." + file_name; return_file_name->assign(file_name.c_str()); LOG(INFO) << "Standalone installer version: " << file_name.c_str(); return true; @@ -262,19 +249,16 @@ void MiniInstallerTestUtil::SendEnterKeyToWindow() { SendInput(1, &key, sizeof(INPUT)); } - void MiniInstallerTestUtil::VerifyProcessLaunch( const wchar_t* process_name, bool expected_status) { int timer = 0, wait_time = 60000; if (!expected_status) wait_time = 8000; - while ((base::GetProcessCount(process_name, NULL) == 0) && (timer < wait_time)) { PlatformThread::Sleep(200); timer = timer + 200; } - if (expected_status) ASSERT_NE(0, base::GetProcessCount(process_name, NULL)); else 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 dd205ab..8312dad 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_util.h +++ b/chrome/test/mini_installer_test/mini_installer_test_util.h @@ -60,24 +60,22 @@ class MiniInstallerTestUtil { // Returns the directory containing exe_name. static std::wstring GetFilePath(const wchar_t* exe_name); - // This method will get the list of all folders or files based on the passed // 'path' and 'pattern' argument. The 'pattern' argument decides if the // requested file is a full or a differential installer. static bool GetLatestFile(const wchar_t* path, const wchar_t* pattern, FileInfoList *file_name); - // This method retrieves the previous build version for the given diff - // installer path. - static bool GetPreviousBuildNumber(const std::wstring& path, - std::wstring *build_number); + // This method will get the previous build number + static void GetPreviousBuildNumber(const std::wstring& path, + std::wstring *build_number, const wchar_t* channel_type); // This method will get the previous full installer based on 'diff_file' // and 'channel_type' arguments. The 'channel_type' // parameter decides if the build is stable/dev/beta. The 'diff_file' // parameter will hold the latest diff installer name. static bool GetPreviousFullInstaller(const std::wstring& diff_file, - std::wstring *previous); + std::wstring *previous, const wchar_t* channel_type); // This method will return standalone installer file name. static bool GetStandaloneInstallerFileName(FileInfoList *file_name); diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index e6ef00f..9f2dc9f 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -8,7 +8,6 @@ #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" #include "chrome_mini_installer.h" - void BackUpProfile() { if (base::GetProcessCount(L"chrome.exe", NULL) > 0) { printf("Chrome is currently running and cannot backup the profile." @@ -47,21 +46,14 @@ int main(int argc, char** argv) { } else if (command_line.HasSwitch("backup")) { BackUpProfile(); } else { - printf("This test needs command line arguments.\n"); - printf("Usage: %ls -{clean|backup} [-build <version>] [-force] \n", - command_line.program().c_str()); - printf("-clean arg will uninstall your chrome at all levels" + printf("This test needs command line Arguments.\n"); + printf("Usage: mini_installer_tests.exe -{clean|backup}\n"); + printf("Note: -clean arg will uninstall your chrome at all levels" " and also delete profile.\n" "-backup arg will make a copy of User Data before uninstalling" " your chrome at all levels. The copy will be named as" - " User Data Copy.\n" - "-build specifies the build to be tested, e.g., 3.0.195.24." - " Specifying 'dev' or 'stable' will use the latest build from that" - " channel. 'latest', the default, will use the latest build.\n" - "-force allows these tests to be run on the current platform," - " regardless of whether it is supported.\n"); - return 1; + " User Data Copy.\n"); + exit(1); } - return TestSuite(argc, argv).Run(); } diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 345a24d..6c93acb 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -1,145 +1,189 @@ // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/command_line.h" #include "base/platform_thread.h" -#include "base/scoped_ptr.h" #include "base/win_util.h" #include "chrome/installer/util/install_util.h" #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" -#include "chrome/test/mini_installer_test/mini_installer_test_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "chrome_mini_installer.h" -// Although the C++ style guide disallows use of namespace directive, use -// here because this is not only a .cc file, but also a test. -using namespace mini_installer_constants; - namespace { - class MiniInstallTest : public testing::Test { protected: - // Whether these tests should be run regardless of our running platform. - bool force_tests_; - - // Installers created in test fixture setup for convenience. - scoped_ptr<ChromeMiniInstaller> user_inst_, sys_inst_; - - public: void CleanTheSystem() { - ChromeMiniInstaller userinstall(kUserInstall); + ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall); userinstall.UnInstall(); - ChromeMiniInstaller systeminstall(kSystemInstall); - systeminstall.UnInstall(); + ChromeMiniInstaller systeminstall( + mini_installer_constants::kSystemInstall); + systeminstall.UnInstall(); } - virtual void SetUp() { - // Parse test command-line arguments. - const CommandLine* cmd = CommandLine::ForCurrentProcess(); - std::wstring build = cmd->GetSwitchValue(L"build"); - if (build.empty()) - build = L"latest"; - - force_tests_ = cmd->HasSwitch(L"force"); - - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA || - force_tests_) { + if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { CleanTheSystem(); - // Separate the test output from cleaning output - printf("\nBEGIN test----------------------------------------\n"); - - // Create a few differently configured installers that are used in - // the tests, for convenience. - user_inst_.reset(new ChromeMiniInstaller(kUserInstall)); - user_inst_->SetBuildUnderTest(build); - sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall)); - sys_inst_->SetBuildUnderTest(build); - } else { - printf("These tests don't run on this platform.\n"); - exit(1); + printf("These tests don't run on Vista\n"); + exit(0); + } + } + virtual void TearDown() { + if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + PlatformThread::Sleep(2000); + CleanTheSystem(); + } else { + printf("These tests don't run on Vista\n"); + exit(0); } } }; }; -#if defined(GOOGLE_CHROME_BUILD) -// Could use a parameterized gtest to slim down this list of tests, but since -// these tests will often be run manually, don't want to have obscure test -// names. +// TODO(nsylvain): Change this for GOOGLE_CHROME_BUILD when we have the +// previous installers accessible from our Google Chrome continuous buildbot. +#if defined(OFFICIAL_BUILD) +TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTest) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kDevChannelBuild); +} -// Install full installer. -TEST_F(MiniInstallTest, FullInstallerUser) { - user_inst_->InstallFullInstaller(false); +TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTestSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kDevChannelBuild); } -TEST_F(MiniInstallTest, FullInstallerSys) { - sys_inst_->InstallFullInstaller(false); + +TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTest) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kStableChannelBuild); } -// Overinstall full installer. -TEST_F(MiniInstallTest, FullOverPreviousFullUser) { - user_inst_->OverInstallOnFullInstaller(kFullInstall); +TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTestSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kStableChannelBuild); } -TEST_F(MiniInstallTest, FullOverPreviousFullSys) { - sys_inst_->OverInstallOnFullInstaller(kFullInstall); + +TEST_F(MiniInstallTest, + InstallLatestDevFullInstallerOverPreviousFullDevInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kDevChannelBuild); +} + +TEST_F(MiniInstallTest, + InstallLatestDevFullInstallerOverPreviousFullDevInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kDevChannelBuild); } -// Overinstall diff installer. -TEST_F(MiniInstallTest, DiffOverPreviousFullUser) { - user_inst_->OverInstallOnFullInstaller(kDiffInstall); +TEST_F(MiniInstallTest, + InstallLatestDevDiffInstallerOverPreviousFullDevInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kDevChannelBuild); } -TEST_F(MiniInstallTest, DiffOverPreviousFullSys) { - sys_inst_->OverInstallOnFullInstaller(kDiffInstall); + +TEST_F(MiniInstallTest, + InstallLatestDevDiffInstallerOverPreviousFullDevInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kDevChannelBuild); } -// Repair version folder. -TEST_F(MiniInstallTest, RepairFolderOnFullUser) { - user_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); +TEST_F(MiniInstallTest, + InstallLatestFullStableInstallerOverPreviousFullStableInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kStableChannelBuild); } -TEST_F(MiniInstallTest, RepairFolderOnFullSys) { - sys_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); + +TEST_F(MiniInstallTest, + InstallLatestFullStableInstallerOverPreviousFullStableInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kStableChannelBuild); } -// Repair registry. -TEST_F(MiniInstallTest, RepairRegistryOnFullUser) { - user_inst_->Repair(ChromeMiniInstaller::REGISTRY); +TEST_F(MiniInstallTest, + InstallLatestDiffStableInstallerOverPreviousFullStableInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kStableChannelBuild); } -TEST_F(MiniInstallTest, RepairRegistryOnFullSys) { - sys_inst_->Repair(ChromeMiniInstaller::REGISTRY); + +TEST_F(MiniInstallTest, + InstallLatestDiffStableInstallerOverPreviousFullStableInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kStableChannelBuild); } -// Install standalone. -TEST_F(MiniInstallTest, InstallStandaloneUser) { - user_inst_->InstallStandaloneInstaller(); +TEST_F(MiniInstallTest, StandaloneInstallerTest) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallStandaloneInstaller(); } // This test doesn't make sense. Disabling for now. TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { - user_inst_->OverInstall(); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstall(mini_installer_constants::kDevChannelBuild); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { - user_inst_->OverInstall(); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstall(mini_installer_constants::kStableChannelBuild); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { - user_inst_->OverInstall(); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstall(mini_installer_constants::kDevChannelBuild); +} + +// Repair testcases + +TEST_F(MiniInstallTest, RepairFolderTestOnLatestDevFullInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.Repair(ChromeMiniInstaller::VERSION_FOLDER, + mini_installer_constants::kDevChannelBuild); +} + +TEST_F(MiniInstallTest, RepairFolderTestOnLatestDevFullInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.Repair(ChromeMiniInstaller::VERSION_FOLDER, + mini_installer_constants::kDevChannelBuild); +} + +TEST_F(MiniInstallTest, RepairRegistryTestOnLatestDevFullInstaller) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.Repair(ChromeMiniInstaller::REGISTRY, + mini_installer_constants::kDevChannelBuild); +} + +TEST_F(MiniInstallTest, RepairRegistryTestOnLatestDevFullInstallerSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.Repair(ChromeMiniInstaller::REGISTRY, + mini_installer_constants::kDevChannelBuild); } #endif -TEST_F(MiniInstallTest, InstallMiniInstallerSys) { - sys_inst_->Install(); +TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtSystemLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.Install(); } -TEST_F(MiniInstallTest, InstallMiniInstallerUser) { - user_inst_->Install(); +TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtUserLevel) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.Install(); } -TEST_F(MiniInstallTest, MiniInstallTestValidWindowsVersion) { +TEST(InstallUtilTests, MiniInstallTestValidWindowsVersion) { // We run the tests on all supported OSes. // Make sure the code agrees. EXPECT_TRUE(InstallUtil::IsOSSupported()); |