Commit 79829724 authored by grt@chromium.org's avatar grt@chromium.org

Delete old mini_installer_test.

And run the new Python-driven test_mini_installer on win_rel trybot.

BUG=277655

Review URL: https://codereview.chromium.org/301223007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274260 0039d316-1c4b-4281-b951-d872f2087c98
parent e79409fe
...@@ -1427,7 +1427,7 @@ def GetDefaultTryConfigs(bots=None): ...@@ -1427,7 +1427,7 @@ def GetDefaultTryConfigs(bots=None):
'gfx_unittests', 'gfx_unittests',
'google_apis_unittests', 'google_apis_unittests',
'installer_util_unittests', 'installer_util_unittests',
'mini_installer_test', 'test_mini_installer',
'nacl_integration', 'nacl_integration',
'remoting_unittests', 'remoting_unittests',
'sync_integration_tests', 'sync_integration_tests',
......
...@@ -301,9 +301,7 @@ ...@@ -301,9 +301,7 @@
'dependencies': [ 'dependencies': [
'../chrome/chrome.gyp:crash_service', '../chrome/chrome.gyp:crash_service',
'../chrome/chrome.gyp:installer_util_unittests', '../chrome/chrome.gyp:installer_util_unittests',
'../chrome/chrome.gyp:mini_installer_test', # ../chrome/test/mini_installer requires mini_installer.
# mini_installer_tests depends on mini_installer. This should be
# defined in installer.gyp.
'../chrome/installer/mini_installer.gyp:mini_installer', '../chrome/installer/mini_installer.gyp:mini_installer',
'../chrome_elf/chrome_elf.gyp:chrome_elf_unittests', '../chrome_elf/chrome_elf.gyp:chrome_elf_unittests',
'../content/content_shell_and_tests.gyp:copy_test_netscape_plugin', '../content/content_shell_and_tests.gyp:copy_test_netscape_plugin',
...@@ -958,7 +956,6 @@ ...@@ -958,7 +956,6 @@
'../chrome/chrome.gyp:gcapi_test', '../chrome/chrome.gyp:gcapi_test',
'../chrome/chrome.gyp:installer_util_unittests', '../chrome/chrome.gyp:installer_util_unittests',
'../chrome/chrome.gyp:interactive_ui_tests', '../chrome/chrome.gyp:interactive_ui_tests',
'../chrome/chrome.gyp:mini_installer_test',
'../chrome/chrome.gyp:performance_browser_tests', '../chrome/chrome.gyp:performance_browser_tests',
'../chrome/chrome.gyp:sync_integration_tests', '../chrome/chrome.gyp:sync_integration_tests',
'../chrome/chrome.gyp:unit_tests', '../chrome/chrome.gyp:unit_tests',
...@@ -967,8 +964,7 @@ ...@@ -967,8 +964,7 @@
'../content/content_shell_and_tests.gyp:content_browsertests', '../content/content_shell_and_tests.gyp:content_browsertests',
'../content/content_shell_and_tests.gyp:content_unittests', '../content/content_shell_and_tests.gyp:content_unittests',
'../content/content_shell_and_tests.gyp:copy_test_netscape_plugin', '../content/content_shell_and_tests.gyp:copy_test_netscape_plugin',
# mini_installer_tests depends on mini_installer. This should be # ../chrome/test/mini_installer requires mini_installer.
# defined in installer.gyp.
'../chrome/installer/mini_installer.gyp:mini_installer', '../chrome/installer/mini_installer.gyp:mini_installer',
'../courgette/courgette.gyp:courgette_unittests', '../courgette/courgette.gyp:courgette_unittests',
'../device/device_tests.gyp:device_unittests', '../device/device_tests.gyp:device_unittests',
......
...@@ -210,44 +210,6 @@ ...@@ -210,44 +210,6 @@
'installer/launcher_support/chrome_launcher_support.h', 'installer/launcher_support/chrome_launcher_support.h',
], ],
}, },
{
'target_name': 'mini_installer_test',
'type': 'executable',
'dependencies': [
'installer_util',
'installer_util_strings',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
'../chrome/chrome.gyp:test_support_common',
'../testing/gtest.gyp:gtest',
],
'include_dirs': [
'..',
],
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/installer_util_strings/installer_util_strings.rc',
'installer/util/installation_validation_helper.cc',
'installer/util/installation_validation_helper.h',
'test/mini_installer_test/installer_path_provider.cc',
'test/mini_installer_test/installer_path_provider.h',
'test/mini_installer_test/installer_test_util.cc',
'test/mini_installer_test/installer_test_util.h',
'test/mini_installer_test/mini_installer_test_constants.cc',
'test/mini_installer_test/mini_installer_test_constants.h',
'test/mini_installer_test/run_all_unittests.cc',
'test/mini_installer_test/switch_builder.cc',
'test/mini_installer_test/switch_builder.h',
'test/mini_installer_test/test.cc',
],
'msvs_settings': {
'VCManifestTool': {
'AdditionalManifestFiles': [
'$(ProjectDir)\\installer\\mini_installer\\mini_installer.exe.manifest',
],
},
},
},
{ {
'target_name': 'setup', 'target_name': 'setup',
'type': 'executable', 'type': 'executable',
......
// Copyright (c) 2012 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/installer_path_provider.h"
#include <algorithm>
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_enumerator.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/test/mini_installer_test/installer_test_util.h"
#include "chrome/test/mini_installer_test/mini_installer_test_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
struct FilePathInfo {
base::FileEnumerator::FileInfo info;
base::FilePath path;
};
bool CompareDate(const FilePathInfo& a, const FilePathInfo& b) {
return a.info.GetLastModifiedTime() > b.info.GetLastModifiedTime();
}
// Get list of file |type| matching |pattern| in |root|.
// The list is sorted in last modified date order.
// Return true if files/directories are found.
bool FindMatchingFiles(const base::FilePath& root,
const std::string& pattern,
base::FileEnumerator::FileType type,
std::vector<base::FilePath>* paths) {
base::FileEnumerator files(root, false, type,
base::FilePath().AppendASCII(pattern).value());
std::vector<FilePathInfo> matches;
for (base::FilePath current = files.Next(); !current.empty();
current = files.Next()) {
FilePathInfo entry;
entry.info = files.GetInfo();
entry.path = current;
matches.push_back(entry);
}
if (matches.empty())
return false;
std::sort(matches.begin(), matches.end(), CompareDate);
std::vector<FilePathInfo>::iterator current;
for (current = matches.begin(); current != matches.end(); ++current) {
paths->push_back(current->path);
}
return true;
}
bool FindNewestMatchingFile(const base::FilePath& root,
const std::string& pattern,
base::FileEnumerator::FileType type,
base::FilePath* path) {
std::vector<base::FilePath> paths;
if (FindMatchingFiles(root, pattern, type, &paths)) {
*path = paths[0];
return true;
}
return false;
}
} // namespace
namespace installer_test {
InstallerPathProvider::InstallerPathProvider() {
base::FilePath full_installer, previous_installer;
if (!GetFullInstaller(&full_installer) ||
!GetPreviousInstaller(&previous_installer))
return;
current_build_ =
full_installer.DirName().DirName().BaseName().MaybeAsASCII();
previous_build_ =
previous_installer.DirName().DirName().BaseName().MaybeAsASCII();
}
InstallerPathProvider::InstallerPathProvider(
const std::string& build_under_test) : current_build_(build_under_test) {
base::FilePath full_installer, previous_installer;
if (!GetFullInstaller(&full_installer) ||
!GetPreviousInstaller(&previous_installer))
return;
previous_build_ =
previous_installer.DirName().DirName().BaseName().MaybeAsASCII();
}
InstallerPathProvider::~InstallerPathProvider() {}
bool InstallerPathProvider::GetFullInstaller(base::FilePath* path) {
std::string full_installer_pattern("*_chrome_installer*");
return GetInstaller(full_installer_pattern, path);
}
bool InstallerPathProvider::GetDiffInstaller(base::FilePath* path) {
std::string diff_installer_pattern("*_from_*");
return GetInstaller(diff_installer_pattern, path);
}
bool InstallerPathProvider::GetMiniInstaller(base::FilePath* path) {
// Use local copy of installer, else fall back to filer.
base::FilePath mini_installer = PathFromExeDir(
mini_installer_constants::kChromeMiniInstallerExecutable);
if (base::PathExists(mini_installer)) {
*path = mini_installer;
return true;
}
std::string mini_installer_pattern("mini_installer.exe");
return GetInstaller(mini_installer_pattern, path);
}
bool InstallerPathProvider::GetPreviousInstaller(base::FilePath* path) {
std::string diff_installer_pattern("*_from_*");
std::string full_installer_pattern("*_chrome_installer*");
base::FilePath diff_installer;
if (!GetInstaller(diff_installer_pattern, &diff_installer))
return false;
base::FilePath previous_installer;
std::vector<std::string> tokenized_name;
Tokenize(diff_installer.BaseName().MaybeAsASCII(),
"_", &tokenized_name);
std::string build_pattern = base::StringPrintf(
"*%s", tokenized_name[2].c_str());
std::vector<base::FilePath> previous_build;
if (FindMatchingFiles(diff_installer.DirName().DirName().DirName(),
build_pattern, base::FileEnumerator::DIRECTORIES,
&previous_build)) {
base::FilePath windir = previous_build.at(0).Append(
mini_installer_constants::kWinFolder);
FindNewestMatchingFile(windir, full_installer_pattern,
base::FileEnumerator::FILES, &previous_installer);
}
if (previous_installer.empty())
return false;
*path = previous_installer;
return true;
}
bool InstallerPathProvider::GetStandaloneInstaller(base::FilePath* path) {
// Get standalone installer.
base::FilePath standalone_installer(
mini_installer_constants::kChromeStandAloneInstallerLocation);
// Get the file name.
std::vector<std::string> tokenized_build_number;
if (current_build_.empty())
return false;
Tokenize(current_build_, ".", &tokenized_build_number);
std::string standalone_installer_filename = base::StringPrintf(
"%s%s_%s.exe",
base::FilePath(mini_installer_constants::kUntaggedInstallerPattern)
.MaybeAsASCII().c_str(),
tokenized_build_number[2].c_str(),
tokenized_build_number[3].c_str());
standalone_installer = standalone_installer.AppendASCII(current_build_)
.Append(mini_installer_constants::kWinFolder)
.AppendASCII(standalone_installer_filename);
*path = standalone_installer;
return base::PathExists(standalone_installer);
}
bool InstallerPathProvider::GetSignedStandaloneInstaller(base::FilePath* path) {
base::FilePath standalone_installer;
if (!GetStandaloneInstaller(&standalone_installer))
return false;
base::FilePath tagged_installer = PathFromExeDir(
mini_installer_constants::kStandaloneInstaller);
CommandLine sign_command = CommandLine::FromString(
base::StringPrintf(L"%ls %ls %ls %ls",
mini_installer_constants::kChromeApplyTagExe,
standalone_installer.value().c_str(),
tagged_installer.value().c_str(),
mini_installer_constants::kChromeApplyTagParameters));
if (!installer_test::RunAndWaitForCommandToFinish(sign_command))
return false;
*path = PathFromExeDir(mini_installer_constants::kStandaloneInstaller);
return true;
}
base::FilePath InstallerPathProvider::PathFromExeDir(
const base::FilePath::StringType& name) {
base::FilePath path;
PathService::Get(base::DIR_EXE, &path);
path = path.Append(name);
return path;
}
bool InstallerPathProvider::GetInstaller(const std::string& pattern,
base::FilePath* path) {
base::FilePath installer;
// Search filer for installer binary.
base::FilePath root(mini_installer_constants::kChromeInstallersLocation);
std::vector<base::FilePath> paths;
if (!FindMatchingFiles(root, current_build_,
base::FileEnumerator::DIRECTORIES, &paths)) {
return false;
}
std::vector<base::FilePath>::const_iterator dir;
for (dir = paths.begin(); dir != paths.end(); ++dir) {
base::FilePath windir = dir->Append(
mini_installer_constants::kWinFolder);
if (FindNewestMatchingFile(windir, pattern, base::FileEnumerator::FILES,
&installer)) {
break;
}
}
if (installer.empty()) {
LOG(WARNING) << "Failed to find installer with pattern: " << pattern;
return false;
}
*path = installer;
return true;
}
std::string InstallerPathProvider::GetCurrentBuild() {
return current_build_;
}
std::string InstallerPathProvider::GetPreviousBuild() {
return previous_build_;
}
} // namespace
// Copyright (c) 2012 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.
#ifndef CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_PATH_PROVIDER_H_
#define CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_PATH_PROVIDER_H_
#include "base/basictypes.h"
#include "base/files/file_path.h"
namespace installer_test {
// Locate and provides path for installers.
// Search for latest installer binaries in the filer directory defined by
// mini_installer_constants::kChromeInstallersLocation.
class InstallerPathProvider {
public:
// Search for latest installer binaries in filer.
InstallerPathProvider();
explicit InstallerPathProvider(const std::string& build_under_test);
~InstallerPathProvider();
bool GetFullInstaller(base::FilePath* path);
bool GetDiffInstaller(base::FilePath* path);
bool GetMiniInstaller(base::FilePath* path);
bool GetPreviousInstaller(base::FilePath* path);
bool GetStandaloneInstaller(base::FilePath* path);
bool GetSignedStandaloneInstaller(base::FilePath* path);
std::string GetCurrentBuild();
std::string GetPreviousBuild();
private:
// Returns the local file path for the given file |name|.
// Assumes file is located in the current working directory.
base::FilePath PathFromExeDir(const base::FilePath::StringType& name);
bool GetInstaller(const std::string& pattern, base::FilePath* path);
// Build numbers.
std::string current_build_, previous_build_;
DISALLOW_COPY_AND_ASSIGN(InstallerPathProvider);
};
} // namespace
#endif // CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_PATH_PROVIDER_H_
This diff is collapsed.
// Copyright (c) 2012 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.
#ifndef CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_
#define CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_
#include <vector>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "chrome/installer/util/installation_validator.h"
#include "chrome/test/mini_installer_test/switch_builder.h"
namespace installer_test {
struct InstalledProduct {
std::string version;
installer::InstallationValidator::InstallationType type;
bool system;
};
// Utility functions used to test Chrome installation.
// Deletes the Chrome installation directory which is found at different
// locations depending on the |system_level| and |type|.
// Returns true if successful, otherwise false.
bool DeleteInstallDirectory(
bool system_level,
installer::InstallationValidator::InstallationType type);
// Deletes the Chrome Windows registry entry.
// Returns true if successful, otherwise false.
bool DeleteRegistryKey(
bool system_level,
installer::InstallationValidator::InstallationType type,
REGSAM wow64_access);
// Locates the Chrome installation directory based on the
// provided |system_level|. Returns true if successful, otherwise false.
// Returns true if successful, otherwise false.
bool GetChromeInstallDirectory(bool system_level, base::FilePath* path);
// Gets the installation directory of either Chrome or Chrome Frame
// as specified by the |system_level| and |type|.
// Returns true if successful, otherwise false.
bool GetInstallDirectory(bool system_level,
BrowserDistribution::Type type, base::FilePath* path);
// Returns the version of the specified |product|.
std::string GetVersion(
installer::InstallationValidator::InstallationType product);
// Gets a list of installed products.
// Returns true if there are installed products.
bool GetInstalledProducts(std::vector<InstalledProduct>* products);
bool Install(const base::FilePath& installer);
bool Install(const base::FilePath& installer, const SwitchBuilder& switches);
bool LaunchChrome(bool close_after_launch, bool system_level);
bool LaunchIE(const std::string& url);
// Uninstall all Chrome or Chrome Frame installations.
bool UninstallAll();
// Uninstall the product specified by |system_level| and |type|.
bool Uninstall(
bool system_level,
installer::InstallationValidator::InstallationType type);
// Uninstall the product specified by |system_level| and |product|.
bool Uninstall(
bool system_level,
BrowserDistribution::Type product);
bool ValidateInstall(
bool system_level,
installer::InstallationValidator::InstallationType expected,
const std::string& version);
// Run and wait for command to finish.
// Returns true if successful, otherwise false.
bool RunAndWaitForCommandToFinish(base::CommandLine command);
} // namespace installer_test
#endif // CHROME_TEST_MINI_INSTALLER_TEST_INSTALLER_TEST_UTIL_H_
// Copyright (c) 2011 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_constants.h"
namespace mini_installer_constants {
#if defined(GOOGLE_CHROME_BUILD)
const wchar_t kChromeAppDir[] = L"Google\\Chrome\\Application\\";
const wchar_t kChromeBuildType[] = L"Google Chrome";
const wchar_t kChromeFirstRunUI[] = L"Welcome to Google Chrome";
const wchar_t kChromeLaunchShortcut[] = L"Google Chrome.lnk";
const wchar_t kChromeUninstallShortcut[] = L"Uninstall Google Chrome.lnk";
const wchar_t kChromeUninstallDialogName[] = L"Uninstall Google Chrome";
#else
const wchar_t kChromeAppDir[] = L"Chromium\\Application\\";
const wchar_t kChromeBuildType[] = L"Chromium";
const wchar_t kChromeFirstRunUI[] = L"Welcome to Chromium";
const wchar_t kChromeLaunchShortcut[] = L"Chromium.lnk";
const wchar_t kChromeUninstallShortcut[] = L"Uninstall Chromium.lnk";
const wchar_t kChromeUninstallDialogName[] = L"Uninstall Chromium";
#endif
const wchar_t kBrowserTabName[] = L"New Tab - Google Chrome";
const wchar_t kChromeFrameAppDir[] = L"Google\\Chrome Frame\\Application\\";
const wchar_t kChromeFrameAppName[] = L"Google Chrome Frame";
const wchar_t kChromeFrameProductName[] = L"Chrome Frame";
const wchar_t kChromeMiniInstallerExecutable[] = L"mini_installer.exe";
const wchar_t kChromeMetaInstallerExecutable[] = L"chrome_installer.exe";
const wchar_t kChromeProductName[] = L"Chrome";
const wchar_t kChromeSetupExecutable[] = L"setup.exe";
const wchar_t kChromeUserDataBackupDir[] = L"User Data Copy";
const wchar_t kChromeUserDataDir[] = L"User Data";
const wchar_t kDiffInstall[] = L"Diff";
const wchar_t kDiffInstallerPattern[] = L"_from_";
const wchar_t kFullInstallerPattern[] = L"_chrome_installer";
const wchar_t kGoogleUpdateExecutable[] = L"GoogleUpdate.exe";
const wchar_t kIEExecutable[] = L"iexplore.exe";
const wchar_t kInstallerWindow[] = L"Chrome Installer";
const wchar_t kStandaloneInstaller[] = L"ChromeSetupTest.exe";
const wchar_t kUntaggedInstallerPattern[] = L"ChromeStandaloneSetup_";
const wchar_t kWinFolder[] = L"win";
const wchar_t kDevChannelBuild[] = L"10.0.";
const wchar_t kStableChannelBuild[] = L"8.0.";
const wchar_t kFullInstall[] = L"Full";
const wchar_t kIELocation[] = L"Internet Explorer\\";
const wchar_t kIEProcessName[] = L"IEXPLORE.EXE";
// Google Chrome meta installer location.
const wchar_t kChromeMetaInstallerExe[] =
L"\\\\172.23.44.61\\shared\\chrome_autotest\\beta_build\\ChromeSetup.exe";
const wchar_t kChromeStandAloneInstallerLocation[] =
L"\\\\filer\\shares\\chromeclient\\builds\\ChromeSigning";
const wchar_t kChromeApplyTagExe[] =
L"\\\\filer\\shares\\googleclient\\save\\builds\\Omaha\\1.3.21.57"
L"\\opt\\tests\\ApplyTag.exe";
const wchar_t kChromeApplyTagParameters[] =
L"\"appguid={8A69D345-D564-463C-AFF1-A69D9E530F96}"
L"&appname=Chrome&needsadmin=false\"";
const wchar_t kChromeInstallersLocation[] =
L"\\\\172.24.6.7\\shares\\chromeclient\\builds\\chrome\\";
} // namespace mini_installer_constants
namespace switches {
// Help.
extern const char kInstallerHelp[] = "help";
// Back up the profile.
const char kInstallerTestBackup[] = "backup";
// Control the build under test.
const char kInstallerTestBuild[] = "build";
// Force the installer tests to run, regardless of the current platform.
const char kInstallerTestForce[] = "force";
} // namespace switches
// Copyright (c) 2011 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.
// Constants related to the Chrome mini installer testing.
#ifndef CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_CONSTANTS_H__
#define CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_CONSTANTS_H__
namespace mini_installer_constants {
// Path and process names
extern const wchar_t kChromeAppDir[];
extern const wchar_t kChromeFrameAppDir[];
extern const wchar_t kChromeFrameProductName[];
extern const wchar_t kChromeMetaInstallerExecutable[];
extern const wchar_t kChromeProductName[];
extern const wchar_t kChromeMiniInstallerExecutable[];
extern const wchar_t kChromeSetupExecutable[];
extern const wchar_t kChromeUserDataBackupDir[];
extern const wchar_t kChromeUserDataDir[];
extern const wchar_t kDiffInstall[];
extern const wchar_t kDiffInstallerPattern[];
extern const wchar_t kFullInstall[];
extern const wchar_t kFullInstallerPattern[];
extern const wchar_t kGoogleUpdateExecutable[];
extern const wchar_t kIEExecutable[];
extern const wchar_t kWinFolder[];
// Window names.
extern const wchar_t kBrowserTabName[];
extern const wchar_t kChromeBuildType[];
extern const wchar_t kChromeFrameAppName[];
extern const wchar_t kChromeFirstRunUI[];
extern const wchar_t kChromeUninstallDialogName[];
extern const wchar_t kInstallerWindow[];
// Shortcut names
extern const wchar_t kChromeLaunchShortcut[];
extern const wchar_t kChromeUninstallShortcut[];
// Chrome install types
extern const wchar_t kStandaloneInstaller[];
extern const wchar_t kUntaggedInstallerPattern[];
// Channel types
extern const wchar_t kDevChannelBuild[];
extern const wchar_t kStableChannelBuild[];
extern const wchar_t kIELocation[];
extern const wchar_t kIEProcessName[];
// Google Chrome meta installer location.
extern const wchar_t kChromeApplyTagExe[];
extern const wchar_t kChromeApplyTagParameters[];
extern const wchar_t kChromeInstallersLocation[];
extern const wchar_t kChromeMetaInstallerExe[];
extern const wchar_t kChromeStandAloneInstallerLocation[];
} // namespace mini_installer_constants
// Command line switches.
namespace switches {
extern const char kInstallerHelp[];
extern const char kInstallerTestBackup[];
extern const char kInstallerTestBuild[];
extern const char kInstallerTestForce[];
} // namespace switches
#endif // CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_CONSTANTS_H__
// Copyright (c) 2012 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/file_util.h"
#include "base/process/process_iterator.h"
#include "base/test/test_suite.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.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/installer_test_util.h"
void BackUpProfile(bool chrome_frame) {
if (base::GetProcessCount(L"chrome.exe", NULL) > 0) {
printf("Chrome is currently running and cannot backup the profile."
"Please close Chrome and run the tests again.\n");
exit(1);
}
base::FilePath path;
installer_test::GetChromeInstallDirectory(false /* system_level */, &path);
path = path.Append(mini_installer_constants::kChromeAppDir).DirName();
base::FilePath backup_path = path;
// Will hold User Data path that needs to be backed-up.
path = path.Append(mini_installer_constants::kChromeUserDataDir);
// Will hold new backup path to save the profile.
backup_path = backup_path.Append(
mini_installer_constants::kChromeUserDataBackupDir);
// Will check if User Data profile is available.
if (base::PathExists(path)) {
// Will check if User Data is already backed up.
// If yes, will delete and create new one.
if (base::PathExists(backup_path))
base::DeleteFile(backup_path, true);
base::CopyDirectory(path, backup_path, true);
} else {
printf("Chrome is not installed. Will not take any backup\n");
}
}
int main(int argc, char** argv) {
// Check command line to decide if the tests should continue
// with cleaning the system or make a backup before continuing.
CommandLine::Init(argc, argv);
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
base::TestSuite test_suite(argc, argv);
if (command_line.HasSwitch(switches::kInstallerHelp)) {
printf("This test needs command line arguments.\n");
printf("Usage: %ls [-backup] [-build <version>] [-force] \n",
command_line.GetProgram().value().c_str());
printf("-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;
}
if (command_line.HasSwitch(switches::kInstallerTestBackup)) {
BackUpProfile(command_line.HasSwitch(
installer::switches::kChromeFrame));
}
if (base::win::GetVersion() < base::win::VERSION_VISTA ||
command_line.HasSwitch(switches::kInstallerTestForce)) {
return test_suite.Run();
}
printf("These tests don't run on this platform.\n");
return 0;
}
// Copyright (c) 2012 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/switch_builder.h"
#include "chrome/installer/util/install_util.h"
namespace installer_test {
SwitchBuilder::SwitchBuilder()
: switches_(CommandLine::NO_PROGRAM) {}
SwitchBuilder::~SwitchBuilder() {}
const CommandLine& SwitchBuilder::GetSwitches() const {
return switches_;
}
SwitchBuilder& SwitchBuilder::AddChrome() {
switches_.AppendSwitch(installer::switches::kChrome);
return *this;
}
SwitchBuilder& SwitchBuilder::AddChromeFrame() {
switches_.AppendSwitch(installer::switches::kChromeFrame);
switches_.AppendSwitch(installer::switches::kDoNotLaunchChrome);
switches_.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch);
return *this;
}
SwitchBuilder& SwitchBuilder::AddMultiInstall() {
switches_.AppendSwitch(installer::switches::kMultiInstall);
return *this;
}
SwitchBuilder& SwitchBuilder::AddSystemInstall() {
switches_.AppendSwitch(installer::switches::kSystemLevel);
return *this;
}
} // namespace
// Copyright (c) 2012 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.
#ifndef CHROME_TEST_MINI_INSTALLER_TEST_SWITCH_BUILDER_H_
#define CHROME_TEST_MINI_INSTALLER_TEST_SWITCH_BUILDER_H_
#include "base/basictypes.h"
#include "base/command_line.h"
namespace installer_test {
// Builds commandline arguments for Chrome installation.
class SwitchBuilder {
public:
SwitchBuilder();
~SwitchBuilder();
const base::CommandLine& GetSwitches() const;
SwitchBuilder& AddChrome();
SwitchBuilder& AddChromeFrame();
SwitchBuilder& AddMultiInstall();
SwitchBuilder& AddSystemInstall();
private:
base::CommandLine switches_;
DISALLOW_COPY_AND_ASSIGN(SwitchBuilder);
};
} // namespace
#endif // CHROME_TEST_MINI_INSTALLER_TEST_SWITCH_BUILDER_H_
This diff is collapsed.
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
{"test": "browser_tests", "shard_index": 0, "total_shards": 3}, {"test": "browser_tests", "shard_index": 0, "total_shards": 3},
"content_browsertests", "content_browsertests",
"installer_util_unittests", "installer_util_unittests",
"mini_installer_test",
"webkit_compositor_bindings_unittests" "webkit_compositor_bindings_unittests"
] ]
}, },
...@@ -79,7 +78,6 @@ ...@@ -79,7 +78,6 @@
{"test": "browser_tests", "shard_index": 0, "total_shards": 3}, {"test": "browser_tests", "shard_index": 0, "total_shards": 3},
"content_browsertests", "content_browsertests",
"installer_util_unittests", "installer_util_unittests",
"mini_installer_test",
"webkit_compositor_bindings_unittests" "webkit_compositor_bindings_unittests"
] ]
}, },
...@@ -146,7 +144,6 @@ ...@@ -146,7 +144,6 @@
{"test": "browser_tests", "shard_index": 0, "total_shards": 3}, {"test": "browser_tests", "shard_index": 0, "total_shards": 3},
"content_browsertests", "content_browsertests",
"installer_util_unittests", "installer_util_unittests",
"mini_installer_test",
"webkit_compositor_bindings_unittests" "webkit_compositor_bindings_unittests"
] ]
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment