Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2008)

Unified Diff: chrome/installer/util/installer_state_unittest.cc

Issue 7353030: Cause new_chrome.exe to always be written if Chrome Frame is in use, resulting in updates being d... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/installer_state.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/installer_state_unittest.cc
===================================================================
--- chrome/installer/util/installer_state_unittest.cc (revision 91508)
+++ chrome/installer/util/installer_state_unittest.cc (working copy)
@@ -47,6 +47,9 @@
void set_target_path(const FilePath& target_path) {
target_path_ = target_path;
}
+ static bool IsFileInUse(const FilePath& file) {
+ return InstallerState::IsFileInUse(file);
+ }
};
// Simple function to dump some text into a new file.
@@ -457,3 +460,30 @@
scoped_ptr<Version> version(installer_state.GetCurrentVersion(machine_state));
EXPECT_TRUE(version.get() != NULL);
}
+
+TEST_F(InstallerStateTest, IsFileInUse) {
+ ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ FilePath temp_file;
+ ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir.path(), &temp_file));
+
+ EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file));
+
+ {
+ // Open a handle to the file with the same access mode and sharing options
+ // as the loader.
+ base::win::ScopedHandle temp_handle(
+ CreateFile(temp_file.value().c_str(),
+ SYNCHRONIZE | FILE_EXECUTE,
+ FILE_SHARE_DELETE | FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, 0, 0));
+ ASSERT_TRUE(temp_handle != NULL);
+
+ // The file should now be in use.
+ EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file));
+ }
+
+ // And once the handle is gone, it should no longer be in use.
+ EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file));
+}
« no previous file with comments | « chrome/installer/util/installer_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698