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

Unified Diff: chrome/common/json_value_serializer_unittest.cc

Issue 6793008: Replacing base::DIR_TEMP with ScopedTempDir when appropriate. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: I obviously need a Windows test machine. 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/common/json_value_serializer_unittest.cc
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc
index c52aa06cde3da3c8fd9f6cae293a432879a3305f..0df24b0e6d5136d20c8c2c2d1edd11cf9c925432 100644
--- a/chrome/common/json_value_serializer_unittest.cc
+++ b/chrome/common/json_value_serializer_unittest.cc
@@ -1,4 +1,4 @@
-// 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.
@@ -6,6 +6,7 @@
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/memory/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/string16.h"
#include "base/string_util.h"
@@ -239,23 +240,10 @@ TEST(JSONValueSerializerTest, JSONReaderComments) {
class JSONFileValueSerializerTest : public testing::Test {
protected:
virtual void SetUp() {
- // Name a subdirectory of the temp directory.
- ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_));
- test_dir_ =
- test_dir_.Append(FILE_PATH_LITERAL("JSONFileValueSerializerTest"));
-
- // Create a fresh, empty copy of this directory.
- file_util::Delete(test_dir_, true);
- file_util::CreateDirectory(test_dir_);
- }
- virtual void TearDown() {
- // Clean up test directory
- ASSERT_TRUE(file_util::Delete(test_dir_, false));
- ASSERT_FALSE(file_util::PathExists(test_dir_));
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
- // the path to temporary directory used to contain the test operations
- FilePath test_dir_;
+ ScopedTempDir temp_dir_;
};
TEST_F(JSONFileValueSerializerTest, Roundtrip) {
@@ -295,7 +283,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) {
// Now try writing.
const FilePath written_file_path =
- test_dir_.Append(FILE_PATH_LITERAL("test_output.js"));
+ temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js"));
ASSERT_FALSE(file_util::PathExists(written_file_path));
JSONFileValueSerializer serializer(written_file_path);
@@ -324,7 +312,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) {
// Now try writing.
FilePath written_file_path =
- test_dir_.Append(FILE_PATH_LITERAL("test_output.js"));
+ temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js"));
ASSERT_FALSE(file_util::PathExists(written_file_path));
JSONFileValueSerializer serializer(written_file_path);

Powered by Google App Engine
This is Rietveld 408576698