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

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

Issue 591483002: Only send C2F ping for a search through homepage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 2 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::win::RegKey key(dest->Handle(), iter->first.c_str(), KEY_ALL_ACCESS); 84 base::win::RegKey key(dest->Handle(), iter->first.c_str(), KEY_ALL_ACCESS);
85 WriteRegistryTree(iter->second, &key); 85 WriteRegistryTree(iter->second, &key);
86 } 86 }
87 } 87 }
88 88
89 } // namespace
90
89 // Initialize temporary HKLM/HKCU registry hives used for testing. 91 // Initialize temporary HKLM/HKCU registry hives used for testing.
90 // Testing RLZ requires reading and writing to the Windows registry. To keep 92 // Testing RLZ requires reading and writing to the Windows registry. To keep
91 // the tests isolated from the machine's state, as well as to prevent the tests 93 // the tests isolated from the machine's state, as well as to prevent the tests
92 // from causing side effects in the registry, HKCU and HKLM are overridden for 94 // from causing side effects in the registry, HKCU and HKLM are overridden for
93 // the duration of the tests. RLZ tests don't expect the HKCU and KHLM hives to 95 // the duration of the tests. RLZ tests don't expect the HKCU and KHLM hives to
94 // be empty though, and this function initializes the minimum value needed so 96 // be empty though, and this function initializes the minimum value needed so
95 // that the test will run successfully. 97 // that the test will run successfully.
96 void InitializeRegistryOverridesForTesting( 98 void InitializeRegistryOverridesForTesting(
97 registry_util::RegistryOverrideManager* override_manager) { 99 registry_util::RegistryOverrideManager* override_manager) {
98 // For the moment, the HKCU hive requires no initialization. 100 // For the moment, the HKCU hive requires no initialization.
(...skipping 15 matching lines...) Expand all
114 override_manager->OverrideRegistry(HKEY_LOCAL_MACHINE); 116 override_manager->OverrideRegistry(HKEY_LOCAL_MACHINE);
115 override_manager->OverrideRegistry(HKEY_CURRENT_USER); 117 override_manager->OverrideRegistry(HKEY_CURRENT_USER);
116 118
117 if (do_copy) { 119 if (do_copy) {
118 base::win::RegKey key( 120 base::win::RegKey key(
119 HKEY_LOCAL_MACHINE, kHKLMAccessProviders, KEY_ALL_ACCESS); 121 HKEY_LOCAL_MACHINE, kHKLMAccessProviders, KEY_ALL_ACCESS);
120 WriteRegistryTree(data, &key); 122 WriteRegistryTree(data, &key);
121 } 123 }
122 } 124 }
123 125
124 } // namespace
125 126
126 #endif // defined(OS_WIN) 127 #endif // defined(OS_WIN)
127 128
128 void RlzLibTestNoMachineState::SetUp() { 129 void RlzLibTestNoMachineState::SetUp() {
129 #if defined(OS_WIN) 130 #if defined(OS_WIN)
130 InitializeRegistryOverridesForTesting(&override_manager_); 131 InitializeRegistryOverridesForTesting(&override_manager_);
131 #elif defined(OS_MACOSX) 132 #elif defined(OS_MACOSX)
132 base::mac::ScopedNSAutoreleasePool pool; 133 base::mac::ScopedNSAutoreleasePool pool;
133 #endif // defined(OS_WIN) 134 #endif // defined(OS_WIN)
134 #if defined(OS_POSIX) 135 #if defined(OS_POSIX)
135 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 136 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
136 rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path()); 137 rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path());
137 #endif // defined(OS_POSIX) 138 #endif // defined(OS_POSIX)
138 } 139 }
Roger Tawa OOO till Jul 10th 2014/09/30 14:43:35 I think it would be better to put all the code abo
yao 2014/09/30 17:10:44 Are you saying we should have an overloading funct
Roger Tawa OOO till Jul 10th 2014/09/30 18:24:36 No overload, because RlzLibTest no longer derives
yao 2014/09/30 18:30:01 hm... maybe I'm confused, but how are we planning
139 140
140 void RlzLibTestNoMachineState::TearDown() { 141 void RlzLibTestNoMachineState::TearDown() {
141 #if defined(OS_POSIX) 142 #if defined(OS_POSIX)
142 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath()); 143 rlz_lib::testing::SetRlzStoreDirectory(base::FilePath());
143 #endif // defined(OS_POSIX) 144 #endif // defined(OS_POSIX)
144 } 145 }
145 146
146 void RlzLibTestBase::SetUp() { 147 void RlzLibTestBase::SetUp() {
147 RlzLibTestNoMachineState::SetUp(); 148 RlzLibTestNoMachineState::SetUp();
148 #if defined(OS_WIN) 149 #if defined(OS_WIN)
149 rlz_lib::CreateMachineState(); 150 rlz_lib::CreateMachineState();
150 #endif // defined(OS_WIN) 151 #endif // defined(OS_WIN)
151 } 152 }
OLDNEW
« chrome/browser/rlz/rlz_unittest.cc ('K') | « rlz/test/rlz_test_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698