diff options
9 files changed, 513 insertions, 484 deletions
diff --git a/chrome/installer/installer.gyp b/chrome/installer/installer.gyp index 0058427..517ba30 100644 --- a/chrome/installer/installer.gyp +++ b/chrome/installer/installer.gyp @@ -222,12 +222,13 @@ '../..', ], 'sources': [ - 'setup/setup_constants.cc', - 'util/run_all_unittests.cc', + '../test/mini_installer_test/run_all_unittests.cc', '../test/mini_installer_test/chrome_mini_installer.cc', '../test/mini_installer_test/chrome_mini_installer.h', '../test/mini_installer_test/mini_installer_test_constants.cc', '../test/mini_installer_test/mini_installer_test_constants.h', + '../test/mini_installer_test/mini_installer_test_util.cc', + '../test/mini_installer_test/mini_installer_test_util.h', '../test/mini_installer_test/test.cc', ], 'msvs_settings': { diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index 88b5fba..3e58a86 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -1,42 +1,39 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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 "chrome/test/mini_installer_test/chrome_mini_installer.h" -#include <algorithm> - #include "base/file_util.h" #include "base/path_service.h" #include "base/platform_thread.h" #include "base/process_util.h" #include "base/registry.h" #include "base/string_util.h" -#include "base/time.h" -#include "chrome/installer/setup/setup_constants.h" #include "chrome/installer/util/browser_distribution.h" -#include "chrome/installer/util/install_util.h" #include "chrome/installer/util/google_update_constants.h" -#include "chrome/installer/util/util_constants.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" // Installs Chrome. void ChromeMiniInstaller::Install() { - std::wstring installer_path = GetFilePath( - mini_installer_constants::kChromeMiniInstallerExecutable); + std::wstring installer_path = MiniInstallerTestUtil::GetFilePath( + mini_installer_constants::kChromeMiniInstallerExecutable); 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) { + const std::wstring& install_type, const wchar_t* channel_type) { std::wstring diff_installer; - ASSERT_TRUE(GetInstaller(mini_installer_constants::kDiffInstallerPattern, - &diff_installer)); + ASSERT_TRUE(MiniInstallerTestUtil::GetInstaller( + mini_installer_constants::kDiffInstallerPattern, + &diff_installer, channel_type)); std::wstring prev_full_installer; - ASSERT_TRUE(GetPreviousFullInstaller(diff_installer, &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); @@ -49,8 +46,9 @@ void ChromeMiniInstaller::OverInstallOnFullInstaller( InstallMiniInstaller(true, diff_installer); } else if (install_type == mini_installer_constants::kFullInstall) { std::wstring latest_full_installer; - ASSERT_TRUE(GetInstaller(mini_installer_constants::kFullInstallerPattern, - &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", latest_full_installer.c_str()); InstallMiniInstaller(true, latest_full_installer); @@ -58,7 +56,7 @@ void ChromeMiniInstaller::OverInstallOnFullInstaller( std::wstring diff_installer_value; GetChromeVersionFromRegistry(&diff_installer_value); ASSERT_TRUE(VerifyDifferentialInstall(full_installer_value, - diff_installer_value, diff_installer)); + diff_installer_value, diff_installer, channel_type)); } // This method will get the diff installer file name and @@ -66,13 +64,15 @@ void ChromeMiniInstaller::OverInstallOnFullInstaller( bool ChromeMiniInstaller::VerifyDifferentialInstall( const std::wstring& full_installer_value, const std::wstring& diff_installer_value, - const std::wstring& diff_path) { + 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); - GetPreviousBuildNumber(diff_path, &actual_full_installer_value); + 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(build_channel_); + 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'_'))); @@ -92,27 +92,14 @@ bool ChromeMiniInstaller::VerifyDifferentialInstall( } } -// This method will get previous build number. -void ChromeMiniInstaller::GetPreviousBuildNumber( - const std::wstring& path, std::wstring *build_number) { - 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 = build_channel_ + file_name; - build_number->assign(file_name); - printf("Previous build number is %ls\n", file_name.c_str()); -} - // This method will get the latest full installer from nightly location // and installs it. -void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { +void ChromeMiniInstaller::InstallFullInstaller(bool over_install, + const wchar_t* channel_type) { std::wstring full_installer_file_name; - ASSERT_TRUE(GetInstaller(mini_installer_constants::kFullInstallerPattern, - &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); @@ -148,9 +135,10 @@ void ChromeMiniInstaller::InstallStandaloneInstaller() { standalone_installer = true; file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); std::wstring tag_installer_command; - ASSERT_TRUE(GetCommandForTagging(&tag_installer_command)); + ASSERT_TRUE(MiniInstallerTestUtil::GetCommandForTagging( + &tag_installer_command)); base::LaunchApp(tag_installer_command, true, false, NULL); - std::wstring installer_path = GetFilePath( + std::wstring installer_path = MiniInstallerTestUtil::GetFilePath( mini_installer_constants::kStandaloneInstaller); InstallMiniInstaller(false, installer_path); ASSERT_TRUE(VerifyStandaloneInstall()); @@ -163,7 +151,8 @@ void ChromeMiniInstaller::InstallMetaInstaller() { // Install Google Chrome through meta installer. LaunchInstaller(mini_installer_constants::kChromeMetaInstallerExe, mini_installer_constants::kChromeSetupExecutable); - VerifyProcessClose(mini_installer_constants::kChromeMetaInstallerExecutable); + ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( + mini_installer_constants::kChromeMetaInstallerExecutable)); std::wstring chrome_google_update_state_key( google_update::kRegPathClients); chrome_google_update_state_key.append(L"\\"); @@ -178,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); @@ -196,9 +185,10 @@ 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); - CloseProcesses(installer_util::kChromeExe); + 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"); printf("Deleted folder. Now trying to launch chrome\n"); @@ -207,10 +197,10 @@ void ChromeMiniInstaller::Repair( printf("Deleted registry. Now trying to launch chrome\n"); } std::wstring current_path; - ChangeCurrentDirectory(¤t_path); + 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()); @@ -233,7 +223,7 @@ void ChromeMiniInstaller::UnInstall() { } printf("\n\nUninstalling Chrome...\n"); printf("Closing Chrome processes, if any...\n"); - CloseProcesses(installer_util::kChromeExe); + MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); std::wstring uninstall_path = GetUninstallPath(); if (uninstall_path == L"") { printf("\n Chrome install is in a weird state. Cleaning the machine...\n"); @@ -249,13 +239,15 @@ void ChromeMiniInstaller::UnInstall() { printf("Launched setup.exe. Here are the commands passed: %ls\n", uninstall_args.c_str()); // ASSERT_TRUE(CloseUninstallWindow()); - VerifyProcessClose(mini_installer_constants::kChromeSetupExecutable); + ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( + mini_installer_constants::kChromeSetupExecutable)); printf("\n\nUninstall Checks:\n\n"); ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); printf("Deleting user data folder after uninstall\n"); DeleteUserDataFolder(); FindChromeShortcut(); - CloseProcesses(mini_installer_constants::kIEExecutable); + MiniInstallerTestUtil::CloseProcesses( + mini_installer_constants::kIEExecutable); ASSERT_EQ(0, base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL)); } @@ -266,37 +258,6 @@ void ChromeMiniInstaller::CleanChromeInstall() { DeleteFolder(mini_installer_constants::kChromeAppDir); } -bool ChromeMiniInstaller::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); - PlatformThread::Sleep(200); - timer = timer + 200; - } - if (hndl != NULL) { - LRESULT _result = SendMessage(hndl, message, 1, 0); - return_val = true; - } - return return_val; -} - -// This method will send enter key. -void ChromeMiniInstaller::SendEnterKeyToWindow() { - INPUT key; - key.type = INPUT_KEYBOARD; - key.ki.wVk = VK_RETURN; - key.ki.dwFlags = 0; - key.ki.time = 0; - key.ki.wScan = 0; - key.ki.dwExtraInfo = 0; - SendInput(1, &key, sizeof(INPUT)); - key.ki.dwExtraInfo = KEYEVENTF_KEYUP; - SendInput(1, &key, sizeof(INPUT)); -} - bool ChromeMiniInstaller::CloseUninstallWindow() { HWND hndl = NULL; int timer = 0; @@ -314,7 +275,7 @@ bool ChromeMiniInstaller::CloseUninstallWindow() { return false; SetForegroundWindow(hndl); - SendEnterKeyToWindow(); + MiniInstallerTestUtil::SendEnterKeyToWindow(); return true; } @@ -354,40 +315,16 @@ bool ChromeMiniInstaller::CloseChromeBrowser() { // Closes the First Run UI dialog. void ChromeMiniInstaller::CloseFirstRunUIDialog(bool over_install) { - VerifyProcessLaunch(installer_util::kChromeExe, true); + MiniInstallerTestUtil::VerifyProcessLaunch(installer_util::kChromeExe, true); if (!over_install) { - ASSERT_TRUE(CloseWindow(mini_installer_constants::kChromeFirstRunUI, - WM_CLOSE)); + ASSERT_TRUE(MiniInstallerTestUtil::CloseWindow( + mini_installer_constants::kChromeFirstRunUI, WM_CLOSE)); } else { - ASSERT_TRUE(CloseWindow(mini_installer_constants::kBrowserTabName, - WM_CLOSE)); + ASSERT_TRUE(MiniInstallerTestUtil::CloseWindow( + mini_installer_constants::kBrowserTabName, WM_CLOSE)); } } -// Checks for all requested running processes and kills them. -void ChromeMiniInstaller::CloseProcesses(const std::wstring& executable_name) { - int timer = 0; - while ((base::GetProcessCount(executable_name, NULL) > 0) && - (timer < 20000)) { - base::KillProcesses(executable_name, 1, NULL); - PlatformThread::Sleep(200); - timer = timer + 200; - } - ASSERT_EQ(0, base::GetProcessCount(executable_name, NULL)); -} - -// Change current directory so that chrome.dll from current folder -// will not be used as fall back. -void ChromeMiniInstaller::ChangeCurrentDirectory(std::wstring *current_path) { - wchar_t backup_path[MAX_PATH]; - DWORD ret = ::GetCurrentDirectory(MAX_PATH, backup_path); - ASSERT_TRUE(0 != ret && ret < MAX_PATH); - current_path->assign(backup_path); - file_util::UpOneDirectory(current_path); - ::SetCurrentDirectory(current_path->c_str()); - current_path->assign(backup_path); -} - // Checks for Chrome registry keys. bool ChromeMiniInstaller::CheckRegistryKey(const std::wstring& key_path) { RegKey key; @@ -493,40 +430,6 @@ std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { return path.ToWStringHack(); } -// This method will create a command line to run apply tag. -bool ChromeMiniInstaller::GetCommandForTagging(std::wstring *return_command) { - file_info_list file_details; - ChromeMiniInstaller::GetStandaloneInstallerFileName(&file_details); - std::wstring standalone_installer_name, standalone_installer_path; - if (file_details.empty()) - return false; - if (file_details.at(0).name_.empty()) - return false; - standalone_installer_name.append(file_details.at(0).name_); - standalone_installer_path.assign( - mini_installer_constants::kChromeStandAloneInstallerLocation); - standalone_installer_path.append(standalone_installer_name); - return_command->append( - mini_installer_constants::kChromeApplyTagExe); - return_command->append(L" "); - return_command->append(standalone_installer_path); - return_command->append(L" "); - return_command->append(mini_installer_constants::kStandaloneInstaller); - return_command->append(L" "); - return_command->append(mini_installer_constants::kChromeApplyTagParameters); - printf("Command to run Apply tag is %ls\n", return_command->c_str()); - return true; -} - -// Gets path for the specified parameter. -std::wstring ChromeMiniInstaller::GetFilePath(const wchar_t* name) { - FilePath installer_path; - PathService::Get(base::DIR_EXE, &installer_path); - installer_path = installer_path.Append(name); - printf("Chrome exe path is %ls\n", installer_path.value().c_str()); - return installer_path.ToWStringHack(); -} - // This method gets the shortcut path from startmenu based on install type std::wstring ChromeMiniInstaller::GetStartMenuShortcutPath() { FilePath path_name; @@ -537,145 +440,6 @@ std::wstring ChromeMiniInstaller::GetStartMenuShortcutPath() { return path_name.ToWStringHack(); } -// This is a predicate to sort file_info. -bool IsNewer(const file_info& file_rbegin, const file_info& file_rend) { - return (file_rbegin.creation_time_ > file_rend.creation_time_); -} - -// This method will first call GetLatestFile to get the list of all -// builds, sorted on creation time. Then goes through each build folder -// until it finds the installer file that matches the pattern argument. -bool ChromeMiniInstaller::GetInstaller(const wchar_t* pattern, - std::wstring *path) { - file_info_list list; - std::wstring chrome_diff_installer( - mini_installer_constants::kChromeDiffInstallerLocation); - chrome_diff_installer.append(L"*"); - if (!GetLatestFile(chrome_diff_installer.c_str(), - build_channel_.c_str(), &list)) - return false; - int list_size = (list.size())-1; - while (list_size > 0) { - path->assign(L""); - path->append(mini_installer_constants::kChromeDiffInstallerLocation); - file_util::AppendToPath(path, list.at(list_size).name_.c_str()); - if (build_channel_ == mini_installer_constants::kDevChannelBuild) - file_util::AppendToPath(path, L"win"); - std::wstring build_number; - build_number.assign(list.at(list_size).name_.c_str()); - std::wstring installer_path( - mini_installer_constants::kChromeDiffInstallerLocation); - installer_path.append(build_number.c_str()); - if (build_channel_ == mini_installer_constants::kDevChannelBuild) - file_util::AppendToPath(&installer_path, L"win"); - file_util::AppendToPath(&installer_path, L"*.exe"); - if (!GetLatestFile(installer_path.c_str(), pattern, &list)) { - list_size--; - } else { - file_util::AppendToPath(path, list.at(0).name_.c_str()); - if (!file_util::PathExists(*path)) { - list_size--; - } else { - break; - } - } - } - return (file_util::PathExists(path->c_str())); -} - -// This method will get the latest installer filename from the directory. -bool ChromeMiniInstaller::GetLatestFile(const wchar_t* file_name, - const wchar_t* pattern, - file_info_list *file_details) { - WIN32_FIND_DATA find_file_data; - HANDLE file_handle = FindFirstFile(file_name, &find_file_data); - if (file_handle == INVALID_HANDLE_VALUE) { - printf("Handle is invalid\n"); - return false; - } - BOOL ret = TRUE; - while (ret) { - std::wstring search_path = find_file_data.cFileName; - size_t position_found = search_path.find(pattern); - if (position_found != -1) { - std::wstring extension = file_util::GetFileExtensionFromPath(file_name); - if (extension.compare(L"exe") == 0) { - file_details->push_back(file_info(find_file_data.cFileName, 0)); - break; - } else { - FILETIME file_time = find_file_data.ftCreationTime; - base::Time creation_time = base::Time::FromFileTime(file_time); - file_details->push_back(file_info(find_file_data.cFileName, - static_cast<int>(creation_time.ToDoubleT()))); - } - } - ret = FindNextFile(file_handle, &find_file_data); - } - std::sort(file_details->rbegin(), file_details->rend(), &IsNewer); - FindClose(file_handle); - return true; -} - -// 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 ChromeMiniInstaller::GetPreviousFullInstaller( - const std::wstring& diff_file_name, std::wstring *previous) { - std::wstring diff_file = diff_file_name; - std::wstring build_number; - GetPreviousBuildNumber(diff_file, &build_number); - file_util::UpOneDirectory(&diff_file); - file_util::UpOneDirectory(&diff_file); - if (build_channel_ == mini_installer_constants::kDevChannelBuild) - file_util::UpOneDirectory(&diff_file); - file_util::AppendToPath(&diff_file, build_number.c_str()); - if (build_channel_ == mini_installer_constants::kDevChannelBuild) - file_util::AppendToPath(&diff_file, L"win"); - previous->assign(diff_file); - file_util::AppendToPath(&diff_file, L"*.exe"); - file_info_list directory_list; - if (!GetLatestFile(diff_file.c_str(), - mini_installer_constants::kFullInstallerPattern, - &directory_list)) - return false; - file_util::AppendToPath(previous, directory_list.at(0).name_); - return (file_util::PathExists(previous->c_str())); -} - -// This method will return standalone installer file name. -bool ChromeMiniInstaller::GetStandaloneInstallerFileName( - file_info_list *file_name) { - std::wstring standalone_installer( - mini_installer_constants::kChromeStandAloneInstallerLocation); - standalone_installer.append(L"*.exe"); - return (GetLatestFile(standalone_installer.c_str(), - mini_installer_constants::kUntaggedInstallerPattern, - file_name)); -} - -// This method will get the version number from the filename. -bool ChromeMiniInstaller::GetStandaloneVersion(std::wstring* return_file_name) { - file_info_list file_details; - ChromeMiniInstaller::GetStandaloneInstallerFileName(&file_details); - std::wstring file_name = file_details.at(0).name_; - // Returned file name will have following convention: - // ChromeStandaloneSetup_<build>_<patch>.exe - // Following code will extract build, patch details from the file - // and concatenate with 1.0 to form the build version. - // Patteren followed: 1.0.<build>.<patch>htt - file_name = file_name.substr(22, 25); - std::wstring::size_type last_dot = file_name.find(L'.'); - 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"2.0." + file_name; - return_file_name->assign(file_name.c_str()); - printf("Standalone installer version is %ls\n", file_name.c_str()); - return true; -} - // Gets the path for uninstall. std::wstring ChromeMiniInstaller::GetUninstallPath() { std::wstring username, append_path, path, reg_key_value; @@ -728,8 +492,8 @@ void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path, base::LaunchApp(L"\"" + path + L"\"", false, false, NULL); } printf("Waiting while this process is running %ls ....\n", process_name); - VerifyProcessLaunch(process_name, true); - VerifyProcessClose(process_name); + MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); + ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(process_name)); } // Gets the path to launch Chrome. @@ -748,7 +512,7 @@ void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { if ((install_type_ == mini_installer_constants::kSystemInstall) && (!over_install)) CloseFirstRunUIDialog(over_install); - CloseProcesses(installer_util::kChromeExe); + MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); } // This method will get Chrome exe path and launch it. @@ -756,8 +520,9 @@ void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { std::wstring launch_path; GetChromeLaunchPath(&launch_path); base::LaunchApp(L"\"" + launch_path + L"\"", false, false, NULL); - PlatformThread::Sleep(400); - VerifyProcessLaunch(installer_util::kChromeExe, expected_status); + PlatformThread::Sleep(1000); + MiniInstallerTestUtil::VerifyProcessLaunch( + installer_util::kChromeExe, expected_status); } // This method compares the registry keys after overinstall. @@ -783,42 +548,10 @@ bool ChromeMiniInstaller::VerifyOverInstall( // This method will verify if the installed build is correct. bool ChromeMiniInstaller::VerifyStandaloneInstall() { std::wstring reg_key_value_returned, standalone_installer_version; - GetStandaloneVersion(&standalone_installer_version); + MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); GetChromeVersionFromRegistry(®_key_value_returned); if (standalone_installer_version.compare(reg_key_value_returned) == 0) return true; else return false; } -// Verifies if the process starts running. -void ChromeMiniInstaller::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 - ASSERT_EQ(0, base::GetProcessCount(process_name, NULL)); -} - -// Verifies if the process stops running. -void ChromeMiniInstaller::VerifyProcessClose( - const wchar_t* process_name) { - int timer = 0; - if (base::GetProcessCount(process_name, NULL) > 0) { - printf("\nWaiting for this process to end... %ls\n", process_name); - while ((base::GetProcessCount(process_name, NULL) > 0) && - (timer < 60000)) { - PlatformThread::Sleep(200); - timer = timer + 200; - } - } else { - ASSERT_EQ(0, base::GetProcessCount(process_name, NULL)); - } -} diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h index 565fef1..58d43fb2 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.h +++ b/chrome/test/mini_installer_test/chrome_mini_installer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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. @@ -6,41 +6,15 @@ #define CHROME_TEST_MINI_INSTALLER_TEST_CHROME_MINI_INSTALLER_H__ #include <windows.h> -#include <process.h> -#include <psapi.h> -#include <tlhelp32.h> -#include <tchar.h> -#include <errno.h> #include <string> -#include <vector> #include "base/basictypes.h" -// This structure holds the name and creation time -// details of all the chrome nightly builds. -class file_info { - public: - file_info() {} - file_info(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 file_info& creation_time_begin, - const file_info& creation_time_end); - - std::wstring name_; - int creation_time_; -}; -typedef std::vector<file_info> file_info_list; - // This class has methods to install and uninstall Chrome mini installer. class ChromeMiniInstaller { public: - explicit ChromeMiniInstaller(std::wstring install_type, - std::wstring build_type) { + explicit ChromeMiniInstaller(std::wstring install_type) { install_type_ = install_type; - build_channel_ = build_type; } ~ChromeMiniInstaller() {} @@ -50,22 +24,20 @@ class ChromeMiniInstaller { VERSION_FOLDER }; - // Closes specified process. - void CloseProcesses(const std::wstring& executable_name); - // This method returns path to either program files // or documents and setting based on the install type. 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(); @@ -78,23 +50,19 @@ 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 OverInstall(const wchar_t* channel_type); private: // This variable holds the install type. // Install type can be either system or user level. std::wstring install_type_; - // This variable holds the channel information. A dev build or stable build - // will be installed based on the build_channel_ value. - std::wstring build_channel_; - bool standalone_installer; // Will clean up the machine if Chrome install is messed up. @@ -103,20 +71,12 @@ class ChromeMiniInstaller { // Closes First Run UI dialog. void CloseFirstRunUIDialog(bool over_install); - // Close Window whose name is 'window_name', by sending Windows message - // 'message' to it. - bool CloseWindow(const wchar_t* window_name, UINT message); - // Closes Chrome uninstall confirm dialog window. bool CloseUninstallWindow(); // Closes Chrome browser. bool CloseChromeBrowser(); - // Change current directory so that chrome.dll from current folder - // will not be used as fall back. - void ChangeCurrentDirectory(std::wstring *current_path); - // Checks for registry key. bool CheckRegistryKey(const std::wstring& key_path); @@ -135,31 +95,6 @@ class ChromeMiniInstaller { // This method verifies Chrome shortcut. void FindChromeShortcut(); - // This method will create a command line to run apply tag. - bool GetCommandForTagging(std::wstring *return_command); - - // This method will get the latest installer based - // on the pattern argument passed. - bool GetInstaller(const wchar_t* pattern, std::wstring *name); - - // Gets path for the specified parameter. - std::wstring GetFilePath(const wchar_t* name); - - // This method will get the latest installer filename, - // based on the passed pattern argument. - bool GetLatestFile(const wchar_t* path, - const wchar_t* pattern, - file_info_list *file_name); - - // This method will get the previous full installer based on - // the diff installer file name argument. - bool GetPreviousFullInstaller(const std::wstring& diff_file, - std::wstring *previous); - - // This method will get the previous build number - void GetPreviousBuildNumber(const std::wstring& path, - std::wstring *build_number); - // Get HKEY based on install type. HKEY GetRootRegistryKey(); @@ -169,12 +104,6 @@ class ChromeMiniInstaller { // This method gets the shortcut path from start menu based on install type. std::wstring GetStartMenuShortcutPath(); - // This method will return standalone installer file name. - bool GetStandaloneInstallerFileName(file_info_list *file_name); - - // This method will get the version number from the filename. - bool GetStandaloneVersion(std::wstring* version); - // Get path for uninstall. std::wstring GetUninstallPath(); @@ -188,9 +117,6 @@ class ChromeMiniInstaller { void LaunchInstaller(const std::wstring& install_path, const wchar_t* process_name); - // This method will send enter key to window in the foreground. - void SendEnterKeyToWindow(); - // Verifies if Chrome launches after install. void LaunchAndCloseChrome(bool over_install); @@ -201,17 +127,12 @@ class ChromeMiniInstaller { // 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 std::wstring& diff_installer_name, + const wchar_t* channel_type); // This method will verify if the installed build is correct. bool VerifyStandaloneInstall(); - // Verifies if the given process starts running. - void VerifyProcessLaunch(const wchar_t* process_name, bool expected_status); - - // Verifies if the given process stops running. - void VerifyProcessClose(const wchar_t* process_name); - DISALLOW_COPY_AND_ASSIGN(ChromeMiniInstaller); }; diff --git a/chrome/test/mini_installer_test/mini_installer_test_constants.cc b/chrome/test/mini_installer_test/mini_installer_test_constants.cc index ccdc006..cbb4533 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_constants.cc +++ b/chrome/test/mini_installer_test/mini_installer_test_constants.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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. diff --git a/chrome/test/mini_installer_test/mini_installer_test_constants.h b/chrome/test/mini_installer_test/mini_installer_test_constants.h index 19de864..3cab711 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_constants.h +++ b/chrome/test/mini_installer_test/mini_installer_test_constants.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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. diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.cc b/chrome/test/mini_installer_test/mini_installer_test_util.cc new file mode 100644 index 0000000..9c511d1 --- /dev/null +++ b/chrome/test/mini_installer_test/mini_installer_test_util.cc @@ -0,0 +1,283 @@ +// 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 "chrome/test/mini_installer_test/mini_installer_test_util.h" + +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/platform_thread.h" +#include "base/process_util.h" +#include "base/string_util.h" +#include "base/time.h" +#include "chrome/installer/util/logging_installer.h" +#include "chrome/test/mini_installer_test/mini_installer_test_constants.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Change current directory so that chrome.dll from current folder +// will not be used as fall back. +bool MiniInstallerTestUtil::ChangeCurrentDirectory(std::wstring *current_path) { + wchar_t backup_path[MAX_PATH]; + DWORD ret = ::GetCurrentDirectory(MAX_PATH, backup_path); + if (ret == 0 && ret > MAX_PATH) + return false; + current_path->assign(backup_path); + file_util::UpOneDirectory(current_path); + ::SetCurrentDirectory(current_path->c_str()); + current_path->assign(backup_path); + return true; +} + +// Checks for all requested running processes and kills them. +void MiniInstallerTestUtil::CloseProcesses( + const std::wstring& executable_name) { + int timer = 0; + while ((base::GetProcessCount(executable_name, NULL) > 0) && + (timer < 20000)) { + base::KillProcesses(executable_name, 1, NULL); + PlatformThread::Sleep(200); + timer = timer + 200; + } + 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); + 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_); +} + +bool MiniInstallerTestUtil::GetCommandForTagging(std::wstring *return_command) { + FileInfoList file_details; + MiniInstallerTestUtil::GetStandaloneInstallerFileName(&file_details); + if (file_details.empty()) + return false; + if (file_details.at(0).name_.empty()) + return false; + std::wstring standalone_installer_path; + standalone_installer_path.assign( + mini_installer_constants::kChromeStandAloneInstallerLocation); + standalone_installer_path.append(file_details.at(0).name_); + return_command->append(mini_installer_constants::kChromeApplyTagExe); + return_command->append(L" "); + return_command->append(standalone_installer_path); + return_command->append(L" "); + return_command->append(mini_installer_constants::kStandaloneInstaller); + return_command->append(L" "); + return_command->append(mini_installer_constants::kChromeApplyTagParameters); + LOG(INFO) << "Command to run Apply tag: " << return_command->c_str(); + return true; +} + +std::wstring MiniInstallerTestUtil::GetFilePath(const wchar_t* exe_name) { + FilePath installer_path; + PathService::Get(base::DIR_EXE, &installer_path); + installer_path = installer_path.Append(exe_name); + LOG(INFO) << "Chrome exe path: " << installer_path.value().c_str(); + return installer_path.ToWStringHack(); +} + +// This method will first call GetLatestFile to get the list of all +// builds, sorted on creation time. Then goes through each build folder +// until it finds the installer file that matches the pattern argument. +bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, + std::wstring *path, const wchar_t* channel_type) { + FileInfoList builds_list; + 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_); + 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)) { + ++builds_list_size; + } else { + file_util::AppendToPath(path, exe_list.at(0).name_.c_str()); + if (!file_util::PathExists(*path)) { + ++builds_list_size; + } else { + break; + } + } + } + return (file_util::PathExists(path->c_str())); +} + +// 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) { + LOG(INFO) << "Handle is invalid."; + return false; + } + BOOL ret = TRUE; + bool return_val = false; + while (ret) { + std::wstring search_path = find_file_data.cFileName; + size_t position_found = search_path.find(pattern); + if (position_found != -1) { + std::wstring extension = file_util::GetFileExtensionFromPath(file_name); + if ((base::strcasecmp(WideToUTF8(extension).c_str(), "exe")) == 0) { + file_details->push_back(FileInfo(find_file_data.cFileName, 0)); + return_val = true; + break; + } else { + FILETIME file_time = find_file_data.ftCreationTime; + base::Time creation_time = base::Time::FromFileTime(file_time); + file_details->push_back(FileInfo(find_file_data.cFileName, + static_cast<int>(creation_time.ToDoubleT()))); + return_val = true; + } + } + ret = FindNextFile(file_handle, &find_file_data); + } + std::sort(file_details->rbegin(), file_details->rend(), &IsNewer); + FindClose(file_handle); + return return_val; +} + +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_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; + file_util::AppendToPath(previous, directory_list.at(0).name_); + return (file_util::PathExists(previous->c_str())); +} + +bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( + FileInfoList *file_name) { + std::wstring standalone_installer( + mini_installer_constants::kChromeStandAloneInstallerLocation); + standalone_installer.append(L"*.exe"); + return (GetLatestFile(standalone_installer.c_str(), + mini_installer_constants::kUntaggedInstallerPattern, + file_name)); +} + +bool MiniInstallerTestUtil::GetStandaloneVersion( + std::wstring* return_file_name) { + FileInfoList file_details; + GetStandaloneInstallerFileName(&file_details); + std::wstring file_name = file_details.at(0).name_; + // Returned file name will have following convention: + // ChromeStandaloneSetup_<build>_<patch>.exe + // Following code will extract build, patch details from the file + // and concatenate with 1.0 to form the build version. + // Patteren followed: 1.0.<build>.<patch>htt + file_name = file_name.substr(22, 25); + std::wstring::size_type last_dot = file_name.find(L'.'); + 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"2.0." + file_name; + return_file_name->assign(file_name.c_str()); + LOG(INFO) << "Standalone installer version: " << file_name.c_str(); + return true; +} + +void MiniInstallerTestUtil::SendEnterKeyToWindow() { + INPUT key; + key.type = INPUT_KEYBOARD; + key.ki.wVk = VK_RETURN; + key.ki.dwFlags = 0; + key.ki.time = 0; + key.ki.wScan = 0; + key.ki.dwExtraInfo = 0; + SendInput(1, &key, sizeof(INPUT)); + key.ki.dwExtraInfo = KEYEVENTF_KEYUP; + 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 + ASSERT_EQ(0, base::GetProcessCount(process_name, NULL)); +} + +bool MiniInstallerTestUtil::VerifyProcessClose( + const wchar_t* process_name) { + int timer = 0; + if (base::GetProcessCount(process_name, NULL) > 0) { + LOG(INFO) << "Waiting for this process to end: " << process_name; + while ((base::GetProcessCount(process_name, NULL) > 0) && + (timer < 60000)) { + PlatformThread::Sleep(200); + timer = timer + 200; + } + } else { + if (base::GetProcessCount(process_name, NULL) != 0) + return false; + } + return true; +} diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.h b/chrome/test/mini_installer_test/mini_installer_test_util.h new file mode 100644 index 0000000..8312dad --- /dev/null +++ b/chrome/test/mini_installer_test/mini_installer_test_util.h @@ -0,0 +1,100 @@ +// 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. +// +// This file declares utility functions for mini installer tests. +// The reason for putting these functions in different class is to separate out +// the critical logic from utility methods. + +#ifndef CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_UTIL_H_ +#define CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_UTIL_H_ + +#include <windows.h> +#include <vector> + +#include "base/basictypes.h" + +// 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 { + public: + // This method will change the current directory to one level up and + // return the new current path. + static bool ChangeCurrentDirectory(std::wstring *current_path); + + // 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); + + // This method will get the latest installer based on the passed 'pattern' and + // 'channel_type' arguments. The 'pattern' argument decides if the requested + // installer is full or differential. The 'channel_type' parameter decides if + // the build is stable/dev/beta. + static bool GetInstaller(const wchar_t* pattern, std::wstring *name, + const wchar_t* channel_type); + + // This method will create a command line to run apply tag. + static bool GetCommandForTagging(std::wstring *return_command); + + // 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 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, const wchar_t* channel_type); + + // This method will return standalone installer file name. + static bool GetStandaloneInstallerFileName(FileInfoList *file_name); + + // This method will get the version number from the filename. + static bool GetStandaloneVersion(std::wstring* version); + + // This method will send enter key to window in the foreground. + static void SendEnterKeyToWindow(); + + // Verifies if the given process starts running. + static void VerifyProcessLaunch(const wchar_t* process_name, + bool expected_status); + + // Verifies if the given process stops running. + static bool VerifyProcessClose(const wchar_t* process_name); + + private: + DISALLOW_EVIL_CONSTRUCTORS(MiniInstallerTestUtil); +}; + +#endif // CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_UTIL_H_ diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index 03ab03b..a957f9b 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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. @@ -14,8 +14,7 @@ void BackUpProfile() { "Please close Chrome and run the tests again.\n"); exit(1); } - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); std::wstring path = installer.GetChromeInstallDirectoryLocation(); file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); file_util::UpOneDirectory(&path); diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 4f0153f..6c93acb 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// 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/platform_thread.h" @@ -13,12 +13,10 @@ namespace { class MiniInstallTest : public testing::Test { protected: void CleanTheSystem() { - ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); + ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall); userinstall.UnInstall(); ChromeMiniInstaller systeminstall( - mini_installer_constants::kSystemInstall, - mini_installer_constants::kDevChannelBuild); + mini_installer_constants::kSystemInstall); systeminstall.UnInstall(); } virtual void SetUp() { @@ -45,149 +43,143 @@ class MiniInstallTest : public testing::Test { // previous installers accessible from our Google Chrome continuous buildbot. #if defined(OFFICIAL_BUILD) TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTest) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); - installer.InstallFullInstaller(false); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTestSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kDevChannelBuild); - installer.InstallFullInstaller(false); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTest) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kStableChannelBuild); - installer.InstallFullInstaller(false); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallFullInstaller(false, + mini_installer_constants::kStableChannelBuild); } TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTestSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.InstallFullInstaller(false, mini_installer_constants::kStableChannelBuild); - installer.InstallFullInstaller(false); } TEST_F(MiniInstallTest, InstallLatestDevFullInstallerOverPreviousFullDevInstaller) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall); + 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, - mini_installer_constants::kDevChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, InstallLatestDevDiffInstallerOverPreviousFullDevInstaller) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, InstallLatestDevDiffInstallerOverPreviousFullDevInstallerSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kDevChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, InstallLatestFullStableInstallerOverPreviousFullStableInstaller) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kStableChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kStableChannelBuild); } TEST_F(MiniInstallTest, InstallLatestFullStableInstallerOverPreviousFullStableInstallerSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kStableChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, + mini_installer_constants::kStableChannelBuild); } TEST_F(MiniInstallTest, InstallLatestDiffStableInstallerOverPreviousFullStableInstaller) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kStableChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kStableChannelBuild); } TEST_F(MiniInstallTest, InstallLatestDiffStableInstallerOverPreviousFullStableInstallerSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kStableChannelBuild); - installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, + mini_installer_constants::kStableChannelBuild); } TEST_F(MiniInstallTest, StandaloneInstallerTest) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kStableChannelBuild); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); installer.InstallStandaloneInstaller(); } // This test doesn't make sense. Disabling for now. TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); - installer.OverInstall(); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstall(mini_installer_constants::kDevChannelBuild); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kStableChannelBuild); - installer.OverInstall(); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.OverInstall(mini_installer_constants::kStableChannelBuild); } // Encountering issue 9593. Disabling temporarily. TEST_F(MiniInstallTest, DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); - installer.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, - mini_installer_constants::kDevChannelBuild); - installer.Repair(ChromeMiniInstaller::VERSION_FOLDER); + 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, - mini_installer_constants::kDevChannelBuild); - installer.Repair(ChromeMiniInstaller::VERSION_FOLDER); + 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, - mini_installer_constants::kDevChannelBuild); - installer.Repair(ChromeMiniInstaller::REGISTRY); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.Repair(ChromeMiniInstaller::REGISTRY, + mini_installer_constants::kDevChannelBuild); } TEST_F(MiniInstallTest, RepairRegistryTestOnLatestDevFullInstallerSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kDevChannelBuild); - installer.Repair(ChromeMiniInstaller::REGISTRY); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); + installer.Repair(ChromeMiniInstaller::REGISTRY, + mini_installer_constants::kDevChannelBuild); } #endif TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtSystemLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall, - mini_installer_constants::kDevChannelBuild); + ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); installer.Install(); } TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtUserLevel) { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall, - mini_installer_constants::kDevChannelBuild); + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); installer.Install(); } |