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

Side by Side Diff: base/registry_unittest.cc

Issue 3836005: Move pe_image and registry from base to base/win and use the namespace. It re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/registry.cc ('k') | base/win/pe_image.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/registry.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace {
9
10 const wchar_t kRootKey[] = L"Base_Registry_Unittest";
11
12 class RegistryTest : public testing::Test {
13 public:
14 RegistryTest() {}
15
16 protected:
17 virtual void SetUp() {
18 // Create a temporary key.
19 RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
20 key.DeleteKey(kRootKey);
21 ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, kRootKey, KEY_READ));
22 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, kRootKey, KEY_READ));
23 }
24
25 virtual void TearDown() {
26 // Clean up the temporary key.
27 RegKey key(HKEY_CURRENT_USER, L"", KEY_SET_VALUE);
28 ASSERT_TRUE(key.DeleteKey(kRootKey));
29 }
30
31 private:
32 DISALLOW_COPY_AND_ASSIGN(RegistryTest);
33 };
34
35 TEST_F(RegistryTest, ValueTest) {
36 RegKey key;
37
38 std::wstring foo_key(kRootKey);
39 foo_key += L"\\Foo";
40 ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, foo_key.c_str(), KEY_READ));
41
42 {
43 ASSERT_TRUE(key.Open(HKEY_CURRENT_USER, foo_key.c_str(),
44 KEY_READ | KEY_SET_VALUE));
45
46 const wchar_t* kName = L"Bar";
47 const wchar_t* kValue = L"bar";
48 EXPECT_TRUE(key.WriteValue(kName, kValue));
49 EXPECT_TRUE(key.ValueExists(kName));
50 std::wstring out_value;
51 EXPECT_TRUE(key.ReadValue(kName, &out_value));
52 EXPECT_NE(out_value, L"");
53 EXPECT_STREQ(out_value.c_str(), kValue);
54 EXPECT_EQ(1U, key.ValueCount());
55 EXPECT_TRUE(key.DeleteValue(kName));
56 }
57 }
58
59 } // namespace
OLDNEW
« no previous file with comments | « base/registry.cc ('k') | base/win/pe_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698