diff options
author | paivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 03:31:16 +0000 |
---|---|---|
committer | paivanof@gmail.com <paivanof@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 03:31:16 +0000 |
commit | 9903468a31bf78d67d0e68def758c72380e44250 (patch) | |
tree | 769dd1e05a8554961966c7e3ab3bb8dcfafd5bca /sql | |
parent | fa6c393a5f739d3639449235725ed135c4bd2990 (diff) | |
download | chromium_src-9903468a31bf78d67d0e68def758c72380e44250.zip chromium_src-9903468a31bf78d67d0e68def758c72380e44250.tar.gz chromium_src-9903468a31bf78d67d0e68def758c72380e44250.tar.bz2 |
Avoid leaking any files from SQLiteFeaturesTest.
Patch from Pavel Ivanov <paivanof@gmail.com>
BUG=130498
TEST=On Linux /tmp/SQLStatementTest.db-journal is not left after execution.
Review URL: https://chromiumcodereview.appspot.com/10542096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sqlite_features_unittest.cc | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/sql/sqlite_features_unittest.cc b/sql/sqlite_features_unittest.cc index 2ae8dd7..08e1819 100644 --- a/sql/sqlite_features_unittest.cc +++ b/sql/sqlite_features_unittest.cc @@ -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 @@ class SQLiteFeaturesTest : public testing::Test { 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 @@ class SQLiteFeaturesTest : public testing::Test { // 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 @@ class SQLiteFeaturesTest : public testing::Test { void reset_error() const { error_handler_->reset_error(); } private: - FilePath path_; + ScopedTempDir temp_dir_; sql::Connection db_; scoped_refptr<StatementErrorHandler> error_handler_; }; |