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" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); | 479 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
480 | 480 |
481 { | 481 { |
482 // Open a handle to the file with the same access mode and sharing options | 482 // Open a handle to the file with the same access mode and sharing options |
483 // as the loader. | 483 // as the loader. |
484 base::win::ScopedHandle temp_handle( | 484 base::win::ScopedHandle temp_handle( |
485 CreateFile(temp_file.value().c_str(), | 485 CreateFile(temp_file.value().c_str(), |
486 SYNCHRONIZE | FILE_EXECUTE, | 486 SYNCHRONIZE | FILE_EXECUTE, |
487 FILE_SHARE_DELETE | FILE_SHARE_READ, | 487 FILE_SHARE_DELETE | FILE_SHARE_READ, |
488 NULL, OPEN_EXISTING, 0, 0)); | 488 NULL, OPEN_EXISTING, 0, 0)); |
489 ASSERT_TRUE(temp_handle != NULL); | 489 ASSERT_TRUE(temp_handle.IsValid()); |
490 | 490 |
491 // The file should now be in use. | 491 // The file should now be in use. |
492 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); | 492 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); |
493 } | 493 } |
494 | 494 |
495 // And once the handle is gone, it should no longer be in use. | 495 // And once the handle is gone, it should no longer be in use. |
496 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); | 496 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
497 } | 497 } |
498 | 498 |
499 TEST_F(InstallerStateTest, RemoveOldVersionDirs) { | 499 TEST_F(InstallerStateTest, RemoveOldVersionDirs) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 // Critical update newer than the new version. | 818 // Critical update newer than the new version. |
819 EXPECT_FALSE( | 819 EXPECT_FALSE( |
820 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); | 820 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); |
821 EXPECT_FALSE( | 821 EXPECT_FALSE( |
822 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) | 822 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) |
823 .IsValid()); | 823 .IsValid()); |
824 EXPECT_FALSE( | 824 EXPECT_FALSE( |
825 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) | 825 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) |
826 .IsValid()); | 826 .IsValid()); |
827 } | 827 } |
OLD | NEW |