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

Unified Diff: chrome/installer/util/lzma_util_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: Needed to rebase; patch didn't apply cleanly to save_package_unittest. 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/installer/util/lzma_util_unittest.cc
diff --git a/chrome/installer/util/lzma_util_unittest.cc b/chrome/installer/util/lzma_util_unittest.cc
index b1c63637e9cef816afe8b129da2b226c2d97098c..e82d8bf11705dc32e2918c9677485630f15a9d08 100644
--- a/chrome/installer/util/lzma_util_unittest.cc
+++ b/chrome/installer/util/lzma_util_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.
@@ -7,6 +7,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/process_util.h"
+#include "base/memory/scoped_temp_dir.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/installer/util/lzma_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,24 +20,10 @@ class LzmaUtilTest : public testing::Test {
data_dir_ = data_dir_.AppendASCII("installer");
ASSERT_TRUE(file_util::PathExists(data_dir_));
- // Name a subdirectory of the user temp directory.
- ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_));
- test_dir_ = test_dir_.AppendASCII("LzmaUtilTest");
-
- // Create a fresh, empty copy of this test directory.
- file_util::Delete(test_dir_, true);
- file_util::CreateDirectoryW(test_dir_);
- ASSERT_TRUE(file_util::PathExists(test_dir_));
- }
-
- virtual void TearDown() {
- // Clean up test directory
- ASSERT_TRUE(file_util::Delete(test_dir_, true));
- 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_;
// The path to input data used in tests.
FilePath data_dir_;
@@ -66,7 +53,7 @@ TEST_F(LzmaUtilTest, OpenArchiveTest) {
// Test that we can extract archives successfully.
TEST_F(LzmaUtilTest, UnPackTest) {
- FilePath extract_dir(test_dir_);
+ FilePath extract_dir(temp_dir_.path());
extract_dir = extract_dir.AppendASCII("UnPackTest");
ASSERT_FALSE(file_util::PathExists(extract_dir));
EXPECT_TRUE(file_util::CreateDirectory(extract_dir));
@@ -107,7 +94,7 @@ TEST_F(LzmaUtilTest, UnPackTest) {
// Test the static method that can be used to unpack archives.
TEST_F(LzmaUtilTest, UnPackArchiveTest) {
- FilePath extract_dir(test_dir_);
+ FilePath extract_dir(temp_dir_.path());
extract_dir = extract_dir.AppendASCII("UnPackArchiveTest");
ASSERT_FALSE(file_util::PathExists(extract_dir));
EXPECT_TRUE(file_util::CreateDirectory(extract_dir));
« no previous file with comments | « chrome/installer/util/delete_tree_work_item_unittest.cc ('k') | chrome/installer/util/move_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698