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

Side by Side Diff: rlz/test/rlz_test_helpers.cc

Issue 102833007: Add base:: to string16 in rlz/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missed one Created 7 years 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 | « rlz/mac/lib/machine_id_mac.cc ('k') | rlz/win/lib/machine_id_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 26
27 namespace { 27 namespace {
28 28
29 // Path to recursively copy into the replacemment hives. These are needed 29 // 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 30 // to make sure certain win32 APIs continue to run correctly once the real
31 // hives are replaced. 31 // hives are replaced.
32 const wchar_t kHKLMAccessProviders[] = 32 const wchar_t kHKLMAccessProviders[] =
33 L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders"; 33 L"System\\CurrentControlSet\\Control\\Lsa\\AccessProviders";
34 34
35 struct RegistryValue { 35 struct RegistryValue {
36 string16 name; 36 base::string16 name;
37 DWORD type; 37 DWORD type;
38 std::vector<uint8> data; 38 std::vector<uint8> data;
39 }; 39 };
40 40
41 struct RegistryKeyData { 41 struct RegistryKeyData {
42 std::vector<RegistryValue> values; 42 std::vector<RegistryValue> values;
43 std::map<string16, RegistryKeyData> keys; 43 std::map<base::string16, RegistryKeyData> keys;
44 }; 44 };
45 45
46 void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) { 46 void ReadRegistryTree(const base::win::RegKey& src, RegistryKeyData* data) {
47 // First read values. 47 // First read values.
48 { 48 {
49 base::win::RegistryValueIterator i(src.Handle(), L""); 49 base::win::RegistryValueIterator i(src.Handle(), L"");
50 data->values.clear(); 50 data->values.clear();
51 data->values.reserve(i.ValueCount()); 51 data->values.reserve(i.ValueCount());
52 for (; i.Valid(); ++i) { 52 for (; i.Valid(); ++i) {
53 RegistryValue& value = *data->values.insert(data->values.end(), 53 RegistryValue& value = *data->values.insert(data->values.end(),
54 RegistryValue()); 54 RegistryValue());
55 const uint8* data = reinterpret_cast<const uint8*>(i.Value()); 55 const uint8* data = reinterpret_cast<const uint8*>(i.Value());
56 value.name.assign(i.Name()); 56 value.name.assign(i.Name());
57 value.type = i.Type(); 57 value.type = i.Type();
58 value.data.assign(data, data + i.ValueSize()); 58 value.data.assign(data, data + i.ValueSize());
59 } 59 }
60 } 60 }
61 61
62 // Next read subkeys recursively. 62 // Next read subkeys recursively.
63 for (base::win::RegistryKeyIterator i(src.Handle(), L""); 63 for (base::win::RegistryKeyIterator i(src.Handle(), L"");
64 i.Valid(); ++i) { 64 i.Valid(); ++i) {
65 ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ), 65 ReadRegistryTree(base::win::RegKey(src.Handle(), i.Name(), KEY_READ),
66 &data->keys[string16(i.Name())]); 66 &data->keys[base::string16(i.Name())]);
67 } 67 }
68 } 68 }
69 69
70 void WriteRegistryTree(const RegistryKeyData& data, base::win::RegKey* dest) { 70 void WriteRegistryTree(const RegistryKeyData& data, base::win::RegKey* dest) {
71 // First write values. 71 // First write values.
72 for (size_t i = 0; i < data.values.size(); ++i) { 72 for (size_t i = 0; i < data.values.size(); ++i) {
73 const RegistryValue& value = data.values[i]; 73 const RegistryValue& value = data.values[i];
74 dest->WriteValue(value.name.c_str(), 74 dest->WriteValue(value.name.c_str(),
75 value.data.size() ? &value.data[0] : NULL, 75 value.data.size() ? &value.data[0] : NULL,
76 static_cast<DWORD>(value.data.size()), 76 static_cast<DWORD>(value.data.size()),
77 value.type); 77 value.type);
78 } 78 }
79 79
80 // Next write values recursively. 80 // Next write values recursively.
81 for (std::map<string16, RegistryKeyData>::const_iterator iter = 81 for (std::map<base::string16, RegistryKeyData>::const_iterator iter =
82 data.keys.begin(); 82 data.keys.begin();
83 iter != data.keys.end(); ++iter) { 83 iter != data.keys.end(); ++iter) {
84 WriteRegistryTree(iter->second, 84 WriteRegistryTree(iter->second,
85 &base::win::RegKey(dest->Handle(), iter->first.c_str(), 85 &base::win::RegKey(dest->Handle(), iter->first.c_str(),
86 KEY_ALL_ACCESS)); 86 KEY_ALL_ACCESS));
87 } 87 }
88 } 88 }
89 89
90 // Initialize temporary HKLM/HKCU registry hives used for testing. 90 // Initialize temporary HKLM/HKCU registry hives used for testing.
91 // Testing RLZ requires reading and writing to the Windows registry. To keep 91 // Testing RLZ requires reading and writing to the Windows registry. To keep
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath()); 143 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath());
144 #endif // defined(OS_POSIX) 144 #endif // defined(OS_POSIX)
145 } 145 }
146 146
147 void RlzLibTestBase::SetUp() { 147 void RlzLibTestBase::SetUp() {
148 RlzLibTestNoMachineState::SetUp(); 148 RlzLibTestNoMachineState::SetUp();
149 #if defined(OS_WIN) 149 #if defined(OS_WIN)
150 rlz_lib::CreateMachineState(); 150 rlz_lib::CreateMachineState();
151 #endif // defined(OS_WIN) 151 #endif // defined(OS_WIN)
152 } 152 }
OLDNEW
« no previous file with comments | « rlz/mac/lib/machine_id_mac.cc ('k') | rlz/win/lib/machine_id_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698