| OLD | NEW |
| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 EXPECT_TRUE(!system_level_ || mode_->supports_system_level); | 280 EXPECT_TRUE(!system_level_ || mode_->supports_system_level); |
| 281 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 281 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 282 nt_root_key_ = system_level_ ? nt::HKLM : nt::HKCU; | 282 nt_root_key_ = system_level_ ? nt::HKLM : nt::HKCU; |
| 283 | 283 |
| 284 std::unique_ptr<PrimaryInstallDetails> details = | 284 std::unique_ptr<PrimaryInstallDetails> details = |
| 285 base::MakeUnique<PrimaryInstallDetails>(); | 285 base::MakeUnique<PrimaryInstallDetails>(); |
| 286 details->set_mode(mode_); | 286 details->set_mode(mode_); |
| 287 details->set_channel(mode_->default_channel_name); | 287 details->set_channel(mode_->default_channel_name); |
| 288 details->set_system_level(system_level_); | 288 details->set_system_level(system_level_); |
| 289 InstallDetails::SetForProcess(std::move(details)); | 289 InstallDetails::SetForProcess(std::move(details)); |
| 290 | |
| 291 base::string16 path; | |
| 292 override_manager_.OverrideRegistry(root_key_, &path); | |
| 293 nt::SetTestingOverride(nt_root_key_, path); | |
| 294 } | 290 } |
| 295 | 291 |
| 296 ~InstallStaticUtilTest() { | 292 ~InstallStaticUtilTest() { |
| 297 InstallDetails::SetForProcess(nullptr); | 293 InstallDetails::SetForProcess(nullptr); |
| 298 nt::SetTestingOverride(nt_root_key_, base::string16()); | 294 nt::SetTestingOverride(nt_root_key_, base::string16()); |
| 299 } | 295 } |
| 300 | 296 |
| 297 void SetUp() override { |
| 298 base::string16 path; |
| 299 ASSERT_NO_FATAL_FAILURE( |
| 300 override_manager_.OverrideRegistry(root_key_, &path)); |
| 301 nt::SetTestingOverride(nt_root_key_, path); |
| 302 } |
| 303 |
| 301 bool system_level() const { return system_level_; } | 304 bool system_level() const { return system_level_; } |
| 302 | 305 |
| 303 const wchar_t* default_channel() const { return mode_->default_channel_name; } | 306 const wchar_t* default_channel() const { return mode_->default_channel_name; } |
| 304 | 307 |
| 305 void SetUsageStat(DWORD value, bool medium) { | 308 void SetUsageStat(DWORD value, bool medium) { |
| 306 ASSERT_TRUE(!medium || system_level_); | 309 ASSERT_TRUE(!medium || system_level_); |
| 307 ASSERT_EQ(ERROR_SUCCESS, | 310 ASSERT_EQ(ERROR_SUCCESS, |
| 308 base::win::RegKey(root_key_, GetUsageStatsKeyPath(medium).c_str(), | 311 base::win::RegKey(root_key_, GetUsageStatsKeyPath(medium).c_str(), |
| 309 KEY_SET_VALUE | KEY_WOW64_32KEY) | 312 KEY_SET_VALUE | KEY_WOW64_32KEY) |
| 310 .WriteValue(L"usagestats", value)); | 313 .WriteValue(L"usagestats", value)); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 testing::Values("user"))); | 430 testing::Values("user"))); |
| 428 #else // GOOGLE_CHROME_BUILD | 431 #else // GOOGLE_CHROME_BUILD |
| 429 // Chromium supports user and system levels. | 432 // Chromium supports user and system levels. |
| 430 INSTANTIATE_TEST_CASE_P(Chromium, | 433 INSTANTIATE_TEST_CASE_P(Chromium, |
| 431 InstallStaticUtilTest, | 434 InstallStaticUtilTest, |
| 432 testing::Combine(testing::Values(CHROMIUM_INDEX), | 435 testing::Combine(testing::Values(CHROMIUM_INDEX), |
| 433 testing::Values("user", "system"))); | 436 testing::Values("user", "system"))); |
| 434 #endif // !GOOGLE_CHROME_BUILD | 437 #endif // !GOOGLE_CHROME_BUILD |
| 435 | 438 |
| 436 } // namespace install_static | 439 } // namespace install_static |
| OLD | NEW |