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

Unified Diff: base/test/test_reg_util_win.cc

Issue 2692843002: Fail tests fast if overriding the Windows registry fails. (Closed)
Patch Set: sync to position 450085 Created 3 years, 10 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 | « base/test/test_reg_util_win.h ('k') | base/test/test_reg_util_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_reg_util_win.cc
diff --git a/base/test/test_reg_util_win.cc b/base/test/test_reg_util_win.cc
index 8dda1b362ba78da3abb17138f273d3b2175bde58..a4010d5fc2d38731519c0211977f2225327c1e3e 100644
--- a/base/test/test_reg_util_win.cc
+++ b/base/test/test_reg_util_win.cc
@@ -70,18 +70,13 @@ base::string16 GenerateTempKeyPath(const base::string16& test_key_root,
RegistryOverrideManager::ScopedRegistryKeyOverride::ScopedRegistryKeyOverride(
HKEY override,
const base::string16& key_path)
- : override_(override) {
- EXPECT_EQ(
- ERROR_SUCCESS,
- temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(), KEY_ALL_ACCESS));
- EXPECT_EQ(ERROR_SUCCESS,
- ::RegOverridePredefKey(override_, temp_key_.Handle()));
-}
+ : override_(override), key_path_(key_path) {}
RegistryOverrideManager::
ScopedRegistryKeyOverride::~ScopedRegistryKeyOverride() {
::RegOverridePredefKey(override_, NULL);
- temp_key_.DeleteKey(L"");
+ base::win::RegKey(HKEY_CURRENT_USER, L"", KEY_QUERY_VALUE)
+ .DeleteKey(key_path_.c_str());
}
RegistryOverrideManager::RegistryOverrideManager()
@@ -105,6 +100,12 @@ void RegistryOverrideManager::OverrideRegistry(HKEY override) {
void RegistryOverrideManager::OverrideRegistry(HKEY override,
base::string16* override_path) {
base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_);
+
+ base::win::RegKey temp_key;
+ ASSERT_EQ(ERROR_SUCCESS, temp_key.Create(HKEY_CURRENT_USER, key_path.c_str(),
+ KEY_ALL_ACCESS));
+ ASSERT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(override, temp_key.Handle()));
+
overrides_.push_back(
base::MakeUnique<ScopedRegistryKeyOverride>(override, key_path));
if (override_path)
« no previous file with comments | « base/test/test_reg_util_win.h ('k') | base/test/test_reg_util_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698