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

Unified Diff: chrome/browser/history/text_database_unittest.cc

Issue 6793008: Replacing base::DIR_TEMP with ScopedTempDir when appropriate. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: I obviously need a Windows test machine. Created 9 years, 8 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
Index: chrome/browser/history/text_database_unittest.cc
diff --git a/chrome/browser/history/text_database_unittest.cc b/chrome/browser/history/text_database_unittest.cc
index fb94eba8e5cbec2aac46813d8c674c25dd578553..3564c82ed3b18ea1cb7a7d0494aeb9334acf1862 100644
--- a/chrome/browser/history/text_database_unittest.cc
+++ b/chrome/browser/history/text_database_unittest.cc
@@ -6,7 +6,7 @@
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/path_service.h"
+#include "base/memory/scoped_temp_dir.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/history/text_database.h"
@@ -92,14 +92,7 @@ class TextDatabaseTest : public PlatformTest {
protected:
void SetUp() {
PlatformTest::SetUp();
- PathService::Get(base::DIR_TEMP, &temp_path_);
- }
-
- void TearDown() {
- for (size_t i = 0; i < opened_files_.size(); i++)
- file_util::Delete(opened_files_[i], false);
- file_util::Delete(file_name_, false);
- PlatformTest::TearDown();
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
// Create databases with this function, which will ensure that the files are
@@ -112,7 +105,7 @@ class TextDatabaseTest : public PlatformTest {
TextDatabase* CreateDB(TextDatabase::DBIdent id,
bool allow_create,
bool delete_file) {
- TextDatabase* db = new TextDatabase(temp_path_, id, allow_create);
+ TextDatabase* db = new TextDatabase(temp_dir_.path(), id, allow_create);
if (delete_file)
file_util::Delete(db->file_name(), false);
@@ -121,17 +114,14 @@ class TextDatabaseTest : public PlatformTest {
delete db;
return NULL;
}
- opened_files_.push_back(db->file_name());
return db;
}
// Directory containing the databases.
- FilePath temp_path_;
+ ScopedTempDir temp_dir_;
// Name of the main database file.
FilePath file_name_;
-
- std::vector<FilePath> opened_files_;
};
TEST_F(TextDatabaseTest, AttachDetach) {
@@ -183,7 +173,7 @@ TEST_F(TextDatabaseTest, AddRemove) {
EXPECT_EQ(2, RowCount(db.get()));
// Close and reopen.
- db.reset(new TextDatabase(temp_path_, kIdee1, false));
+ db.reset(new TextDatabase(temp_dir_.path(), kIdee1, false));
EXPECT_TRUE(db->Init());
// Verify that the deleted ID is gone and try to delete another one.

Powered by Google App Engine
This is Rietveld 408576698