diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 12:00:30 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-15 12:00:30 +0000 |
commit | 2614ed923300f66bd8f9bd2d109f0be5eed69a0d (patch) | |
tree | ef38fcb7c9765d886b97d9c13e2eef7e54d7f8eb /chrome/installer/util/google_update_settings_unittest.cc | |
parent | 1b3f6b7b95f4534eab79c01cb46c209003a3a890 (diff) | |
download | chromium_src-2614ed923300f66bd8f9bd2d109f0be5eed69a0d.zip chromium_src-2614ed923300f66bd8f9bd2d109f0be5eed69a0d.tar.gz chromium_src-2614ed923300f66bd8f9bd2d109f0be5eed69a0d.tar.bz2 |
Launch Google Update on uninstall.
So it can self-destruct if Chrome (or Chrome Frame) was the last Omaha-managed product on the system.
BUG=114786
TEST=Install Google Update 1.3.21.105 or later and Chrome w/ --verbose-logging. Uninstall Chrome and see that Google Update vanishes immediately. Take a look at chrome_installer.log and look for messages related to Launching Google Update's uninstaller.
Review URL: http://codereview.chromium.org/9693055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/google_update_settings_unittest.cc')
-rw-r--r-- | chrome/installer/util/google_update_settings_unittest.cc | 101 |
1 files changed, 63 insertions, 38 deletions
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index 59c414c..4eb5d11 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -23,10 +23,6 @@ using installer::ChannelInfo; namespace { -const wchar_t kHKCUReplacement[] = - L"Software\\Google\\InstallUtilUnittest\\HKCU"; -const wchar_t kHKLMReplacement[] = - L"Software\\Google\\InstallUtilUnittest\\HKLM"; const wchar_t kGoogleUpdatePoliciesKey[] = L"SOFTWARE\\Policies\\Google\\Update"; const wchar_t kGoogleUpdateUpdateDefault[] = L"UpdateDefault"; @@ -45,38 +41,9 @@ const wchar_t kTestProductGuid[] = L"{89F1B351-B15D-48D4-8F10-1298721CF13D}"; // and user settings. class GoogleUpdateSettingsTest: public testing::Test { protected: - virtual void SetUp() { - // Wipe the keys we redirect to. - // This gives us a stable run, even in the presence of previous - // crashes or failures. - LSTATUS err = SHDeleteKey(HKEY_CURRENT_USER, kHKCUReplacement); - EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); - err = SHDeleteKey(HKEY_CURRENT_USER, kHKLMReplacement); - EXPECT_TRUE(err == ERROR_SUCCESS || err == ERROR_FILE_NOT_FOUND); - - // Create the keys we're redirecting HKCU and HKLM to. - ASSERT_EQ(ERROR_SUCCESS, - hkcu_.Create(HKEY_CURRENT_USER, kHKCUReplacement, KEY_READ)); - ASSERT_EQ(ERROR_SUCCESS, - hklm_.Create(HKEY_CURRENT_USER, kHKLMReplacement, KEY_READ)); - - // And do the switcharoo. - ASSERT_EQ(ERROR_SUCCESS, - ::RegOverridePredefKey(HKEY_CURRENT_USER, hkcu_.Handle())); - ASSERT_EQ(ERROR_SUCCESS, - ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, hklm_.Handle())); - } - - virtual void TearDown() { - // Undo the redirection. - EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_CURRENT_USER, NULL)); - EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, NULL)); - - // Close our handles and delete the temp keys we redirected to. - hkcu_.Close(); - hklm_.Close(); - EXPECT_EQ(ERROR_SUCCESS, SHDeleteKey(HKEY_CURRENT_USER, kHKCUReplacement)); - EXPECT_EQ(ERROR_SUCCESS, SHDeleteKey(HKEY_CURRENT_USER, kHKLMReplacement)); + virtual void SetUp() OVERRIDE { + registry_overrides_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"HKLM_pit"); + registry_overrides_.OverrideRegistry(HKEY_CURRENT_USER, L"HKCU_pit"); } enum SystemUserInstall { @@ -181,8 +148,7 @@ class GoogleUpdateSettingsTest: public testing::Test { return ap_key_value; } - RegKey hkcu_; - RegKey hklm_; + registry_util::RegistryOverrideManager registry_overrides_; }; } // namespace @@ -590,6 +556,65 @@ TEST_F(GoogleUpdateSettingsTest, GetAppUpdatePolicyAppOverride) { #endif // defined(GOOGLE_CHROME_BUILD) +// Test GoogleUpdateSettings::GetUninstallCommandLine at system- or user-level, +// according to the param. +class GetUninstallCommandLine : public GoogleUpdateSettingsTest, + public testing::WithParamInterface<bool> { + protected: + static const wchar_t kDummyCommand[]; + + virtual void SetUp() OVERRIDE { + GoogleUpdateSettingsTest::SetUp(); + system_install_ = GetParam(); + root_key_ = system_install_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + } + + HKEY root_key_; + bool system_install_; +}; + +const wchar_t GetUninstallCommandLine::kDummyCommand[] = + L"\"goopdate.exe\" /spam"; + +// Tests that GetUninstallCommandLine returns an empty string if there's no +// Software\Google\Update key. +TEST_P(GetUninstallCommandLine, TestNoKey) { + EXPECT_EQ(string16(), + GoogleUpdateSettings::GetUninstallCommandLine(system_install_)); +} + +// Tests that GetUninstallCommandLine returns an empty string if there's no +// UninstallCmdLine value in the Software\Google\Update key. +TEST_P(GetUninstallCommandLine, TestNoValue) { + RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE); + EXPECT_EQ(string16(), + GoogleUpdateSettings::GetUninstallCommandLine(system_install_)); +} + +// Tests that GetUninstallCommandLine returns an empty string if there's an +// empty UninstallCmdLine value in the Software\Google\Update key. +TEST_P(GetUninstallCommandLine, TestEmptyValue) { + RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE) + .WriteValue(google_update::kRegUninstallCmdLine, L""); + EXPECT_EQ(string16(), + GoogleUpdateSettings::GetUninstallCommandLine(system_install_)); +} + +// Tests that GetUninstallCommandLine returns the correct string if there's an +// UninstallCmdLine value in the Software\Google\Update key. +TEST_P(GetUninstallCommandLine, TestRealValue) { + RegKey(root_key_, google_update::kRegPathGoogleUpdate, KEY_SET_VALUE) + .WriteValue(google_update::kRegUninstallCmdLine, kDummyCommand); + EXPECT_EQ(string16(kDummyCommand), + GoogleUpdateSettings::GetUninstallCommandLine(system_install_)); + // Make sure that there's no value in the other level (user or system). + EXPECT_EQ(string16(), + GoogleUpdateSettings::GetUninstallCommandLine(!system_install_)); +} + +INSTANTIATE_TEST_CASE_P(GetUninstallCommandLineAtLevel, GetUninstallCommandLine, + testing::Bool()); + // Test values for use by the CollectStatsConsent test fixture. class StatsState { public: |