| OLD | NEW |
| 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 #include <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_enumerator.h" | 11 #include "base/files/file_enumerator.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/scoped_path_override.h" |
| 18 #include "base/test/test_reg_util_win.h" | 19 #include "base/test/test_reg_util_win.h" |
| 19 #include "base/version.h" | 20 #include "base/version.h" |
| 20 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
| 21 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
| 22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/installer/test/alternate_version_generator.h" | 24 #include "chrome/installer/test/alternate_version_generator.h" |
| 24 #include "chrome/installer/util/fake_installation_state.h" | 25 #include "chrome/installer/util/fake_installation_state.h" |
| 25 #include "chrome/installer/util/fake_product_state.h" | 26 #include "chrome/installer/util/fake_product_state.h" |
| 26 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
| 27 #include "chrome/installer/util/helper.h" | 28 #include "chrome/installer/util/helper.h" |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 | 599 |
| 599 std::set<std::string>::const_iterator iter( | 600 std::set<std::string>::const_iterator iter( |
| 600 expected_remaining_dirs.begin()); | 601 expected_remaining_dirs.begin()); |
| 601 for (; iter != expected_remaining_dirs.end(); ++iter) | 602 for (; iter != expected_remaining_dirs.end(); ++iter) |
| 602 ADD_FAILURE() << "Expected to find version dir for " << *iter; | 603 ADD_FAILURE() << "Expected to find version dir for " << *iter; |
| 603 } | 604 } |
| 604 | 605 |
| 605 TEST_F(InstallerStateTest, InitializeTwice) { | 606 TEST_F(InstallerStateTest, InitializeTwice) { |
| 607 // Override these paths so that they can be found after the registry override |
| 608 // manager is in place. |
| 609 base::FilePath temp; |
| 610 PathService::Get(base::DIR_PROGRAM_FILES, &temp); |
| 611 base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES, |
| 612 temp); |
| 613 PathService::Get(base::DIR_PROGRAM_FILESX86, &temp); |
| 614 base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86, |
| 615 temp); |
| 616 PathService::Get(base::DIR_LOCAL_APP_DATA, &temp); |
| 617 base::ScopedPathOverride local_app_data_override(base::DIR_LOCAL_APP_DATA, |
| 618 temp); |
| 619 registry_util::RegistryOverrideManager override_manager; |
| 620 override_manager.OverrideRegistry(HKEY_CURRENT_USER, base::string16()); |
| 621 override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE, base::string16()); |
| 622 |
| 606 InstallationState machine_state; | 623 InstallationState machine_state; |
| 607 machine_state.Initialize(); | 624 machine_state.Initialize(); |
| 608 | 625 |
| 609 InstallerState installer_state; | 626 InstallerState installer_state; |
| 610 | 627 |
| 611 // Initialize the instance to install multi Chrome. | 628 // Initialize the instance to install multi Chrome. |
| 612 { | 629 { |
| 613 CommandLine cmd_line( | 630 CommandLine cmd_line( |
| 614 CommandLine::FromString(L"setup.exe --multi-install --chrome")); | 631 CommandLine::FromString(L"setup.exe --multi-install --chrome")); |
| 615 MasterPreferences prefs(cmd_line); | 632 MasterPreferences prefs(cmd_line); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 // Critical update newer than the new version. | 818 // Critical update newer than the new version. |
| 802 EXPECT_FALSE( | 819 EXPECT_FALSE( |
| 803 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); | 820 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); |
| 804 EXPECT_FALSE( | 821 EXPECT_FALSE( |
| 805 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) | 822 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) |
| 806 .IsValid()); | 823 .IsValid()); |
| 807 EXPECT_FALSE( | 824 EXPECT_FALSE( |
| 808 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) | 825 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) |
| 809 .IsValid()); | 826 .IsValid()); |
| 810 } | 827 } |
| OLD | NEW |