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

Unified Diff: chrome/installer/util/work_item_list_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: 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/installer/util/work_item_list_unittest.cc
diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc
index ff2c3ad44ff9be214ce1e1619003d06ac79f7fed..56d3a8b804e4f364beb9ed30014d9fe1d419b4c7 100644
--- a/chrome/installer/util/work_item_list_unittest.cc
+++ b/chrome/installer/util/work_item_list_unittest.cc
@@ -7,6 +7,7 @@
#include "base/base_paths.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/win/registry.h"
@@ -32,26 +33,18 @@ class WorkItemListTest : public testing::Test {
ASSERT_EQ(ERROR_SUCCESS,
key.Create(HKEY_CURRENT_USER, test_root, KEY_READ));
- // Create a temp directory for test.
- ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_));
- test_dir_ = test_dir_.AppendASCII("WorkItemListTest");
- file_util::Delete(test_dir_, true);
- ASSERT_FALSE(file_util::PathExists(test_dir_));
- file_util::CreateDirectoryW(test_dir_);
- ASSERT_TRUE(file_util::PathExists(test_dir_));
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
virtual void TearDown() {
logging::CloseLogFile();
- // Clean up test directory
- ASSERT_TRUE(file_util::Delete(test_dir_, true));
- ASSERT_FALSE(file_util::PathExists(test_dir_));
+
// Clean up the temporary key
RegKey key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS);
ASSERT_EQ(ERROR_SUCCESS, key.DeleteKey(test_root));
}
- FilePath test_dir_;
+ ScopedTempDir temp_dir_;
};
} // namespace
@@ -61,7 +54,7 @@ TEST_F(WorkItemListTest, ExecutionSuccess) {
scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
scoped_ptr<WorkItem> work_item;
- FilePath top_dir_to_create(test_dir_);
+ FilePath top_dir_to_create(temp_dir_.path());
top_dir_to_create = top_dir_to_create.AppendASCII("a");
FilePath dir_to_create(top_dir_to_create);
dir_to_create = dir_to_create.AppendASCII("b");
@@ -112,7 +105,7 @@ TEST_F(WorkItemListTest, ExecutionFailAndRollback) {
scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
scoped_ptr<WorkItem> work_item;
- FilePath top_dir_to_create(test_dir_);
+ FilePath top_dir_to_create(temp_dir_.path());
top_dir_to_create = top_dir_to_create.AppendASCII("a");
FilePath dir_to_create(top_dir_to_create);
dir_to_create = dir_to_create.AppendASCII("b");
@@ -168,7 +161,7 @@ TEST_F(WorkItemListTest, ConditionalExecutionSuccess) {
scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
scoped_ptr<WorkItem> work_item;
- FilePath top_dir_to_create(test_dir_);
+ FilePath top_dir_to_create(temp_dir_.path());
top_dir_to_create = top_dir_to_create.AppendASCII("a");
FilePath dir_to_create(top_dir_to_create);
dir_to_create = dir_to_create.AppendASCII("b");
@@ -223,7 +216,7 @@ TEST_F(WorkItemListTest, ConditionalExecutionConditionFailure) {
scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
scoped_ptr<WorkItem> work_item;
- FilePath top_dir_to_create(test_dir_);
+ FilePath top_dir_to_create(temp_dir_.path());
top_dir_to_create = top_dir_to_create.AppendASCII("a");
FilePath dir_to_create(top_dir_to_create);
dir_to_create = dir_to_create.AppendASCII("b");

Powered by Google App Engine
This is Rietveld 408576698