| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 ASSERT_TRUE(temp_handle != NULL); | 488 ASSERT_TRUE(temp_handle != NULL); |
| 489 | 489 |
| 490 // The file should now be in use. | 490 // The file should now be in use. |
| 491 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); | 491 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); |
| 492 } | 492 } |
| 493 | 493 |
| 494 // And once the handle is gone, it should no longer be in use. | 494 // And once the handle is gone, it should no longer be in use. |
| 495 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); | 495 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
| 496 } | 496 } |
| 497 | 497 |
| 498 TEST_F(InstallerStateTest, IsNonExistantFileInUse) { |
| 499 base::ScopedTempDir temp_dir; |
| 500 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 501 |
| 502 FilePath temp_file; |
| 503 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp_file)); |
| 504 ASSERT_TRUE(file_util::Delete(temp_file, false)); |
| 505 |
| 506 // There's no file, so it had better not be in use. |
| 507 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
| 508 } |
| 498 | 509 |
| 499 TEST_F(InstallerStateTest, RemoveOldVersionDirs) { | 510 TEST_F(InstallerStateTest, RemoveOldVersionDirs) { |
| 500 MockInstallerState installer_state; | 511 MockInstallerState installer_state; |
| 501 installer_state.set_target_path(test_dir_.path()); | 512 installer_state.set_target_path(test_dir_.path()); |
| 502 EXPECT_EQ(test_dir_.path().value(), installer_state.target_path().value()); | 513 EXPECT_EQ(test_dir_.path().value(), installer_state.target_path().value()); |
| 503 | 514 |
| 504 const char kOldVersion[] = "2.0.0.0"; | 515 const char kOldVersion[] = "2.0.0.0"; |
| 505 const char kNewVersion[] = "3.0.0.0"; | 516 const char kNewVersion[] = "3.0.0.0"; |
| 506 const char kOldChromeExeVersion[] = "2.1.0.0"; | 517 const char kOldChromeExeVersion[] = "2.1.0.0"; |
| 507 const char kChromeExeVersion[] = "2.1.1.1"; | 518 const char kChromeExeVersion[] = "2.1.1.1"; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 // Critical update newer than the new version. | 759 // Critical update newer than the new version. |
| 749 EXPECT_FALSE( | 760 EXPECT_FALSE( |
| 750 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); | 761 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); |
| 751 EXPECT_FALSE( | 762 EXPECT_FALSE( |
| 752 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) | 763 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) |
| 753 .IsValid()); | 764 .IsValid()); |
| 754 EXPECT_FALSE( | 765 EXPECT_FALSE( |
| 755 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) | 766 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) |
| 756 .IsValid()); | 767 .IsValid()); |
| 757 } | 768 } |
| OLD | NEW |