| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/test/test_reg_util_win.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "base/version.h" | 18 #include "base/version.h" |
| 18 #include "base/win/registry.h" | 19 #include "base/win/registry.h" |
| 19 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
| 20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/installer/util/fake_installation_state.h" | 22 #include "chrome/installer/util/fake_installation_state.h" |
| 22 #include "chrome/installer/util/fake_product_state.h" | 23 #include "chrome/installer/util/fake_product_state.h" |
| 23 #include "chrome/installer/util/google_update_constants.h" | 24 #include "chrome/installer/util/google_update_constants.h" |
| 24 #include "chrome/installer/util/helper.h" | 25 #include "chrome/installer/util/helper.h" |
| 25 #include "chrome/installer/util/installation_state.h" | 26 #include "chrome/installer/util/installation_state.h" |
| 26 #include "chrome/installer/util/installer_state.h" | 27 #include "chrome/installer/util/installer_state.h" |
| 27 #include "chrome/installer/util/master_preferences.h" | 28 #include "chrome/installer/util/master_preferences.h" |
| 28 #include "chrome/installer/util/product_unittest.h" | 29 #include "chrome/installer/util/product_unittest.h" |
| 29 #include "chrome/installer/util/work_item.h" | 30 #include "chrome/installer/util/work_item.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 32 |
| 32 #include "installer_util_strings.h" // NOLINT | 33 #include "installer_util_strings.h" // NOLINT |
| 33 | 34 |
| 34 using base::win::RegKey; | 35 using base::win::RegKey; |
| 35 using installer::InstallationState; | 36 using installer::InstallationState; |
| 36 using installer::InstallerState; | 37 using installer::InstallerState; |
| 37 using installer::MasterPreferences; | 38 using installer::MasterPreferences; |
| 39 using reg_util::TempRegKeyOverride; |
| 38 | 40 |
| 39 class InstallerStateTest : public TestWithTempDirAndDeleteTempOverrideKeys { | 41 class InstallerStateTest : public TestWithTempDirAndDeleteTempOverrideKeys { |
| 40 protected: | 42 protected: |
| 41 }; | 43 }; |
| 42 | 44 |
| 43 // An installer state on which we can tweak the target path. | 45 // An installer state on which we can tweak the target path. |
| 44 class MockInstallerState : public InstallerState { | 46 class MockInstallerState : public InstallerState { |
| 45 public: | 47 public: |
| 46 MockInstallerState() : InstallerState() { } | 48 MockInstallerState() : InstallerState() { } |
| 47 void set_target_path(const FilePath& target_path) { | 49 void set_target_path(const FilePath& target_path) { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 NULL, OPEN_EXISTING, 0, 0)); | 482 NULL, OPEN_EXISTING, 0, 0)); |
| 481 ASSERT_TRUE(temp_handle != NULL); | 483 ASSERT_TRUE(temp_handle != NULL); |
| 482 | 484 |
| 483 // The file should now be in use. | 485 // The file should now be in use. |
| 484 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); | 486 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); |
| 485 } | 487 } |
| 486 | 488 |
| 487 // And once the handle is gone, it should no longer be in use. | 489 // And once the handle is gone, it should no longer be in use. |
| 488 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); | 490 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
| 489 } | 491 } |
| OLD | NEW |