diff options
author | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 13:40:53 +0000 |
---|---|---|
committer | mkwst@chromium.org <mkwst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-12 13:40:53 +0000 |
commit | 3a305db06850635febc42acc54b65a93bf5739c7 (patch) | |
tree | 1e79d71199dd8bf13c31b94ee53a25c3afd1fe6b /app | |
parent | ca0269fee674ebe4f233ae7f1efa91f503a8c784 (diff) | |
download | chromium_src-3a305db06850635febc42acc54b65a93bf5739c7.zip chromium_src-3a305db06850635febc42acc54b65a93bf5739c7.tar.gz chromium_src-3a305db06850635febc42acc54b65a93bf5739c7.tar.bz2 |
Replacing base::DIR_TEMP with ScopedTempDir when appropriate.
BUG=73854
TEST=unit_tests
Review URL: http://codereview.chromium.org/6793008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/sql/connection_unittest.cc | 17 | ||||
-rw-r--r-- | app/sql/statement_unittest.cc | 17 | ||||
-rw-r--r-- | app/sql/transaction_unittest.cc | 18 |
3 files changed, 17 insertions, 35 deletions
diff --git a/app/sql/connection_unittest.cc b/app/sql/connection_unittest.cc index 0a14a9a..880bb81 100644 --- a/app/sql/connection_unittest.cc +++ b/app/sql/connection_unittest.cc @@ -1,12 +1,11 @@ -// 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 "app/sql/connection.h" #include "app/sql/statement.h" -#include "base/file_path.h" #include "base/file_util.h" -#include "base/path_service.h" +#include "base/memory/scoped_temp_dir.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/sqlite/sqlite3.h" @@ -15,24 +14,18 @@ class SQLConnectionTest : public testing::Test { SQLConnectionTest() {} void SetUp() { - ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_)); - path_ = path_.AppendASCII("SQLConnectionTest.db"); - file_util::Delete(path_, false); - ASSERT_TRUE(db_.Open(path_)); + ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); + ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLConnectionTest.db"))); } void TearDown() { 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_; } private: - FilePath path_; + ScopedTempDir temp_dir_; sql::Connection db_; }; diff --git a/app/sql/statement_unittest.cc b/app/sql/statement_unittest.cc index f9271a7..2cefd18 100644 --- a/app/sql/statement_unittest.cc +++ b/app/sql/statement_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 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. @@ -6,9 +6,8 @@ #include "app/sql/connection.h" #include "app/sql/statement.h" -#include "base/file_path.h" #include "base/file_util.h" -#include "base/path_service.h" +#include "base/memory/scoped_temp_dir.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/sqlite/sqlite3.h" @@ -43,10 +42,9 @@ class SQLStatementTest : public testing::Test { SQLStatementTest() : 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_); @@ -57,9 +55,6 @@ class SQLStatementTest : 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_; } @@ -68,7 +63,7 @@ class SQLStatementTest : 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_; }; diff --git a/app/sql/transaction_unittest.cc b/app/sql/transaction_unittest.cc index 9ca6bbd..c8e986d 100644 --- a/app/sql/transaction_unittest.cc +++ b/app/sql/transaction_unittest.cc @@ -1,13 +1,12 @@ -// Copyright (c) 2009 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 "app/sql/connection.h" #include "app/sql/statement.h" #include "app/sql/transaction.h" -#include "base/file_path.h" #include "base/file_util.h" -#include "base/path_service.h" +#include "base/memory/scoped_temp_dir.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/sqlite/sqlite3.h" @@ -16,20 +15,15 @@ class SQLTransactionTest : public testing::Test { SQLTransactionTest() {} 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("SQLTransactionTest.db"))); ASSERT_TRUE(db().Execute("CREATE TABLE foo (a, b)")); } void TearDown() { 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_; } @@ -42,7 +36,7 @@ class SQLTransactionTest : public testing::Test { } private: - FilePath path_; + ScopedTempDir temp_dir_; sql::Connection db_; }; |