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

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

Issue 369923004: rlz: Do not take the address of a temporary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<base::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 base::win::RegKey key(dest->Handle(), iter->first.c_str(), KEY_ALL_ACCESS);
85 &base::win::RegKey(dest->Handle(), iter->first.c_str(), 85 WriteRegistryTree(iter->second, &key);
86 KEY_ALL_ACCESS));
87 } 86 }
88 } 87 }
89 88
90 // Initialize temporary HKLM/HKCU registry hives used for testing. 89 // Initialize temporary HKLM/HKCU registry hives used for testing.
91 // Testing RLZ requires reading and writing to the Windows registry. To keep 90 // Testing RLZ requires reading and writing to the Windows registry. To keep
92 // the tests isolated from the machine's state, as well as to prevent the tests 91 // the tests isolated from the machine's state, as well as to prevent the tests
93 // from causing side effects in the registry, HKCU and HKLM are overridden for 92 // from causing side effects in the registry, HKCU and HKLM are overridden for
94 // the duration of the tests. RLZ tests don't expect the HKCU and KHLM hives to 93 // the duration of the tests. RLZ tests don't expect the HKCU and KHLM hives to
95 // be empty though, and this function initializes the minimum value needed so 94 // be empty though, and this function initializes the minimum value needed so
96 // that the test will run successfully. 95 // that the test will run successfully.
(...skipping 12 matching lines...) Expand all
109 // This seems to be required since Win7. 108 // This seems to be required since Win7.
110 ReadRegistryTree(base::win::RegKey(HKEY_LOCAL_MACHINE, 109 ReadRegistryTree(base::win::RegKey(HKEY_LOCAL_MACHINE,
111 kHKLMAccessProviders, 110 kHKLMAccessProviders,
112 KEY_READ), &data); 111 KEY_READ), &data);
113 } 112 }
114 113
115 override_manager->OverrideRegistry(HKEY_LOCAL_MACHINE, L"rlz_temp_hklm"); 114 override_manager->OverrideRegistry(HKEY_LOCAL_MACHINE, L"rlz_temp_hklm");
116 override_manager->OverrideRegistry(HKEY_CURRENT_USER, L"rlz_temp_hkcu"); 115 override_manager->OverrideRegistry(HKEY_CURRENT_USER, L"rlz_temp_hkcu");
117 116
118 if (do_copy) { 117 if (do_copy) {
119 WriteRegistryTree(data, &base::win::RegKey(HKEY_LOCAL_MACHINE, 118 base::win::RegKey key(
120 kHKLMAccessProviders, 119 HKEY_LOCAL_MACHINE, kHKLMAccessProviders, KEY_ALL_ACCESS);
121 KEY_ALL_ACCESS)); 120 WriteRegistryTree(data, &key);
122 } 121 }
123 } 122 }
124 123
125 } // namespace 124 } // namespace
126 125
127 #endif // defined(OS_WIN) 126 #endif // defined(OS_WIN)
128 127
129 void RlzLibTestNoMachineState::SetUp() { 128 void RlzLibTestNoMachineState::SetUp() {
130 #if defined(OS_WIN) 129 #if defined(OS_WIN)
131 InitializeRegistryOverridesForTesting(&override_manager_); 130 InitializeRegistryOverridesForTesting(&override_manager_);
(...skipping 11 matching lines...) Expand all
143 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath()); 142 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath());
144 #endif // defined(OS_POSIX) 143 #endif // defined(OS_POSIX)
145 } 144 }
146 145
147 void RlzLibTestBase::SetUp() { 146 void RlzLibTestBase::SetUp() {
148 RlzLibTestNoMachineState::SetUp(); 147 RlzLibTestNoMachineState::SetUp();
149 #if defined(OS_WIN) 148 #if defined(OS_WIN)
150 rlz_lib::CreateMachineState(); 149 rlz_lib::CreateMachineState();
151 #endif // defined(OS_WIN) 150 #endif // defined(OS_WIN)
152 } 151 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698