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

Side by Side Diff: chrome/installer/util/beacons_unittest.cc

Issue 2692843002: Fail tests fast if overriding the Windows registry fails. (Closed)
Patch Set: sync to position 450085 Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/installer/util/beacons.h" 5 #include "chrome/installer/util/beacons.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/test/scoped_path_override.h" 10 #include "base/test/scoped_path_override.h"
(...skipping 23 matching lines...) Expand all
34 static const base::char16 kBeaconName[]; 34 static const base::char16 kBeaconName[];
35 35
36 BeaconTest() 36 BeaconTest()
37 : beacon_type_(::testing::get<0>(GetParam())), 37 : beacon_type_(::testing::get<0>(GetParam())),
38 beacon_scope_(::testing::get<1>(GetParam())), 38 beacon_scope_(::testing::get<1>(GetParam())),
39 system_install_(::testing::get<2>(GetParam())), 39 system_install_(::testing::get<2>(GetParam())),
40 beacon_(kBeaconName, 40 beacon_(kBeaconName,
41 beacon_type_, 41 beacon_type_,
42 beacon_scope_, 42 beacon_scope_,
43 system_install_, 43 system_install_,
44 app_registration_data_) { 44 app_registration_data_) {}
45
46 void SetUp() override {
45 // Override the registry so that tests can freely push state to it. 47 // Override the registry so that tests can freely push state to it.
46 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 48 ASSERT_NO_FATAL_FAILURE(
47 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); 49 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
50 ASSERT_NO_FATAL_FAILURE(
51 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE));
48 } 52 }
49 53
50 TestAppRegistrationData app_registration_data_; 54 TestAppRegistrationData app_registration_data_;
51 BeaconType beacon_type_; 55 BeaconType beacon_type_;
52 BeaconScope beacon_scope_; 56 BeaconScope beacon_scope_;
53 bool system_install_; 57 bool system_install_;
54 Beacon beacon_; 58 Beacon beacon_;
55 59
56 private: 60 private:
57 registry_util::RegistryOverrideManager registry_override_manager_; 61 registry_util::RegistryOverrideManager registry_override_manager_;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 base::DIR_PROGRAM_FILESX86, 174 base::DIR_PROGRAM_FILESX86,
171 base::DIR_LOCAL_APP_DATA, 175 base::DIR_LOCAL_APP_DATA,
172 }; 176 };
173 for (int key : kPathKeys) { 177 for (int key : kPathKeys) {
174 base::FilePath temp; 178 base::FilePath temp;
175 PathService::Get(key, &temp); 179 PathService::Get(key, &temp);
176 path_overrides_.push_back(new base::ScopedPathOverride(key, temp)); 180 path_overrides_.push_back(new base::ScopedPathOverride(key, temp));
177 } 181 }
178 182
179 // Override the registry so that tests can freely push state to it. 183 // Override the registry so that tests can freely push state to it.
180 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 184 ASSERT_NO_FATAL_FAILURE(
181 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); 185 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
186 ASSERT_NO_FATAL_FAILURE(
187 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE));
182 188
183 // Ensure that IsPerUserInstall returns the proper value. 189 // Ensure that IsPerUserInstall returns the proper value.
184 ASSERT_EQ(!system_install_, InstallUtil::IsPerUserInstall(chrome_exe_)); 190 ASSERT_EQ(!system_install_, InstallUtil::IsPerUserInstall(chrome_exe_));
185 191
186 distribution_ = BrowserDistribution::GetDistribution(); 192 distribution_ = BrowserDistribution::GetDistribution();
187 } 193 }
188 194
189 bool system_install_; 195 bool system_install_;
190 bool chrome_sxs_; 196 bool chrome_sxs_;
191 base::FilePath chrome_exe_; 197 base::FilePath chrome_exe_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 INSTANTIATE_TEST_CASE_P(UserLevelChrome, 278 INSTANTIATE_TEST_CASE_P(UserLevelChrome,
273 DefaultBrowserBeaconTest, 279 DefaultBrowserBeaconTest,
274 Values(DistributionVariant::USER_LEVEL)); 280 Values(DistributionVariant::USER_LEVEL));
275 #if 0 && defined(GOOGLE_CHROME_BUILD) 281 #if 0 && defined(GOOGLE_CHROME_BUILD)
276 // Disabled for now since InstallUtil::IsChromeSxSProcess makes this impossible. 282 // Disabled for now since InstallUtil::IsChromeSxSProcess makes this impossible.
277 INSTANTIATE_TEST_CASE_P(ChromeSxS, DefaultBrowserBeaconTest, 283 INSTANTIATE_TEST_CASE_P(ChromeSxS, DefaultBrowserBeaconTest,
278 Values(DistributionVariant::SXS)); 284 Values(DistributionVariant::SXS));
279 #endif 285 #endif
280 286
281 } // namespace installer_util 287 } // namespace installer_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698