diff options
author | husky@google.com <husky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 14:25:04 +0000 |
---|---|---|
committer | husky@google.com <husky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 14:25:04 +0000 |
commit | cbbb641e6283e2f68ebc4f68da8191a342fa8838 (patch) | |
tree | 896de49d81d567491ff12afb1fea68c648ebaacc /chrome | |
parent | fb8f976cb2b5ce1a8e078852c67e049987edf81f (diff) | |
download | chromium_src-cbbb641e6283e2f68ebc4f68da8191a342fa8838.zip chromium_src-cbbb641e6283e2f68ebc4f68da8191a342fa8838.tar.gz chromium_src-cbbb641e6283e2f68ebc4f68da8191a342fa8838.tar.bz2 |
Replace all usage of FileAutoDeleter with ScopedTempDir.
Review URL: http://codereview.chromium.org/7056011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
5 files changed, 17 insertions, 45 deletions
diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc index ad0d9cb..7524aa5 100644 --- a/chrome/browser/importer/firefox_profile_lock_unittest.cc +++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc @@ -10,7 +10,6 @@ #include "build/build_config.h" #include "chrome/browser/importer/firefox_profile_lock.h" #include "chrome/common/chrome_paths.h" -#include "chrome/test/file_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" class FirefoxProfileLockTest : public testing::Test { @@ -34,12 +33,8 @@ TEST_F(FirefoxProfileLockTest, LockTest) { // Tests basic functionality and verifies that the lock file is deleted after // use. TEST_F(FirefoxProfileLockTest, ProfileLock) { - FilePath test_path; - ASSERT_TRUE(file_util::CreateNewTempDirectory( - FILE_PATH_LITERAL("firefox_profile"), &test_path)); - FilePath lock_file_path = test_path; - FileAutoDeleter deleter(lock_file_path); - lock_file_path = lock_file_path.Append(FirefoxProfileLock::kLockFileName); + FilePath test_path = temp_dir_.path(); + FilePath lock_file_path = test_path.Append(FirefoxProfileLock::kLockFileName); scoped_ptr<FirefoxProfileLock> lock; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get()); @@ -70,12 +65,8 @@ TEST_F(FirefoxProfileLockTest, ProfileLock) { // If for some reason the lock file is left behind by the previous owner, we // should still be able to lock it, at least in the Windows implementation. TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { - FilePath test_path; - ASSERT_TRUE(file_util::CreateNewTempDirectory( - FILE_PATH_LITERAL("firefox_profile"), &test_path)); - FilePath lock_file_path = test_path; - FileAutoDeleter deleter(lock_file_path); - lock_file_path = lock_file_path.Append(FirefoxProfileLock::kLockFileName); + FilePath test_path = temp_dir_.path(); + FilePath lock_file_path = test_path.Append(FirefoxProfileLock::kLockFileName); // Create the orphaned lock file. FILE* lock_file = file_util::OpenFile(lock_file_path, "w"); @@ -96,10 +87,7 @@ TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { #if !defined(OS_POSIX) // Tests two locks contending for the same lock file. TEST_F(FirefoxProfileLockTest, ProfileLockContention) { - FilePath test_path; - ASSERT_TRUE(file_util::CreateNewTempDirectory( - FILE_PATH_LITERAL("firefox_profile"), &test_path)); - FileAutoDeleter deleter(test_path); + FilePath test_path = temp_dir_.path(); scoped_ptr<FirefoxProfileLock> lock1; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock1.get()); diff --git a/chrome/browser/importer/safari_importer_unittest.mm b/chrome/browser/importer/safari_importer_unittest.mm index 519031d..efd9714 100644 --- a/chrome/browser/importer/safari_importer_unittest.mm +++ b/chrome/browser/importer/safari_importer_unittest.mm @@ -9,12 +9,12 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" +#include "base/scoped_temp_dir.h" #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/importer/importer_bridge.h" #include "chrome/common/chrome_paths.h" -#include "chrome/test/file_test_utils.h" #include "testing/platform_test.h" // In order to test the Safari import functionality effectively, we store a @@ -157,8 +157,7 @@ TEST_F(SafariImporterTest, CanImport) { EXPECT_EQ(items & importer::HOME_PAGE, importer::NONE); // Check that we don't import anything from a bogus library directory. - FilePath fake_library_dir; - file_util::CreateNewTempDirectory("FakeSafariLibrary", &fake_library_dir); - FileAutoDeleter deleter(fake_library_dir); - EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir, &items)); + ScopedTempDir fake_library_dir; + ASSERT_TRUE(fake_library_dir.CreateUniqueTempDir()); + EXPECT_FALSE(SafariImporter::CanImport(fake_library_dir.path(), &items)); } diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc index 39fe53a..1eb540e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc @@ -1,12 +1,12 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" #include "base/callback.h" +#include "base/scoped_temp_dir.h" #include "chrome/browser/safe_browsing/safe_browsing_store_unittest_helper.h" -#include "chrome/test/file_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -20,19 +20,10 @@ class SafeBrowsingStoreFileTest : public PlatformTest { virtual void SetUp() { PlatformTest::SetUp(); - FilePath temp_dir; - ASSERT_TRUE(file_util::CreateNewTempDirectory(kFolderPrefix, &temp_dir)); + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); - file_deleter_.reset(new FileAutoDeleter(temp_dir)); - - filename_ = temp_dir; + filename_ = temp_dir_.path(); filename_ = filename_.AppendASCII("SafeBrowsingTestStore"); - file_util::Delete(filename_, false); - - // Make sure an old temporary file isn't hanging around. - const FilePath temp_file = - SafeBrowsingStoreFile::TemporaryFileForFilename(filename_); - file_util::Delete(temp_file, false); store_.reset(new SafeBrowsingStoreFile()); store_->Init(filename_, NULL); @@ -41,7 +32,6 @@ class SafeBrowsingStoreFileTest : public PlatformTest { if (store_.get()) store_->Delete(); store_.reset(); - file_deleter_.reset(); PlatformTest::TearDown(); } @@ -50,7 +40,7 @@ class SafeBrowsingStoreFileTest : public PlatformTest { corruption_detected_ = true; } - scoped_ptr<FileAutoDeleter> file_deleter_; + ScopedTempDir temp_dir_; FilePath filename_; scoped_ptr<SafeBrowsingStoreFile> store_; bool corruption_detected_; @@ -60,8 +50,8 @@ TEST_STORE(SafeBrowsingStoreFileTest, store_.get(), filename_); // Test that Delete() deletes the temporary store, if present. TEST_F(SafeBrowsingStoreFileTest, DeleteTemp) { - const FilePath temp_file = - SafeBrowsingStoreFile::TemporaryFileForFilename(filename_); + const FilePath temp_file = + SafeBrowsingStoreFile::TemporaryFileForFilename(filename_); EXPECT_FALSE(file_util::PathExists(filename_)); EXPECT_FALSE(file_util::PathExists(temp_file)); diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index 6781db4..572c84d 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -18,7 +18,6 @@ #include "chrome/browser/sessions/session_types.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/browser_with_test_window_test.h" -#include "chrome/test/file_test_utils.h" #include "chrome/test/testing_profile.h" #include "content/browser/tab_contents/navigation_entry.h" #include "content/common/notification_observer.h" @@ -39,8 +38,7 @@ class SessionServiceTest : public BrowserWithTestWindowTest, ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("SessionTestDirs")); - file_util::CreateDirectory(path_); - path_deleter_.reset(new FileAutoDeleter(path_)); + ASSERT_TRUE(file_util::CreateDirectory(path_)); path_ = path_.AppendASCII(b); SessionService* session_service = new SessionService(path_); @@ -60,7 +58,6 @@ class SessionServiceTest : public BrowserWithTestWindowTest, virtual void TearDown() { helper_.set_service(NULL); - path_deleter_.reset(); } void UpdateNavigation(const SessionID& window_id, @@ -136,7 +133,6 @@ class SessionServiceTest : public BrowserWithTestWindowTest, // Path used in testing. ScopedTempDir temp_dir_; FilePath path_; - scoped_ptr<FileAutoDeleter> path_deleter_; SessionServiceTestHelper helper_; }; diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index 90bc56e..8f79f67 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -29,7 +29,6 @@ #include "chrome/browser/sync/test_profile_sync_service.h" #include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/test/browser_with_test_window_test.h" -#include "chrome/test/file_test_utils.h" #include "chrome/test/profile_mock.h" #include "chrome/test/sync/engine/test_id_factory.h" #include "chrome/test/testing_profile.h" |