Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: chrome/installer/util/install_util_unittest.cc

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/installation_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/install_util_unittest.cc
===================================================================
--- chrome/installer/util/install_util_unittest.cc (revision 72487)
+++ chrome/installer/util/install_util_unittest.cc (working copy)
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <string>
+#include <utility>
#include "base/command_line.h"
#include "base/win/registry.h"
@@ -34,17 +35,17 @@
// check results for a fresh install of single Chrome
{
TempRegKeyOverride override(root, L"root_inst_res");
- const MasterPreferences prefs(
- CommandLine::FromString(L"setup.exe --system-level"));
+ CommandLine cmd_line = CommandLine::FromString(L"setup.exe --system-level");
+ const MasterPreferences prefs(cmd_line);
InstallationState machine_state;
- machine_state.Initialize(prefs);
+ machine_state.Initialize();
InstallerState state;
- state.Initialize(prefs, machine_state);
+ state.Initialize(cmd_line, prefs, machine_state);
InstallUtil::WriteInstallerResult(system_level, state.state_key(),
installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd);
BrowserDistribution* distribution =
BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER, prefs);
+ BrowserDistribution::CHROME_BROWSER);
EXPECT_EQ(ERROR_SUCCESS,
key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
EXPECT_EQ(ERROR_SUCCESS,
@@ -56,18 +57,18 @@
// check results for a fresh install of multi Chrome
{
TempRegKeyOverride override(root, L"root_inst_res");
- const MasterPreferences prefs(
- CommandLine::FromString(
- L"setup.exe --system-level --multi-install --chrome"));
+ CommandLine cmd_line = CommandLine::FromString(
+ L"setup.exe --system-level --multi-install --chrome");
+ const MasterPreferences prefs(cmd_line);
InstallationState machine_state;
- machine_state.Initialize(prefs);
+ machine_state.Initialize();
InstallerState state;
- state.Initialize(prefs, machine_state);
+ state.Initialize(cmd_line, prefs, machine_state);
InstallUtil::WriteInstallerResult(system_level, state.state_key(),
installer::FIRST_INSTALL_SUCCESS, 0, &launch_cmd);
BrowserDistribution* distribution =
BrowserDistribution::GetSpecificDistribution(
- BrowserDistribution::CHROME_BROWSER, prefs);
+ BrowserDistribution::CHROME_BROWSER);
EXPECT_EQ(ERROR_SUCCESS,
key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
EXPECT_EQ(ERROR_SUCCESS,
@@ -77,3 +78,27 @@
}
TempRegKeyOverride::DeleteAllTempKeys();
}
+
+TEST_F(InstallUtilTest, MakeUninstallCommand) {
+ CommandLine command_line(CommandLine::NO_PROGRAM);
+
+ std::pair<std::wstring, std::wstring> params[] = {
+ std::make_pair(std::wstring(L""), std::wstring(L"")),
+ std::make_pair(std::wstring(L""), std::wstring(L"--do-something --silly")),
+ std::make_pair(std::wstring(L"spam.exe"), std::wstring(L"")),
+ std::make_pair(std::wstring(L"spam.exe"),
+ std::wstring(L"--do-something --silly")),
+ };
+ for (int i = 0; i < arraysize(params); ++i) {
+ std::pair<std::wstring, std::wstring>& param = params[i];
+ InstallUtil::MakeUninstallCommand(param.first, param.second, &command_line);
+ EXPECT_EQ(param.first, command_line.GetProgram().value());
+ if (param.second.empty()) {
+ EXPECT_EQ(0U, command_line.GetSwitchCount());
+ } else {
+ EXPECT_EQ(2U, command_line.GetSwitchCount());
+ EXPECT_TRUE(command_line.HasSwitch("do-something"));
+ EXPECT_TRUE(command_line.HasSwitch("silly"));
+ }
+ }
+}
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/installation_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698