summaryrefslogtreecommitdiffstats
path: root/chrome/test/mini_installer_test
diff options
context:
space:
mode:
authorrickcam@chromium.org <rickcam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 00:26:07 +0000
committerrickcam@chromium.org <rickcam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 00:26:07 +0000
commit2eed2e3dbfd35e159896b022445669f8b5e1d311 (patch)
treed1874c70611b7529b9c6b245641a138d6f553bf6 /chrome/test/mini_installer_test
parent397bba74e3674b0f80c209b89735e615fe7979f9 (diff)
downloadchromium_src-2eed2e3dbfd35e159896b022445669f8b5e1d311.zip
chromium_src-2eed2e3dbfd35e159896b022445669f8b5e1d311.tar.gz
chromium_src-2eed2e3dbfd35e159896b022445669f8b5e1d311.tar.bz2
Revert "Adding simple Chrome install testing using multi-install and cleaning up a bit."
This reverts commit f53d32099f0e70705a1e935f92c8e9f378fdadd2. BUG=none TEST=none Review URL: http://codereview.chromium.org/8075001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/mini_installer_test')
-rw-r--r--chrome/test/mini_installer_test/chrome_mini_installer.cc355
-rw-r--r--chrome/test/mini_installer_test/chrome_mini_installer.h39
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test_constants.cc3
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test_constants.h3
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test_util.cc1
-rw-r--r--chrome/test/mini_installer_test/run_all_unittests.cc7
-rw-r--r--chrome/test/mini_installer_test/test.cc28
7 files changed, 244 insertions, 192 deletions
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc
index fba75d1..08d8ec6 100644
--- a/chrome/test/mini_installer_test/chrome_mini_installer.cc
+++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc
@@ -18,17 +18,12 @@
#include "base/win/registry.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
-#include "chrome/installer/util/helper.h"
-#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installation_validation_helper.h"
-#include "chrome/installer/util/util_constants.h"
-#include "chrome/test/base/chrome_process_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"
using base::win::RegKey;
-using installer::InstallationValidator;
namespace {
@@ -95,10 +90,10 @@ bool FindNewestMatchingFile(const FilePath& root,
} // namespace
-ChromeMiniInstaller::ChromeMiniInstaller(bool system_install,
+ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type,
bool is_chrome_frame)
: is_chrome_frame_(is_chrome_frame),
- system_install_(system_install) {}
+ install_type_(install_type) {}
void ChromeMiniInstaller::SetBuildUnderTest(
const std::wstring& build) {
@@ -109,7 +104,9 @@ void ChromeMiniInstaller::SetBuildUnderTest(
// Installs Chrome.
void ChromeMiniInstaller::Install() {
- InstallMiniInstaller(false, mini_installer_);
+ FilePath installer_path = MiniInstallerTestUtil::GetFilePath(
+ mini_installer_constants::kChromeMiniInstallerExecutable);
+ InstallMiniInstaller(false, installer_path);
}
// This method will get the previous latest full installer from
@@ -167,38 +164,20 @@ void ChromeMiniInstaller::InstallFullInstaller(bool over_install) {
// Installs the Chrome mini-installer, checks the registry and shortcuts.
void ChromeMiniInstaller::InstallMiniInstaller(bool over_install,
const FilePath& path) {
- LOG(INFO) << "Install level is: "
- << (system_install_ ? "system" : "user");
- RunInstaller(CommandLine(path));
-
- std::wstring version;
- ASSERT_TRUE(GetChromeVersionFromRegistry(&version))
- << "Install failed: unable to get version.";
+ LOG(INFO) << "Chrome will be installed at "
+ << install_type_ << "level.";
+ LOG(INFO) << "Will proceed with the test only if this path exists: "
+ << path.value();
+
+ ASSERT_TRUE(file_util::PathExists(path)) << path.value()
+ << " does not exist.";
+ LaunchInstaller(path, path.BaseName().value().c_str());
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())) << dist->GetVersionKey()
+ << " does not exist.";
VerifyInstall(over_install);
}
-void ChromeMiniInstaller::InstallUsingMultiInstall() {
- ASSERT_TRUE(file_util::PathExists(mini_installer_));
- CommandLine cmd(mini_installer_);
- cmd.AppendSwitch(installer::switches::kMultiInstall);
- cmd.AppendSwitch(installer::switches::kChrome);
- RunInstaller(cmd);
-
- // Verify installation.
- InstallationValidator::InstallationType type =
- installer::ExpectValidInstallation(system_install_);
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_));
- if (is_chrome_frame_) {
- EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI);
- VerifyChromeFrameInstall();
- } else {
- EXPECT_TRUE(type & InstallationValidator::ProductBits::CHROME_MULTI);
- }
- FindChromeShortcut();
- LaunchChrome(false);
-}
-
// This method tests the standalone installer by verifying the steps listed at:
// https://sites.google.com/a/google.com/chrome-pmo/
// standalone-installers/testing-standalone-installers
@@ -239,12 +218,10 @@ CommandLine ChromeMiniInstaller::GetCommandForTagging() {
// checks the registry and shortcuts.
void ChromeMiniInstaller::InstallMetaInstaller() {
// Install Google Chrome through meta installer.
- CommandLine installer(FilePath::FromWStringHack(
- mini_installer_constants::kChromeMetaInstallerExe));
- RunInstaller(installer);
+ LaunchInstaller(FilePath(mini_installer_constants::kChromeMetaInstallerExe),
+ mini_installer_constants::kChromeSetupExecutable);
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"\\");
@@ -255,7 +232,7 @@ void ChromeMiniInstaller::InstallMetaInstaller() {
ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key));
ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey()));
FindChromeShortcut();
- LaunchChrome(true);
+ LaunchAndCloseChrome(false);
}
// If the build type is Google Chrome, then it first installs meta installer
@@ -297,10 +274,10 @@ void ChromeMiniInstaller::Repair(
}
FilePath current_path;
ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(&current_path));
- LaunchChrome(false);
- LOG(INFO) << "Installing Chrome again to see if it can be repaired.";
+ VerifyChromeLaunch(false);
+ printf("\nInstalling Chrome again to see if it can be repaired\n\n");
InstallFullInstaller(true);
- LOG(INFO) << "Chrome repair successful.";
+ printf("Chrome repair successful.\n");
// Set the current directory back to original path.
file_util::SetCurrentDirectory(current_path);
}
@@ -314,14 +291,16 @@ void ChromeMiniInstaller::Repair(
// Deletes App dir.
// Closes feedback form.
void ChromeMiniInstaller::UnInstall() {
+ std::wstring product_name;
+ if (is_chrome_frame_)
+ product_name = mini_installer_constants::kChromeFrameProductName;
+ else
+ product_name = mini_installer_constants::kChromeProductName;
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- std::wstring version;
- std::string result;
-
- if (!GetChromeVersionFromRegistry(&version))
+ if (!CheckRegistryKey(dist->GetVersionKey())) {
+ printf("%ls is not installed.\n", product_name.c_str());
return;
-
- // Close running products.
+ }
if (is_chrome_frame_) {
MiniInstallerTestUtil::CloseProcesses(
mini_installer_constants::kIEProcessName);
@@ -329,30 +308,29 @@ void ChromeMiniInstaller::UnInstall() {
MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe);
}
MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
- // Get uninstall command.
- CommandLine cmd = InstallUtil::GetChromeUninstallCmd(
- system_install_, dist->GetType());
-
- LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString();
- ASSERT_TRUE(file_util::PathExists(cmd.GetProgram()))
- << "Uninstall executable does not exist.";
-
- cmd.AppendSwitch(installer::switches::kUninstall);
- cmd.AppendSwitch(installer::switches::kForceUninstall);
+ std::wstring uninstall_path = GetUninstallPath();
+ if (uninstall_path.empty()) {
+ printf("\n %ls install is in a weird state. Cleaning the machine...\n",
+ product_name.c_str());
+ CleanChromeInstall();
+ return;
+ }
+ ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path)));
+ std::wstring uninstall_args(L"\"");
+ uninstall_args.append(uninstall_path);
+ uninstall_args.append(L"\" --uninstall --force-uninstall");
if (is_chrome_frame_)
- cmd.AppendSwitch(installer::switches::kChromeFrame);
- if (system_install_)
- cmd.AppendSwitch(installer::switches::kSystemLevel);
+ uninstall_args.append(L" --chrome-frame");
+ if (install_type_ == mini_installer_constants::kSystemInstall)
+ uninstall_args = uninstall_args + L" --system-level";
base::ProcessHandle setup_handle;
- ASSERT_TRUE(base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle))
- << "Failed to launch uninstall command.";
+ base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle);
if (is_chrome_frame_)
ASSERT_TRUE(CloseUninstallWindow());
ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle));
- ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()))
- << "It appears Chrome was not completely uninstalled.";
+ ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()));
DeleteUserDataFolder();
// Close IE survey window that gets launched on uninstall.
@@ -366,35 +344,35 @@ void ChromeMiniInstaller::UnInstall() {
}
void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() {
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
std::wstring product_name =
mini_installer_constants::kChromeFrameProductName;
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
if (!CheckRegistryKey(dist->GetVersionKey())) {
printf("%ls is not installed.\n", product_name.c_str());
return;
}
MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
+ std::wstring uninstall_path = GetUninstallPath();
- CommandLine cmd = InstallUtil::GetChromeUninstallCmd(
- system_install_, dist->GetType());
-
- if (cmd.GetProgram().empty()) {
- LOG(ERROR) << "Unable to get uninstall command.";
+ if (uninstall_path.empty()) {
+ printf("\n %ls install is in a weird state. Cleaning the machine...\n",
+ product_name.c_str());
CleanChromeInstall();
+ return;
}
- ASSERT_TRUE(file_util::PathExists(cmd.GetProgram()));
-
- cmd.AppendSwitch(installer::switches::kUninstall);
- cmd.AppendSwitch(installer::switches::kForceUninstall);
- cmd.AppendSwitch(installer::switches::kChromeFrame);
+ ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path)));
+ std::wstring uninstall_args(L"\"");
+ uninstall_args.append(uninstall_path);
+ uninstall_args.append(L"\" --uninstall --force-uninstall");
+ uninstall_args.append(L" --chrome-frame");
- if (system_install_)
- cmd.AppendSwitch(installer::switches::kSystemLevel);
+ if (install_type_ == mini_installer_constants::kSystemInstall)
+ uninstall_args = uninstall_args + L" --system-level";
base::ProcessHandle setup_handle;
- base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle);
+ base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle);
ASSERT_TRUE(CloseUninstallWindow());
ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle));
@@ -506,11 +484,12 @@ bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall(
// Deletes Installer folder from Applications directory.
void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) {
- FilePath install_path;
- ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path));
+ FilePath install_path(GetChromeInstallDirectoryLocation());
std::wstring temp_chrome_dir;
if (is_chrome_frame_) {
temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir;
+ } else {
+ temp_chrome_dir = mini_installer_constants::kChromeAppDir;
}
if (wcscmp(folder_name, L"version_folder") == 0) {
@@ -521,9 +500,7 @@ void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) {
} else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) {
install_path = install_path.Append(folder_name).StripTrailingSeparators();
}
- ASSERT_TRUE(file_util::PathExists(install_path))
- << "Could not find path to delete:" << install_path.value();
- LOG(INFO) << "This path will be deleted: " << install_path.value();
+ printf("This path will be deleted: %ls\n", install_path.value().c_str());
ASSERT_TRUE(file_util::Delete(install_path, true));
}
@@ -584,121 +561,163 @@ void ChromeMiniInstaller::FindChromeShortcut() {
ASSERT_TRUE(file_util::PathExists(uninstall_lnk));
}
if (return_val) {
- LOG(INFO) << "Found Chrome shortcuts:\n"
- << path.value() << "\n"
- << uninstall_lnk.value();
+ printf("Chrome shortcuts found are:\n%ls\n%ls\n\n",
+ path.value().c_str(), uninstall_lnk.value().c_str());
} else {
- LOG(INFO) << "No Chrome shortcuts found.";
+ printf("Chrome shortcuts not found\n\n");
}
}
-bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) {
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- *path = installer::GetChromeInstallPath(system_install_, dist);
- FilePath parent;
- if (system_install_) {
- PathService::Get(base::DIR_PROGRAM_FILES, &parent);
- return file_util::ContainsPath(parent, *path);
- } else {
- PathService::Get(base::DIR_LOCAL_APP_DATA, &parent);
- return file_util::ContainsPath(parent, *path);
- }
+// This method returns path to either program files
+// or documents and setting based on the install type.
+std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() {
+ FilePath path;
+ if (install_type_ == mini_installer_constants::kSystemInstall)
+ PathService::Get(base::DIR_PROGRAM_FILES, &path);
+ else
+ PathService::Get(base::DIR_LOCAL_APP_DATA, &path);
+ return path.value();
}
FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() {
FilePath path_name;
- if (system_install_)
+ if (install_type_ == mini_installer_constants::kSystemInstall)
PathService::Get(base::DIR_COMMON_START_MENU, &path_name);
else
PathService::Get(base::DIR_START_MENU, &path_name);
return path_name;
}
+// Gets the path for uninstall.
+std::wstring ChromeMiniInstaller::GetUninstallPath() {
+ std::wstring path, reg_key_value;
+ if (!GetChromeVersionFromRegistry(&reg_key_value))
+ return std::wstring();
+ path = GetChromeInstallDirectoryLocation();
+ if (is_chrome_frame_) {
+ file_util::AppendToPath(&path,
+ mini_installer_constants::kChromeFrameAppDir);
+ } else {
+ file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
+ }
+ file_util::AppendToPath(&path, reg_key_value);
+ file_util::AppendToPath(&path, installer::kInstallerDir);
+ file_util::AppendToPath(&path,
+ mini_installer_constants::kChromeSetupExecutable);
+ if (!file_util::PathExists(FilePath(path))) {
+ printf("This uninstall path is not correct %ls. Will not proceed further",
+ path.c_str());
+ return L"";
+ }
+ printf("uninstall path is %ls\n", path.c_str());
+ return path;
+}
+
// Returns Chrome pv registry key value
bool ChromeMiniInstaller::GetChromeVersionFromRegistry(
- std::wstring* build_key_value) {
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ);
- LONG result = key.ReadValue(L"pv", build_key_value);
- if (result != ERROR_SUCCESS) {
- LOG(WARNING) << "Registry read for Chrome version error: " << result;
- return false;
- }
- LOG(INFO) << "Build key value is " << build_key_value;
+ std::wstring* build_key_value) {
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ);
+ LONG result = key.ReadValue(L"pv", build_key_value);
+ if (result != ERROR_SUCCESS) {
+ printf("registry read for chrome version failed. error: %d\n", result);
+ return false;
+ }
+ printf("Build key value is %ls\n\n", build_key_value->c_str());
return true;
}
// Get HKEY based on install type.
HKEY ChromeMiniInstaller::GetRootRegistryKey() {
HKEY type = HKEY_CURRENT_USER;
- if (system_install_)
+ if (install_type_ == mini_installer_constants::kSystemInstall)
type = HKEY_LOCAL_MACHINE;
return type;
}
// Launches the chrome installer and waits for it to end.
-void ChromeMiniInstaller::RunInstaller(const CommandLine& command) {
- ASSERT_TRUE(file_util::PathExists(command.GetProgram()));
- CommandLine installer(command);
+void ChromeMiniInstaller::LaunchInstaller(const FilePath& path,
+ const wchar_t* process_name) {
+ ASSERT_TRUE(file_util::PathExists(path));
+ std::wstring launch_args;
if (is_chrome_frame_) {
- installer.AppendSwitch(installer::switches::kDoNotCreateShortcuts);
- installer.AppendSwitch(installer::switches::kDoNotLaunchChrome);
- installer.AppendSwitch(installer::switches::kDoNotRegisterForUpdateLaunch);
- installer.AppendSwitch(installer::switches::kChromeFrame);
+ launch_args.append(L" --do-not-create-shortcuts");
+ launch_args.append(L" --do-not-launch-chrome");
+ launch_args.append(L" --do-not-register-for-update-launch");
+ launch_args.append(L" --chrome-frame");
}
- if (system_install_) {
- installer.AppendSwitch(installer::switches::kSystemLevel);
+ if (install_type_ == mini_installer_constants::kSystemInstall) {
+ launch_args.append(L" --system-level");
}
- LOG(INFO) << "Running installer command: "
- << installer.GetCommandLineString();
base::ProcessHandle app_handle;
- ASSERT_TRUE(
- base::LaunchProcess(installer, base::LaunchOptions(), &app_handle))
- << "Installer failed.";
- ASSERT_TRUE(base::WaitForSingleProcess(app_handle, 60 * 1000))
- << "Installer did not complete.";
-}
-
-void ChromeMiniInstaller::LaunchChrome(bool kill) {
- MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
+ base::LaunchProcess(L"\"" + path.value() + L"\"" + launch_args,
+ base::LaunchOptions(), &app_handle);
- FilePath install_path;
- ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path));
- install_path = install_path.Append(installer::kChromeExe);
- CommandLine browser(install_path);
+ printf("Waiting while this process is running %ls ....\n", process_name);
+ MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true);
+ ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle));
+}
- FilePath exe = browser.GetProgram();
- LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString();
- base::ProcessHandle chrome;
- ASSERT_TRUE(base::LaunchProcess(browser, base::LaunchOptions(), &chrome))
- << "Could not launch process: " << exe.value();
+// Gets the path to launch Chrome.
+bool ChromeMiniInstaller::GetChromeLaunchPath(FilePath* launch_path) {
+ std::wstring path;
+ path = GetChromeInstallDirectoryLocation();
+ file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
+ file_util::AppendToPath(&path, installer::kChromeExe);
+ *launch_path = FilePath(path);
+ return file_util::PathExists(*launch_path);
+}
- if (kill) {
- ASSERT_TRUE(base::KillProcess(chrome, 0, true))
- << "Failed to kill chrome.exe";
+// Launch Chrome to see if it works after overinstall. Then close it.
+void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) {
+ VerifyChromeLaunch(true);
+ if ((install_type_ == mini_installer_constants::kSystemInstall) &&
+ (!over_install)) {
+ MiniInstallerTestUtil::VerifyProcessLaunch(
+ installer::kChromeExe, true);
}
+ MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
+}
+
+// This method will get Chrome exe path and launch it.
+void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) {
+ FilePath launch_path;
+ GetChromeLaunchPath(&launch_path);
+ LaunchBrowser(launch_path, L"", expected_status);
}
// Verifies Chrome/Chrome Frame install.
void ChromeMiniInstaller::VerifyInstall(bool over_install) {
+ VerifyMachineState();
+ if (is_chrome_frame_) {
+ VerifyChromeFrameInstall();
+ } else {
+ if ((install_type_ == mini_installer_constants::kUserInstall) &&
+ (!over_install)) {
+ MiniInstallerTestUtil::VerifyProcessLaunch(
+ installer::kChromeExe, true);
+ }
+ base::PlatformThread::Sleep(800);
+ FindChromeShortcut();
+ LaunchAndCloseChrome(over_install);
+ }
+}
+
+// This method verifies installation of Chrome/Chrome Frame via machine
+// introspection.
+void ChromeMiniInstaller::VerifyMachineState() {
+ using installer::InstallationValidator;
+
InstallationValidator::InstallationType type =
- installer::ExpectValidInstallation(system_install_);
+ installer::ExpectValidInstallation(
+ install_type_ == mini_installer_constants::kSystemInstall);
if (is_chrome_frame_) {
EXPECT_NE(0,
type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE);
} else {
EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE);
}
-
- if (is_chrome_frame_)
- VerifyChromeFrameInstall();
- else if (!system_install_ && !over_install)
- MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true);
-
- base::PlatformThread::Sleep(800);
- FindChromeShortcut();
- LaunchChrome(true);
}
// This method will verify if ChromeFrame installed successfully. It will
@@ -724,6 +743,22 @@ void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) {
base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL);
}
+// This method will launch any requested browser.
+void ChromeMiniInstaller::LaunchBrowser(const FilePath& path,
+ const std::wstring& args,
+ bool expected_status) {
+ LOG(INFO) << "Browser executable: " << path.value();
+ bool launched = base::LaunchProcess(
+ L"\"" + path.value() + L"\"" + L" " + args,
+ base::LaunchOptions(), NULL);
+ if (!launched) {
+ LOG(ERROR) << "Could not launch process: " << path.BaseName().value();
+ }
+ base::PlatformThread::Sleep(1000);
+ MiniInstallerTestUtil::VerifyProcessLaunch(path.BaseName().value().c_str(),
+ expected_status);
+}
+
// This method compares the registry keys after overinstall.
bool ChromeMiniInstaller::VerifyOverInstall(
const std::wstring& value_before_overinstall,
@@ -763,10 +798,7 @@ bool ChromeMiniInstaller::LocateInstallers(
const std::wstring& build) {
FilePath::StringType full_installer_pattern =
FILE_PATH_LITERAL("*_chrome_installer*");
- FilePath::StringType diff_installer_pattern =
- FILE_PATH_LITERAL("*_from_*");
- FilePath::StringType mini_installer_pattern =
- FILE_PATH_LITERAL("mini_installer.exe");
+ FilePath::StringType diff_installer_pattern = FILE_PATH_LITERAL("*_from_*");
FilePath root(mini_installer_constants::kChromeInstallersLocation);
std::vector<FilePath> paths;
if (!FindMatchingFiles(root, build,
@@ -782,13 +814,12 @@ bool ChromeMiniInstaller::LocateInstallers(
if (FindNewestMatchingFile(windir, full_installer_pattern,
file_util::FileEnumerator::FILES, &full_installer_) &&
FindNewestMatchingFile(windir, diff_installer_pattern,
- file_util::FileEnumerator::FILES, &diff_installer_) &&
- FindNewestMatchingFile(windir, mini_installer_pattern,
- file_util::FileEnumerator::FILES, &mini_installer_)) {
+ file_util::FileEnumerator::FILES, &diff_installer_)) {
break;
}
}
+ // Set current build directory.
if (full_installer_.empty() || diff_installer_.empty())
return false;
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h
index c6b8b02..6808f38 100644
--- a/chrome/test/mini_installer_test/chrome_mini_installer.h
+++ b/chrome/test/mini_installer_test/chrome_mini_installer.h
@@ -16,7 +16,7 @@
// This class has methods to install and uninstall Chrome mini installer.
class ChromeMiniInstaller {
public:
- ChromeMiniInstaller(bool system_install, bool is_chrome_frame);
+ ChromeMiniInstaller(const std::wstring& install_type, bool is_chrome_frame);
~ChromeMiniInstaller() {}
enum RepairChrome {
@@ -26,13 +26,11 @@ class ChromeMiniInstaller {
// This method returns path to either program files
// or documents and setting based on the install type.
- bool GetChromeInstallDirectoryLocation(FilePath* path);
+ std::wstring GetChromeInstallDirectoryLocation();
// Installs the latest full installer.
void InstallFullInstaller(bool over_install);
- void InstallUsingMultiInstall();
-
// Installs chrome.
void Install();
@@ -104,15 +102,25 @@ class ChromeMiniInstaller {
// This method gets the shortcut path from start menu based on install type.
FilePath GetStartMenuShortcutPath();
+ // Get path for uninstall.
+ std::wstring GetUninstallPath();
+
// Get user data directory path.
FilePath GetUserDataDirPath();
- // Launch Chrome. Kill process if |kill| is true.
- void LaunchChrome(bool kill);
+ // Gets the path to launch Chrome.
+ bool GetChromeLaunchPath(FilePath* launch_path);
+
+ // This method will get Chrome.exe path and launch it.
+ void VerifyChromeLaunch(bool expected_status);
// This method verifies if Chrome/Chrome Frame installed correctly.
void VerifyInstall(bool over_install);
+ // This method verifies installation of Chrome/Chrome Frame via machine
+ // introspection.
+ void VerifyMachineState();
+
// This method will verify if ChromeFrame got successfully installed on the
// machine.
void VerifyChromeFrameInstall();
@@ -120,8 +128,17 @@ class ChromeMiniInstaller {
// Launch IE with |navigate_url|.
void LaunchIE(const std::wstring& navigate_url);
- // Run installer using provided |command|.
- void RunInstaller(const CommandLine& command);
+ // Launches the chrome installer and waits for it to end.
+ void LaunchInstaller(const FilePath& path,
+ const wchar_t* process_name);
+
+ // Verifies if Chrome launches after install.
+ void LaunchAndCloseChrome(bool over_install);
+
+ // Launches any requested browser.
+ void LaunchBrowser(const FilePath& path,
+ const std::wstring& args,
+ bool expected_status);
// Compares the registry key values after overinstall.
bool VerifyOverInstall(const std::wstring& reg_key_value_before_overinstall,
@@ -136,8 +153,9 @@ class ChromeMiniInstaller {
// This method will create a command line to run apply tag.
CommandLine GetCommandForTagging();
- // If true install system level. Otherwise install user level.
- bool system_install_;
+ // This variable holds the install type.
+ // Install type can be either system or user level.
+ std::wstring install_type_;
bool is_chrome_frame_;
@@ -145,7 +163,6 @@ class ChromeMiniInstaller {
FilePath diff_installer_;
FilePath previous_installer_;
FilePath standalone_installer_;
- FilePath mini_installer_;
// Build numbers.
std::wstring current_build_, previous_build_;
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 76d611e..e15d795 100644
--- a/chrome/test/mini_installer_test/mini_installer_test_constants.cc
+++ b/chrome/test/mini_installer_test/mini_installer_test_constants.cc
@@ -26,6 +26,7 @@ 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";
@@ -38,6 +39,8 @@ 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 kSystemInstall[] = L"system";
+const wchar_t kUserInstall[] = L"user";
const wchar_t kUntaggedInstallerPattern[] = L"ChromeStandaloneSetup_";
const wchar_t kWinFolder[] = L"win";
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 6307999..ecb5502 100644
--- a/chrome/test/mini_installer_test/mini_installer_test_constants.h
+++ b/chrome/test/mini_installer_test/mini_installer_test_constants.h
@@ -14,6 +14,7 @@ extern const wchar_t kChromeAppDir[];
extern const wchar_t kChromeFrameAppDir[];
extern const wchar_t kChromeFrameProductName[];
extern const wchar_t kChromeMetaInstallerExecutable[];
+extern const wchar_t kChromeMiniInstallerExecutable[];
extern const wchar_t kChromeProductName[];
extern const wchar_t kChromeSetupExecutable[];
extern const wchar_t kChromeUserDataBackupDir[];
@@ -24,6 +25,8 @@ extern const wchar_t kFullInstall[];
extern const wchar_t kFullInstallerPattern[];
extern const wchar_t kGoogleUpdateExecutable[];
extern const wchar_t kIEExecutable[];
+extern const wchar_t kSystemInstall[];
+extern const wchar_t kUserInstall[];
extern const wchar_t kWinFolder[];
// Window names.
diff --git a/chrome/test/mini_installer_test/mini_installer_test_util.cc b/chrome/test/mini_installer_test/mini_installer_test_util.cc
index 03a8c56..722c701 100644
--- a/chrome/test/mini_installer_test/mini_installer_test_util.cc
+++ b/chrome/test/mini_installer_test/mini_installer_test_util.cc
@@ -93,7 +93,6 @@ void MiniInstallerTestUtil::SendEnterKeyToWindow() {
void MiniInstallerTestUtil::VerifyProcessLaunch(
const wchar_t* process_name, bool expected_status) {
- LOG(INFO) << "Verifying process is launched: " << process_name;
int timer = 0, wait_time = 60000;
if (!expected_status)
wait_time = 8000;
diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc
index 4e72844..dd9274a 100644
--- a/chrome/test/mini_installer_test/run_all_unittests.cc
+++ b/chrome/test/mini_installer_test/run_all_unittests.cc
@@ -18,9 +18,10 @@ void BackUpProfile(bool chrome_frame) {
"Please close Chrome and run the tests again.\n");
exit(1);
}
- ChromeMiniInstaller installer(false, chrome_frame);
- FilePath path;
- installer.GetChromeInstallDirectoryLocation(&path);
+ ChromeMiniInstaller installer(mini_installer_constants::kUserInstall,
+ chrome_frame);
+ FilePath path =
+ FilePath::FromWStringHack(installer.GetChromeInstallDirectoryLocation());
path = path.Append(mini_installer_constants::kChromeAppDir).DirName();
FilePath backup_path = path;
// Will hold User Data path that needs to be backed-up.
diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc
index 1dca4dd..b5b2a2a 100644
--- a/chrome/test/mini_installer_test/test.cc
+++ b/chrome/test/mini_installer_test/test.cc
@@ -27,10 +27,16 @@ class MiniInstallTest : public testing::Test {
static void CleanTheSystem() {
const CommandLine* cmd = CommandLine::ForCurrentProcess();
if (cmd->HasSwitch(installer::switches::kChromeFrame)) {
- ChromeMiniInstaller(true, true).UnInstall();
+ ChromeMiniInstaller systeminstall(kSystemInstall,
+ cmd->HasSwitch(installer::switches::kChromeFrame));
+ systeminstall.UnInstall();
} else {
- ChromeMiniInstaller(false, false).UnInstall();
- ChromeMiniInstaller(true, false).UnInstall();
+ ChromeMiniInstaller userinstall(kUserInstall,
+ cmd->HasSwitch(installer::switches::kChromeFrame));
+ userinstall.UnInstall();
+ ChromeMiniInstaller systeminstall(kSystemInstall,
+ cmd->HasSwitch(installer::switches::kChromeFrame));
+ systeminstall.UnInstall();
}
}
@@ -47,8 +53,10 @@ class MiniInstallTest : public testing::Test {
// Create a few differently configured installers that are used in
// the tests, for convenience.
- user_inst_.reset(new ChromeMiniInstaller(false, chrome_frame_));
- sys_inst_.reset(new ChromeMiniInstaller(true, chrome_frame_));
+ user_inst_.reset(new ChromeMiniInstaller(kUserInstall,
+ chrome_frame_));
+ sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall,
+ chrome_frame_));
sys_inst_->SetBuildUnderTest(build);
user_inst_->SetBuildUnderTest(build);
}
@@ -167,16 +175,6 @@ TEST_F(MiniInstallTest,
if (!chrome_frame_)
user_inst_->OverInstall();
}
-
-TEST_F(MiniInstallTest,
- InstallChromeUsingMultiInstallUser) {
- user_inst_->InstallUsingMultiInstall();
-}
-
-TEST_F(MiniInstallTest,
- InstallChromeUsingMultiInstallSys) {
- sys_inst_->InstallUsingMultiInstall();
-}
#endif
TEST_F(MiniInstallTest, InstallMiniInstallerSys) {