OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Main entry point for all unit tests. | 5 // Main entry point for all unit tests. |
6 | 6 |
7 #include "rlz_test_helpers.h" | 7 #include "rlz_test_helpers.h" |
8 | 8 |
| 9 #include <stddef.h> |
| 10 #include <stdint.h> |
| 11 |
9 #include <map> | 12 #include <map> |
10 #include <vector> | 13 #include <vector> |
11 | 14 |
12 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "build/build_config.h" |
13 #include "rlz/lib/rlz_lib.h" | 17 #include "rlz/lib/rlz_lib.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
15 | 19 |
16 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
17 #include <shlwapi.h> | 21 #include <shlwapi.h> |
18 #include "base/win/registry.h" | 22 #include "base/win/registry.h" |
19 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
20 #elif defined(OS_POSIX) | 24 #elif defined(OS_POSIX) |
21 #include "base/files/file_path.h" | 25 #include "base/files/file_path.h" |
22 #include "rlz/lib/rlz_value_store.h" | 26 #include "rlz/lib/rlz_value_store.h" |
23 #endif | 27 #endif |
24 | 28 |
25 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
26 | 30 |
27 namespace { | 31 namespace { |
28 | 32 |
29 // Path to recursively copy into the replacemment hives. These are needed | 33 // Path to recursively copy into the replacemment hives. These are needed |
30 // to make sure certain win32 APIs continue to run correctly once the real | 34 // to make sure certain win32 APIs continue to run correctly once the real |
31 // hives are replaced. | 35 // hives are replaced. |
32 const wchar_t kHKLMAccessProviders[] = | 36 const wchar_t kHKLMAccessProviders[] = |
33 L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders"; | 37 L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders"; |
34 | 38 |
35 struct RegistryValue { | 39 struct RegistryValue { |
36 base::string16 name; | 40 base::string16 name; |
37 DWORD type; | 41 DWORD type; |
38 std::vector<uint8> data; | 42 std::vector<uint8_t> data; |
39 }; | 43 }; |
40 | 44 |
41 struct RegistryKeyData { | 45 struct RegistryKeyData { |
42 std::vector<RegistryValue> values; | 46 std::vector<RegistryValue> values; |
43 std::map<base::string16, RegistryKeyData> keys; | 47 std::map<base::string16, RegistryKeyData> keys; |
44 }; | 48 }; |
45 | 49 |
46 void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) { | 50 void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) { |
47 // First read values. | 51 // First read values. |
48 { | 52 { |
49 base::win::RegistryValueIterator i(src.Handle(), L""); | 53 base::win::RegistryValueIterator i(src.Handle(), L""); |
50 data->values.clear(); | 54 data->values.clear(); |
51 data->values.reserve(i.ValueCount()); | 55 data->values.reserve(i.ValueCount()); |
52 for (; i.Valid(); ++i) { | 56 for (; i.Valid(); ++i) { |
53 RegistryValue& value = *data->values.insert(data->values.end(), | 57 RegistryValue& value = *data->values.insert(data->values.end(), |
54 RegistryValue()); | 58 RegistryValue()); |
55 const uint8* data = reinterpret_cast<const uint8*>(i.Value()); | 59 const uint8_t* data = reinterpret_cast<const uint8_t*>(i.Value()); |
56 value.name.assign(i.Name()); | 60 value.name.assign(i.Name()); |
57 value.type = i.Type(); | 61 value.type = i.Type(); |
58 value.data.assign(data, data + i.ValueSize()); | 62 value.data.assign(data, data + i.ValueSize()); |
59 } | 63 } |
60 } | 64 } |
61 | 65 |
62 // Next read subkeys recursively. | 66 // Next read subkeys recursively. |
63 for (base::win::RegistryKeyIterator i(src.Handle(), L""); | 67 for (base::win::RegistryKeyIterator i(src.Handle(), L""); |
64 i.Valid(); ++i) { | 68 i.Valid(); ++i) { |
65 ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ), | 69 ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void RlzLibTestNoMachineState::TearDown() { | 154 void RlzLibTestNoMachineState::TearDown() { |
151 m_rlz_test_helper_.TearDown(); | 155 m_rlz_test_helper_.TearDown(); |
152 } | 156 } |
153 | 157 |
154 void RlzLibTestBase::SetUp() { | 158 void RlzLibTestBase::SetUp() { |
155 RlzLibTestNoMachineState::SetUp(); | 159 RlzLibTestNoMachineState::SetUp(); |
156 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
157 rlz_lib::CreateMachineState(); | 161 rlz_lib::CreateMachineState(); |
158 #endif // defined(OS_WIN) | 162 #endif // defined(OS_WIN) |
159 } | 163 } |
OLD | NEW |