Commit b256ed1f authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

Better registry cleanup in InstallServiceWorkItemTest.

mini_installer_tests ChromeUserLevel and ChromeUserLevelUpdate are
failing with the following error:

AssertionError: In state 'chrome_user_installed_not_inuse', Registry key
HKEY_LOCAL_MACHINE\Software\Chromium exists.

This is most likely due to the change I made in change 2086353 to delete
a value instead of the key.

Now the test will delete the key if the test is the one that created the
key in the first place.

Bug: 1059314
Change-Id: I2b85e1f4c979c52a41aebb41c4951b60cf58a50a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092939
Commit-Queue: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Auto-Submit: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748062}
parent 977b9a6f
......@@ -42,6 +42,34 @@ class InstallServiceWorkItemTest : public ::testing::Test {
return GetImpl(item)->IsServiceCorrectlyConfigured(config);
}
void SetUp() override {
base::win::RegKey key;
if (ERROR_SUCCESS ==
key.Open(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
KEY_READ | KEY_WOW64_32KEY)) {
preexisting_clientstate_key_ = true;
} else {
ASSERT_EQ(ERROR_SUCCESS,
key.Create(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
KEY_READ | KEY_WOW64_32KEY));
}
}
void TearDown() override {
if (!preexisting_clientstate_key_) {
base::win::RegKey key;
if (key.Open(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
DELETE | KEY_WOW64_32KEY)) {
EXPECT_EQ(ERROR_SUCCESS, key.DeleteKey(L""));
}
}
}
bool preexisting_clientstate_key_ = false;
};
TEST_F(InstallServiceWorkItemTest, Do_MultiSzToVector) {
......@@ -134,12 +162,6 @@ TEST_F(InstallServiceWorkItemTest, Do_UpgradeChangedCmdLine) {
}
TEST_F(InstallServiceWorkItemTest, Do_ServiceName) {
base::win::RegKey key;
ASSERT_EQ(ERROR_SUCCESS,
key.Create(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
KEY_WRITE | KEY_WOW64_32KEY));
key.DeleteValue(kServiceName);
auto item = std::make_unique<InstallServiceWorkItem>(
kServiceName, kServiceDisplayName,
base::CommandLine(base::FilePath(kServiceProgramPath)));
......@@ -163,6 +185,11 @@ TEST_F(InstallServiceWorkItemTest, Do_ServiceName) {
.c_str(),
GetImpl(item.get())->GetCurrentServiceDisplayName().c_str());
base::win::RegKey key;
ASSERT_EQ(ERROR_SUCCESS,
key.Open(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
KEY_WRITE | KEY_WOW64_32KEY));
EXPECT_EQ(ERROR_SUCCESS, key.DeleteValue(kServiceName));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment