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

Unified Diff: chrome/browser/prefs/pref_service_uitest.cc

Issue 6793008: Replacing base::DIR_TEMP with ScopedTempDir when appropriate. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Paweł's comments on Round 2. 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/prefs/pref_service_uitest.cc
diff --git a/chrome/browser/prefs/pref_service_uitest.cc b/chrome/browser/prefs/pref_service_uitest.cc
index fe2a79ae240c473a724988f97eda02fcb4519feb..f107e943b66cb1ae7afc5b78a095b2d78570b009 100644
--- a/chrome/browser/prefs/pref_service_uitest.cc
+++ b/chrome/browser/prefs/pref_service_uitest.cc
@@ -6,9 +6,9 @@
#include "base/command_line.h"
#include "base/file_util.h"
-#include "base/path_service.h"
#include "base/test/test_file_util.h"
#include "base/values.h"
+#include "base/memory/scoped_temp_dir.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
@@ -22,12 +22,10 @@
class PreferenceServiceTest : public UITest {
public:
void SetUp() {
- PathService::Get(base::DIR_TEMP, &tmp_profile_);
- tmp_profile_ = tmp_profile_.AppendASCII("tmp_profile");
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+ FilePath tmp_profile = temp_dir_.path().AppendASCII("tmp_profile");
- // Create a fresh, empty copy of this directory.
- file_util::Delete(tmp_profile_, true);
- file_util::CreateDirectory(tmp_profile_);
+ file_util::CreateDirectory(tmp_profile);
Paweł Hajdan Jr. 2011/04/12 08:32:02 Ah, check return value of this (ASSERT_TRUE).
Mike West 2011/04/12 12:00:05 Done.
FilePath reference_pref_file;
if (new_profile_) {
@@ -36,7 +34,7 @@ class PreferenceServiceTest : public UITest {
.AppendASCII("window_placement")
.AppendASCII("Default")
.Append(chrome::kPreferencesFilename);
- tmp_pref_file_ = tmp_profile_.AppendASCII("Default");
+ tmp_pref_file_ = tmp_profile.AppendASCII("Default");
ASSERT_TRUE(file_util::CreateDirectory(tmp_pref_file_));
tmp_pref_file_ = tmp_pref_file_.Append(chrome::kPreferencesFilename);
} else {
@@ -44,7 +42,7 @@ class PreferenceServiceTest : public UITest {
.AppendASCII("profiles")
.AppendASCII("window_placement")
.Append(chrome::kLocalStateFilename);
- tmp_pref_file_ = tmp_profile_.Append(chrome::kLocalStateFilename);
+ tmp_pref_file_ = tmp_profile.Append(chrome::kLocalStateFilename);
}
ASSERT_TRUE(file_util::PathExists(reference_pref_file));
@@ -59,7 +57,7 @@ class PreferenceServiceTest : public UITest {
FILE_ATTRIBUTE_NORMAL));
#endif
- launch_arguments_.AppendSwitchPath(switches::kUserDataDir, tmp_profile_);
+ launch_arguments_.AppendSwitchPath(switches::kUserDataDir, tmp_profile);
}
bool LaunchAppWithProfile() {
@@ -71,14 +69,14 @@ class PreferenceServiceTest : public UITest {
void TearDown() {
UITest::TearDown();
-
- EXPECT_TRUE(file_util::DieFileDie(tmp_profile_, true));
}
public:
bool new_profile_;
FilePath tmp_pref_file_;
- FilePath tmp_profile_;
+
+ private:
+ ScopedTempDir temp_dir_;
};
#if !defined(OS_LINUX)

Powered by Google App Engine
This is Rietveld 408576698