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

Unified Diff: sql/sqlite_features_unittest.cc

Issue 10542096: Avoid leaking any files from SQLiteFeaturesTest. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/sqlite_features_unittest.cc
===================================================================
--- sql/sqlite_features_unittest.cc (revision 141732)
+++ sql/sqlite_features_unittest.cc (working copy)
@@ -4,9 +4,8 @@
#include <string>
-#include "base/file_path.h"
#include "base/file_util.h"
-#include "base/path_service.h"
+#include "base/scoped_temp_dir.h"
#include "sql/connection.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -51,10 +50,9 @@
SQLiteFeaturesTest() : error_handler_(new StatementErrorHandler) {}
void SetUp() {
- ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_));
- path_ = path_.AppendASCII("SQLStatementTest.db");
- file_util::Delete(path_, false);
- ASSERT_TRUE(db_.Open(path_));
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+ ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLStatementTest.db")));
+
// The |error_handler_| will be called if any sqlite statement operation
// returns an error code.
db_.set_error_delegate(error_handler_);
@@ -65,9 +63,6 @@
// error_handler_->sql_statement().
EXPECT_EQ(SQLITE_OK, error_handler_->error());
db_.Close();
- // If this fails something is going on with cleanup and later tests may
- // fail, so we want to identify problems right away.
- ASSERT_TRUE(file_util::Delete(path_, false));
}
sql::Connection& db() { return db_; }
@@ -76,7 +71,7 @@
void reset_error() const { error_handler_->reset_error(); }
private:
- FilePath path_;
+ ScopedTempDir temp_dir_;
sql::Connection db_;
scoped_refptr<StatementErrorHandler> error_handler_;
};
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698