OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/win/registry.h" | 5 #include "base/win/registry.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 foo_key += L"\\Foo"; | 160 foo_key += L"\\Foo"; |
161 ASSERT_EQ(ERROR_SUCCESS, key.Create(HKEY_CURRENT_USER, foo_key.c_str(), | 161 ASSERT_EQ(ERROR_SUCCESS, key.Create(HKEY_CURRENT_USER, foo_key.c_str(), |
162 KEY_READ)); | 162 KEY_READ)); |
163 ASSERT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, foo_key.c_str(), | 163 ASSERT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, foo_key.c_str(), |
164 KEY_READ | KEY_SET_VALUE)); | 164 KEY_READ | KEY_SET_VALUE)); |
165 ASSERT_TRUE(key.Valid()); | 165 ASSERT_TRUE(key.Valid()); |
166 | 166 |
167 const wchar_t kName[] = L"name"; | 167 const wchar_t kName[] = L"name"; |
168 // kData size is not a multiple of sizeof(wchar_t). | 168 // kData size is not a multiple of sizeof(wchar_t). |
169 const uint8 kData[] = { 1, 2, 3, 4, 5 }; | 169 const uint8 kData[] = { 1, 2, 3, 4, 5 }; |
170 EXPECT_EQ(5, arraysize(kData)); | 170 EXPECT_EQ(5u, arraysize(kData)); |
171 ASSERT_EQ(ERROR_SUCCESS, key.WriteValue(kName, kData, | 171 ASSERT_EQ(ERROR_SUCCESS, key.WriteValue(kName, kData, |
172 arraysize(kData), REG_BINARY)); | 172 arraysize(kData), REG_BINARY)); |
173 | 173 |
174 RegistryValueIterator iterator(HKEY_CURRENT_USER, foo_key.c_str()); | 174 RegistryValueIterator iterator(HKEY_CURRENT_USER, foo_key.c_str()); |
175 ASSERT_TRUE(iterator.Valid()); | 175 ASSERT_TRUE(iterator.Valid()); |
176 EXPECT_STREQ(kName, iterator.Name()); | 176 EXPECT_STREQ(kName, iterator.Name()); |
177 // ValueSize() is in bytes. | 177 // ValueSize() is in bytes. |
178 ASSERT_EQ(arraysize(kData), iterator.ValueSize()); | 178 ASSERT_EQ(arraysize(kData), iterator.ValueSize()); |
179 // Value() is NUL terminated. | 179 // Value() is NUL terminated. |
180 int end = (iterator.ValueSize() + sizeof(wchar_t) - 1) / sizeof(wchar_t); | 180 int end = (iterator.ValueSize() + sizeof(wchar_t) - 1) / sizeof(wchar_t); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 ASSERT_TRUE(key.StartWatching(Bind(&TestChangeDelegate::OnKeyChanged, | 411 ASSERT_TRUE(key.StartWatching(Bind(&TestChangeDelegate::OnKeyChanged, |
412 Unretained(&delegate)))); | 412 Unretained(&delegate)))); |
413 base::RunLoop().RunUntilIdle(); | 413 base::RunLoop().RunUntilIdle(); |
414 EXPECT_FALSE(delegate.WasCalled()); | 414 EXPECT_FALSE(delegate.WasCalled()); |
415 } | 415 } |
416 | 416 |
417 } // namespace | 417 } // namespace |
418 | 418 |
419 } // namespace win | 419 } // namespace win |
420 } // namespace base | 420 } // namespace base |
OLD | NEW |