OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "base/test/test_reg_util_win.h" |
| 6 |
| 7 #include <memory> |
| 8 |
5 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
6 #include "base/memory/scoped_ptr.h" | |
7 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
9 #include "base/test/test_reg_util_win.h" | |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 namespace registry_util { | 15 namespace registry_util { |
14 | 16 |
15 namespace { | 17 namespace { |
16 const wchar_t kTestKeyPath[] = L"Software\\Chromium\\Foo\\Baz\\TestKey"; | 18 const wchar_t kTestKeyPath[] = L"Software\\Chromium\\Foo\\Baz\\TestKey"; |
17 const wchar_t kTestValueName[] = L"TestValue"; | 19 const wchar_t kTestValueName[] = L"TestValue"; |
18 } // namespace | 20 } // namespace |
19 | 21 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return fake_test_key_root_ + L"\\" + | 63 return fake_test_key_root_ + L"\\" + |
62 base::Int64ToString16(time.ToInternalValue()); | 64 base::Int64ToString16(time.ToInternalValue()); |
63 } | 65 } |
64 | 66 |
65 void CreateManager(const base::Time& timestamp) { | 67 void CreateManager(const base::Time& timestamp) { |
66 manager_.reset(new RegistryOverrideManager(timestamp, fake_test_key_root_)); | 68 manager_.reset(new RegistryOverrideManager(timestamp, fake_test_key_root_)); |
67 manager_->OverrideRegistry(HKEY_CURRENT_USER); | 69 manager_->OverrideRegistry(HKEY_CURRENT_USER); |
68 } | 70 } |
69 | 71 |
70 base::string16 fake_test_key_root_; | 72 base::string16 fake_test_key_root_; |
71 scoped_ptr<RegistryOverrideManager> manager_; | 73 std::unique_ptr<RegistryOverrideManager> manager_; |
72 }; | 74 }; |
73 | 75 |
74 TEST_F(RegistryOverrideManagerTest, Basic) { | 76 TEST_F(RegistryOverrideManagerTest, Basic) { |
75 CreateManager(base::Time::Now()); | 77 CreateManager(base::Time::Now()); |
76 | 78 |
77 base::win::RegKey create_key; | 79 base::win::RegKey create_key; |
78 EXPECT_EQ(ERROR_SUCCESS, | 80 EXPECT_EQ(ERROR_SUCCESS, |
79 create_key.Create(HKEY_CURRENT_USER, kTestKeyPath, KEY_ALL_ACCESS)); | 81 create_key.Create(HKEY_CURRENT_USER, kTestKeyPath, KEY_ALL_ACCESS)); |
80 EXPECT_TRUE(create_key.Valid()); | 82 EXPECT_TRUE(create_key.Valid()); |
81 EXPECT_EQ(ERROR_SUCCESS, create_key.WriteValue(kTestValueName, 42)); | 83 EXPECT_EQ(ERROR_SUCCESS, create_key.WriteValue(kTestValueName, 42)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 manager_.reset(); | 123 manager_.reset(); |
122 | 124 |
123 AssertKeyAbsent(path_garbage); | 125 AssertKeyAbsent(path_garbage); |
124 AssertKeyAbsent(path_very_stale); | 126 AssertKeyAbsent(path_very_stale); |
125 AssertKeyAbsent(path_stale); | 127 AssertKeyAbsent(path_stale); |
126 AssertKeyExists(path_current); | 128 AssertKeyExists(path_current); |
127 AssertKeyExists(path_future); | 129 AssertKeyExists(path_future); |
128 } | 130 } |
129 | 131 |
130 } // namespace registry_util | 132 } // namespace registry_util |
OLD | NEW |