Commit 296ddc16 authored by shess@chromium.org's avatar shess@chromium.org

Use ScopedTempDir instead of DIR_TEST_DATA for creating test data.

BUG=125513
TEST=git status


Review URL: https://chromiumcodereview.appspot.com/10386222

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138071 0039d316-1c4b-4281-b951-d872f2087c98
parent 984aa49c
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/time.h" #include "base/time.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
...@@ -19,19 +20,12 @@ using webkit::forms::PasswordForm; ...@@ -19,19 +20,12 @@ using webkit::forms::PasswordForm;
class LoginDatabaseTest : public testing::Test { class LoginDatabaseTest : public testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
PathService::Get(chrome::DIR_TEST_DATA, &file_); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
const std::string test_db = file_ = temp_dir_.path().AppendASCII("TestMetadataStoreMacDatabase");
"TestMetadataStoreMacDatabase" +
base::Int64ToString(base::Time::Now().ToInternalValue()) + ".db";
file_ = file_.AppendASCII(test_db);
file_util::Delete(file_, false);
}
virtual void TearDown() {
file_util::Delete(file_, false);
} }
FilePath file_; FilePath file_;
ScopedTempDir temp_dir_;
}; };
TEST_F(LoginDatabaseTest, Logins) { TEST_F(LoginDatabaseTest, Logins) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/time.h" #include "base/time.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
...@@ -97,16 +98,8 @@ class AutofillTableTest : public testing::Test { ...@@ -97,16 +98,8 @@ class AutofillTableTest : public testing::Test {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
Encryptor::UseMockKeychain(true); Encryptor::UseMockKeychain(true);
#endif #endif
PathService::Get(chrome::DIR_TEST_DATA, &file_); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
const std::string test_db = "TestWebDatabase" + file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
base::Int64ToString(Time::Now().ToTimeT()) +
".db";
file_ = file_.AppendASCII(test_db);
file_util::Delete(file_, false);
}
virtual void TearDown() {
file_util::Delete(file_, false);
} }
static AutofillEntry MakeAutofillEntry(const char* name, static AutofillEntry MakeAutofillEntry(const char* name,
...@@ -123,6 +116,7 @@ class AutofillTableTest : public testing::Test { ...@@ -123,6 +116,7 @@ class AutofillTableTest : public testing::Test {
} }
FilePath file_; FilePath file_;
ScopedTempDir temp_dir_;
private: private:
DISALLOW_COPY_AND_ASSIGN(AutofillTableTest); DISALLOW_COPY_AND_ASSIGN(AutofillTableTest);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/time.h" #include "base/time.h"
...@@ -28,19 +29,12 @@ class KeywordTableTest : public testing::Test { ...@@ -28,19 +29,12 @@ class KeywordTableTest : public testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
PathService::Get(chrome::DIR_TEST_DATA, &file_); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
const std::string test_db = "TestWebDatabase" + file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
base::Int64ToString(Time::Now().ToTimeT()) +
".db";
file_ = file_.AppendASCII(test_db);
file_util::Delete(file_, false);
}
virtual void TearDown() {
file_util::Delete(file_, false);
} }
FilePath file_; FilePath file_;
ScopedTempDir temp_dir_;
private: private:
DISALLOW_COPY_AND_ASSIGN(KeywordTableTest); DISALLOW_COPY_AND_ASSIGN(KeywordTableTest);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/time.h" #include "base/time.h"
#include "chrome/browser/webdata/token_service_table.h" #include "chrome/browser/webdata/token_service_table.h"
...@@ -20,19 +21,12 @@ class TokenServiceTableTest : public testing::Test { ...@@ -20,19 +21,12 @@ class TokenServiceTableTest : public testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
PathService::Get(chrome::DIR_TEST_DATA, &file_); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
const std::string test_db = "TestWebDatabase" + file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
base::Int64ToString(Time::Now().ToTimeT()) +
".db";
file_ = file_.AppendASCII(test_db);
file_util::Delete(file_, false);
}
virtual void TearDown() {
file_util::Delete(file_, false);
} }
FilePath file_; FilePath file_;
ScopedTempDir temp_dir_;
private: private:
DISALLOW_COPY_AND_ASSIGN(TokenServiceTableTest); DISALLOW_COPY_AND_ASSIGN(TokenServiceTableTest);
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/file_util.h" #include "base/file_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/string_number_conversions.h" #include "base/string_number_conversions.h"
#include "base/time.h" #include "base/time.h"
#include "chrome/browser/webdata/web_apps_table.h" #include "chrome/browser/webdata/web_apps_table.h"
...@@ -22,19 +23,12 @@ class WebAppsTableTest : public testing::Test { ...@@ -22,19 +23,12 @@ class WebAppsTableTest : public testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
PathService::Get(chrome::DIR_TEST_DATA, &file_); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
const std::string test_db = "TestWebDatabase" + file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
base::Int64ToString(Time::Now().ToTimeT()) +
".db";
file_ = file_.AppendASCII(test_db);
file_util::Delete(file_, false);
}
virtual void TearDown() {
file_util::Delete(file_, false);
} }
FilePath file_; FilePath file_;
ScopedTempDir temp_dir_;
private: private:
DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest); DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment