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,38 @@ |
+// 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 reg_util { |
+ |
+const wchar_t TempRegKeyOverride::kTempTestKeyPath[] = |
+ L"Software\\Chromium\\TempTestKeys"; |
+ |
+TempRegKeyOverride::TempRegKeyOverride(HKEY override, const wchar_t* temp_name) |
+ : override_(override), temp_name_(temp_name) { |
Paweł Hajdan Jr.
2011/08/18 22:42:47
nit: Each one on its own line please.
Roger Tawa OOO till Jul 10th
2011/08/22 19:24:42
Done.
|
+ DCHECK(temp_name && lstrlenW(temp_name)); |
Paweł Hajdan Jr.
2011/08/18 22:42:47
Split that into two, so it's easier to see what fa
Roger Tawa OOO till Jul 10th
2011/08/22 19:24:42
Done.
|
+ 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())); |
+} |
+ |
+TempRegKeyOverride::~TempRegKeyOverride() { |
+ ::RegOverridePredefKey(override_, NULL); |
+ // The temp key will be deleted via a call to DeleteAllTempKeys(). |
Paweł Hajdan Jr.
2011/08/18 22:42:47
This relies on the caller calling DeleteAllTempKey
Roger Tawa OOO till Jul 10th
2011/08/22 19:24:42
added a scoper.
|
+} |
+ |
+// static |
+void TempRegKeyOverride::DeleteAllTempKeys() { |
+ base::win::RegKey key; |
+ if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS) == ERROR_SUCCESS) { |
+ key.DeleteKey(kTempTestKeyPath); |
+ } |
+} |
+ |
+} // namespace reg_util |
Property changes on: base\test\test_reg_util_win.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |