Index: base/test/test_reg_util_win.cc |
=================================================================== |
--- base/test/test_reg_util_win.cc (revision 0) |
+++ base/test/test_reg_util_win.cc (revision 0) |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/logging.h" |
+#include "base/test/test_reg_util_win.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace registry_util { |
+ |
+const wchar_t ScopedRegistryKeyOverride::kTempTestKeyPath[] = |
+ L"Software\\Chromium\\TempTestKeys"; |
+ |
+ScopedRegistryKeyOverride::ScopedRegistryKeyOverride( |
+ HKEY override, |
+ const std::wstring& temp_name) |
+ : override_(override), |
+ temp_name_(temp_name) { |
+ DCHECK(temp_name_.length() > 0); |
+ std::wstring key_path(kTempTestKeyPath); |
+ key_path += L"\\" + temp_name_; |
+ 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())); |
+} |
+ |
+ScopedRegistryKeyOverride::~ScopedRegistryKeyOverride() { |
+ ::RegOverridePredefKey(override_, NULL); |
+ // The temp key will be deleted via a call to DeleteAllTempKeys(). |
+} |
+ |
+// static |
+void ScopedRegistryKeyOverride::DeleteAllTempKeys() { |
+ base::win::RegKey key; |
+ if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS) == ERROR_SUCCESS) { |
+ key.DeleteKey(kTempTestKeyPath); |
+ } |
+} |
+ |
+ScopedRegistryTempPathCleanup::ScopedRegistryTempPathCleanup() { |
+ ScopedRegistryKeyOverride::DeleteAllTempKeys(); |
+} |
+ |
+ScopedRegistryTempPathCleanup::~ScopedRegistryTempPathCleanup() { |
+ ScopedRegistryKeyOverride::DeleteAllTempKeys(); |
+} |
+ |
+} // namespace registry_util |
Property changes on: base\test\test_reg_util_win.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |