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

Unified Diff: chrome/installer/setup/setup_util_unittest.cc

Issue 2589753002: Remove multi-install from chrome/installer/setup. (Closed)
Patch Set: sync to position 442053 Created 3 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/setup/setup_util.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/setup_util_unittest.cc
diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
index a2d88cc4425581d8a8713404ea381ac6e284333a..39fe0d564a35435a7ff82103d6868483f26237c3 100644
--- a/chrome/installer/setup/setup_util_unittest.cc
+++ b/chrome/installer/setup/setup_util_unittest.cc
@@ -14,6 +14,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
@@ -512,6 +513,7 @@ TEST_F(FindArchiveToPatchTest, DesiredVersionNotFound) {
#if defined(GOOGLE_CHROME_BUILD)
namespace {
+
const bool kSystemLevel = false;
const HKEY kRootKey = kSystemLevel ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
const wchar_t kVersionString[] = L"30.0.1574.0";
@@ -526,6 +528,7 @@ class MigrateMultiToSingleTest : public testing::Test {
private:
registry_util::RegistryOverrideManager registry_override_manager_;
};
+
} // namespace
// Test migrating Chrome Frame from multi to single.
@@ -585,7 +588,7 @@ TEST_F(MigrateMultiToSingleTest, ChromeFrame) {
BrowserDistribution::CHROME_BINARIES));
EXPECT_EQ(L"2.0-dev-multi", binaries.channel().value());
}
-#endif
+#endif // GOOGLE_CHROME_BUILD
TEST(SetupUtilTest, ContainsUnsupportedSwitch) {
EXPECT_FALSE(installer::ContainsUnsupportedSwitch(
@@ -718,4 +721,142 @@ TEST_F(DeleteRegistryKeyPartialTest, NonEmptyKeyWithPreserve) {
}
}
+class LegacyCleanupsTest : public ::testing::Test {
+ protected:
+ LegacyCleanupsTest() = default;
+ void SetUp() override {
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+ registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER);
+ installer_state_ =
+ base::MakeUnique<FakeInstallerState>(temp_dir_.GetPath());
+ // Create the state to be cleared.
+ ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kBinariesClientsKeyPath,
+ KEY_WRITE | KEY_WOW64_32KEY)
+ .Valid());
+#if defined(GOOGLE_CHROME_BUILD)
+ ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kGCFClientsKeyPath,
+ KEY_WRITE | KEY_WOW64_32KEY)
+ .Valid());
+ ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kAppLauncherClientsKeyPath,
+ KEY_WRITE | KEY_WOW64_32KEY)
+ .Valid());
+ ASSERT_GT(base::WriteFile(GetAppHostExePath(), "cha", 3), 0);
+ ASSERT_TRUE(
+ base::win::RegKey(HKEY_CURRENT_USER,
+ GetChromeAppCommandPath(L"install-extension").c_str(),
+ KEY_WRITE | KEY_WOW64_32KEY)
+ .Valid());
+#endif // GOOGLE_CHROME_BUILD
+ }
+
+ const InstallerState& installer_state() const { return *installer_state_; }
+
+ bool HasBinariesVersionKey() const {
+ return base::win::RegKey(HKEY_CURRENT_USER, kBinariesClientsKeyPath,
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY)
+ .Valid();
+ }
+
+#if defined(GOOGLE_CHROME_BUILD)
+ bool HasMultiGCFVersionKey() const {
+ return base::win::RegKey(HKEY_CURRENT_USER, kGCFClientsKeyPath,
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY)
+ .Valid();
+ }
+
+ bool HasAppLauncherVersionKey() const {
+ return base::win::RegKey(HKEY_CURRENT_USER, kAppLauncherClientsKeyPath,
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY)
+ .Valid();
+ }
+
+ bool HasAppHostExe() const { return base::PathExists(GetAppHostExePath()); }
+
+ bool HasInstallExtensionCommand() const {
+ return base::win::RegKey(
+ HKEY_CURRENT_USER,
+ GetChromeAppCommandPath(L"install-extension").c_str(),
+ KEY_QUERY_VALUE | KEY_WOW64_32KEY)
+ .Valid();
+ }
+#endif // GOOGLE_CHROME_BUILD
+
+ private:
+ // An InstallerState for a per-user install of Chrome in a given directory.
+ class FakeInstallerState : public InstallerState {
+ public:
+ explicit FakeInstallerState(const base::FilePath& target_path) {
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ operation_ = InstallerState::SINGLE_INSTALL_OR_UPDATE;
+ target_path_ = target_path;
+ state_key_ = dist->GetStateKey();
+ state_type_ = dist->GetType();
+ product_ = base::MakeUnique<Product>(dist);
+ level_ = InstallerState::USER_LEVEL;
+ root_key_ = HKEY_CURRENT_USER;
+ }
+ };
+
+#if defined(GOOGLE_CHROME_BUILD)
+ base::FilePath GetAppHostExePath() const {
+ return installer_state_->target_path().AppendASCII("app_host.exe");
+ }
+
+ base::string16 GetChromeAppCommandPath(const wchar_t* command) const {
+ return base::string16(
+ L"SOFTWARE\\Google\\Update\\Clients\\"
+ L"{8A69D345-D564-463c-AFF1-A69D9E530F96}\\Commands\\") +
+ command;
+ }
+#endif // GOOGLE_CHROME_BUILD
+
+ static const wchar_t kBinariesClientsKeyPath[];
+#if defined(GOOGLE_CHROME_BUILD)
+ static const wchar_t kGCFClientsKeyPath[];
+ static const wchar_t kAppLauncherClientsKeyPath[];
+#endif
+
+ base::ScopedTempDir temp_dir_;
+ registry_util::RegistryOverrideManager registry_override_manager_;
+ std::unique_ptr<FakeInstallerState> installer_state_;
+ DISALLOW_COPY_AND_ASSIGN(LegacyCleanupsTest);
+};
+
+#if defined(GOOGLE_CHROME_BUILD)
+const wchar_t LegacyCleanupsTest::kBinariesClientsKeyPath[] =
+ L"SOFTWARE\\Google\\Update\\Clients\\"
+ L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
+const wchar_t LegacyCleanupsTest::kGCFClientsKeyPath[] =
+ L"SOFTWARE\\Google\\Update\\Clients\\"
+ L"{8BA986DA-5100-405E-AA35-86F34A02ACBF}";
+const wchar_t LegacyCleanupsTest::kAppLauncherClientsKeyPath[] =
+ L"SOFTWARE\\Google\\Update\\Clients\\"
+ L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}";
+#else // GOOGLE_CHROME_BUILD
+const wchar_t LegacyCleanupsTest::kBinariesClientsKeyPath[] =
+ L"SOFTWARE\\Chromium Binaries";
+#endif // !GOOGLE_CHROME_BUILD
+
+TEST_F(LegacyCleanupsTest, NoOpOnFailedUpdate) {
+ DoLegacyCleanups(installer_state(), INSTALL_FAILED);
+ EXPECT_TRUE(HasBinariesVersionKey());
+#if defined(GOOGLE_CHROME_BUILD)
+ EXPECT_TRUE(HasMultiGCFVersionKey());
+ EXPECT_TRUE(HasAppLauncherVersionKey());
+ EXPECT_TRUE(HasAppHostExe());
+ EXPECT_TRUE(HasInstallExtensionCommand());
+#endif // GOOGLE_CHROME_BUILD
+}
+
+TEST_F(LegacyCleanupsTest, Do) {
+ DoLegacyCleanups(installer_state(), NEW_VERSION_UPDATED);
+ EXPECT_FALSE(HasBinariesVersionKey());
+#if defined(GOOGLE_CHROME_BUILD)
+ EXPECT_FALSE(HasMultiGCFVersionKey());
+ EXPECT_FALSE(HasAppLauncherVersionKey());
+ EXPECT_FALSE(HasAppHostExe());
+ EXPECT_FALSE(HasInstallExtensionCommand());
+#endif // GOOGLE_CHROME_BUILD
+}
+
} // namespace installer
« no previous file with comments | « chrome/installer/setup/setup_util.cc ('k') | chrome/installer/setup/uninstall.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698