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

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

Issue 7036017: Write installer results in all relevant registry keys so that we're sure that Google Update will ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
Index: chrome/installer/util/installer_state_unittest.cc
===================================================================
--- chrome/installer/util/installer_state_unittest.cc (revision 85625)
+++ chrome/installer/util/installer_state_unittest.cc (working copy)
@@ -26,12 +26,17 @@
#include "chrome/installer/util/work_item.h"
#include "testing/gtest/include/gtest/gtest.h"
+using base::win::RegKey;
+using installer::InstallationState;
+using installer::InstallerState;
+using installer::MasterPreferences;
+
class InstallerStateTest : public TestWithTempDirAndDeleteTempOverrideKeys {
protected:
};
// An installer state on which we can tweak the target path.
-class MockInstallerState : public installer::InstallerState {
+class MockInstallerState : public InstallerState {
public:
MockInstallerState() : InstallerState() { }
void set_target_path(const FilePath& target_path) {
@@ -52,8 +57,8 @@
void BuildSingleChromeState(const FilePath& target_dir,
MockInstallerState* installer_state) {
CommandLine cmd_line = CommandLine::FromString(L"setup.exe");
- installer::MasterPreferences prefs(cmd_line);
- installer::InstallationState machine_state;
+ MasterPreferences prefs(cmd_line);
+ InstallationState machine_state;
machine_state.Initialize();
installer_state->Initialize(cmd_line, prefs, machine_state);
installer_state->set_target_path(target_dir);
@@ -232,8 +237,8 @@
std::wstring(L"setup.exe") +
(multi_install ? L" --multi-install --chrome" : L"") +
(system_level ? L" --system-level" : L""));
- installer::MasterPreferences prefs(cmd_line);
- installer::InstallationState machine_state;
+ MasterPreferences prefs(cmd_line);
+ InstallationState machine_state;
machine_state.Initialize();
MockInstallerState installer_state;
installer_state.Initialize(cmd_line, prefs, machine_state);
@@ -315,8 +320,8 @@
std::wstring(L"setup.exe") +
(multi_install ? L" --multi-install --chrome" : L"") +
(system_level ? L" --system-level" : L""));
- installer::MasterPreferences prefs(cmd_line);
- installer::InstallationState machine_state;
+ MasterPreferences prefs(cmd_line);
+ InstallationState machine_state;
machine_state.Initialize();
MockInstallerState installer_state;
installer_state.Initialize(cmd_line, prefs, machine_state);
@@ -334,8 +339,7 @@
TempRegKeyOverride override(root, L"root_pit");
BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution(
BrowserDistribution::CHROME_BROWSER);
- base::win::RegKey chrome_key(root, dist->GetVersionKey().c_str(),
- KEY_ALL_ACCESS);
+ RegKey chrome_key(root, dist->GetVersionKey().c_str(), KEY_ALL_ACCESS);
EXPECT_TRUE(chrome_key.Valid());
if (chrome_key.Valid()) {
chrome_key.WriteValue(google_update::kRegVersionField,
@@ -351,3 +355,67 @@
}
}
}
+
+TEST_F(InstallerStateTest, InstallerResult) {
+ const bool system_level = true;
+ bool multi_install = false;
+ HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
+
+ RegKey key;
+ std::wstring launch_cmd = L"hey diddle diddle";
+ std::wstring value;
+
+ // check results for a fresh install of single Chrome
+ {
+ TempRegKeyOverride override(root, L"root_inst_res");
+ CommandLine cmd_line = CommandLine::FromString(L"setup.exe --system-level");
+ const MasterPreferences prefs(cmd_line);
+ InstallationState machine_state;
+ machine_state.Initialize();
+ InstallerState state;
+ state.Initialize(cmd_line, prefs, machine_state);
+ state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0,
+ &launch_cmd);
+ BrowserDistribution* distribution =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BROWSER);
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
+ EXPECT_EQ(launch_cmd, value);
+ }
+ TempRegKeyOverride::DeleteAllTempKeys();
+
+ // check results for a fresh install of multi Chrome
+ {
+ TempRegKeyOverride override(root, L"root_inst_res");
+ CommandLine cmd_line = CommandLine::FromString(
+ L"setup.exe --system-level --multi-install --chrome");
+ const MasterPreferences prefs(cmd_line);
+ InstallationState machine_state;
+ machine_state.Initialize();
+ InstallerState state;
+ state.Initialize(cmd_line, prefs, machine_state);
+ state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0,
+ &launch_cmd);
+ BrowserDistribution* distribution =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BROWSER);
+ BrowserDistribution* binaries =
+ BrowserDistribution::GetSpecificDistribution(
+ BrowserDistribution::CHROME_BINARIES);
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
+ EXPECT_EQ(launch_cmd, value);
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.Open(root, binaries->GetStateKey().c_str(), KEY_READ));
+ EXPECT_EQ(ERROR_SUCCESS,
+ key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
+ EXPECT_EQ(launch_cmd, value);
+ key.Close();
+ }
+ TempRegKeyOverride::DeleteAllTempKeys();
robertshield 2011/05/18 12:28:40 should also test the error field and the UI string
grt (UTC plus 2) 2011/05/18 13:39:30 Done.
+}
« chrome/installer/util/install_util.h ('K') | « chrome/installer/util/installer_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698