Commit 0b6c41a8 authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

Reland "Better registry cleanup in InstallServiceWorkItemTest."

This reverts commit b99538b3.

Reason for revert: The original CL 2092939 was not the cause of the flaky failures, so reverting the revert.

Original change's description:
> Revert "Better registry cleanup in InstallServiceWorkItemTest."
> 
> This reverts commit b256ed1f.
> 
> Reason for revert: I'm hoping reverting this and your other patch will fix the flake. Bug is here: https://bugs.chromium.org/p/chromium/issues/detail?id=1059314
> 
> Original change's description:
> > 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: Greg Thompson <grt@chromium.org>
> > Auto-Submit: S. Ganesh <ganesh@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#748062}
> 
> TBR=ganesh@chromium.org,grt@chromium.org
> 
> Change-Id: I875c730322f5bc4cc9fdfa8b5497e26f2b8b81da
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1059314
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095201
> Reviewed-by: Scott Violet <sky@chromium.org>
> Commit-Queue: Scott Violet <sky@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#748256}

TBR=sky@chromium.org,ganesh@chromium.org,grt@chromium.org

Change-Id: Ia53b0dae159068f44137e0e8d597d3dd9c2f0428
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1059314
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095766Reviewed-by: default avatarS. Ganesh <ganesh@chromium.org>
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748415}
parent df91c37e
......@@ -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