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

Side by Side Diff: chrome/install_static/install_util_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 266
267 class InstallStaticUtilTest 267 class InstallStaticUtilTest
268 : public ::testing::TestWithParam< 268 : public ::testing::TestWithParam<
269 std::tuple<InstallConstantIndex, const char*>> { 269 std::tuple<InstallConstantIndex, const char*>> {
270 protected: 270 protected:
271 InstallStaticUtilTest() 271 InstallStaticUtilTest()
272 : system_level_(std::string(std::get<1>(GetParam())) != "user"), 272 : system_level_(std::string(std::get<1>(GetParam())) != "user"),
273 scoped_install_details_(system_level_, std::get<0>(GetParam())), 273 scoped_install_details_(system_level_, std::get<0>(GetParam())),
274 mode_(&InstallDetails::Get().mode()), 274 mode_(&InstallDetails::Get().mode()),
275 root_key_(system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER), 275 root_key_(system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER),
276 nt_root_key_(system_level_ ? nt::HKLM : nt::HKCU) { 276 nt_root_key_(system_level_ ? nt::HKLM : nt::HKCU) {}
277
278 void SetUp() override {
279 ASSERT_TRUE(!system_level_ || mode_->supports_system_level);
277 base::string16 path; 280 base::string16 path;
278 override_manager_.OverrideRegistry(root_key_, &path); 281 ASSERT_NO_FATAL_FAILURE(
282 override_manager_.OverrideRegistry(root_key_, &path));
279 nt::SetTestingOverride(nt_root_key_, path); 283 nt::SetTestingOverride(nt_root_key_, path);
280 } 284 }
281 285
282 ~InstallStaticUtilTest() { 286 void TearDown() override {
283 nt::SetTestingOverride(nt_root_key_, base::string16()); 287 nt::SetTestingOverride(nt_root_key_, base::string16());
284 } 288 }
285 289
286 void SetUp() override {
287 ASSERT_TRUE(!system_level_ || mode_->supports_system_level);
288 }
289
290 bool system_level() const { return system_level_; } 290 bool system_level() const { return system_level_; }
291 291
292 const wchar_t* default_channel() const { return mode_->default_channel_name; } 292 const wchar_t* default_channel() const { return mode_->default_channel_name; }
293 293
294 void SetUsageStat(DWORD value, bool medium) { 294 void SetUsageStat(DWORD value, bool medium) {
295 ASSERT_TRUE(!medium || system_level_); 295 ASSERT_TRUE(!medium || system_level_);
296 ASSERT_EQ(ERROR_SUCCESS, 296 ASSERT_EQ(ERROR_SUCCESS,
297 base::win::RegKey(root_key_, GetUsageStatsKeyPath(medium).c_str(), 297 base::win::RegKey(root_key_, GetUsageStatsKeyPath(medium).c_str(),
298 KEY_SET_VALUE | KEY_WOW64_32KEY) 298 KEY_SET_VALUE | KEY_WOW64_32KEY)
299 .WriteValue(L"usagestats", value)); 299 .WriteValue(L"usagestats", value));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 testing::Values("user"))); 417 testing::Values("user")));
418 #else // GOOGLE_CHROME_BUILD 418 #else // GOOGLE_CHROME_BUILD
419 // Chromium supports user and system levels. 419 // Chromium supports user and system levels.
420 INSTANTIATE_TEST_CASE_P(Chromium, 420 INSTANTIATE_TEST_CASE_P(Chromium,
421 InstallStaticUtilTest, 421 InstallStaticUtilTest,
422 testing::Combine(testing::Values(CHROMIUM_INDEX), 422 testing::Combine(testing::Values(CHROMIUM_INDEX),
423 testing::Values("user", "system"))); 423 testing::Values("user", "system")));
424 #endif // !GOOGLE_CHROME_BUILD 424 #endif // !GOOGLE_CHROME_BUILD
425 425
426 } // namespace install_static 426 } // namespace install_static
OLDNEW
« no previous file with comments | « chrome/browser/win/chrome_elf_init_unittest.cc ('k') | chrome/install_static/product_install_details_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698