From 2d650398a9afa1fc3c168aed736daa13901809a8 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Sun, 17 Oct 2010 04:41:54 +0000 Subject: Move pe_image and registry from base to base/win and use the namespace. It removes windows_message_list which isn't used. This keeps a stub for registry in the old location until we can update that. TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/3836005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62888 0039d316-1c4b-4281-b951-d872f2087c98 --- base/win/registry_unittest.cc | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 base/win/registry_unittest.cc (limited to 'base/win/registry_unittest.cc') diff --git a/base/win/registry_unittest.cc b/base/win/registry_unittest.cc new file mode 100644 index 0000000..524612a --- /dev/null +++ b/base/win/registry_unittest.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2010 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/win/registry.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { +namespace win { + +namespace { + +const wchar_t kRootKey[] = L"Base_Registry_Unittest"; + +class RegistryTest : public testing::Test { + public: + RegistryTest() {} + + protected: + virtual void SetUp() { + // Create a temporary key. + RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); + key.DeleteKey(kRootKey); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, kRootKey, KEY_READ)); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, kRootKey, KEY_READ)); + } + + virtual void TearDown() { + // Clean up the temporary key. + RegKey key(HKEY_CURRENT_USER, L"", KEY_SET_VALUE); + ASSERT_TRUE(key.DeleteKey(kRootKey)); + } + + private: + DISALLOW_COPY_AND_ASSIGN(RegistryTest); +}; + +TEST_F(RegistryTest, ValueTest) { + RegKey key; + + std::wstring foo_key(kRootKey); + foo_key += L"\\Foo"; + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, foo_key.c_str(), KEY_READ)); + + { + ASSERT_TRUE(key.Open(HKEY_CURRENT_USER, foo_key.c_str(), + KEY_READ | KEY_SET_VALUE)); + + const wchar_t* kName = L"Bar"; + const wchar_t* kValue = L"bar"; + EXPECT_TRUE(key.WriteValue(kName, kValue)); + EXPECT_TRUE(key.ValueExists(kName)); + std::wstring out_value; + EXPECT_TRUE(key.ReadValue(kName, &out_value)); + EXPECT_NE(out_value, L""); + EXPECT_STREQ(out_value.c_str(), kValue); + EXPECT_EQ(1U, key.ValueCount()); + EXPECT_TRUE(key.DeleteValue(kName)); + } +} + +} // namespace + +} // namespace win +} // namespace base -- cgit v1.1