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

Unified Diff: chrome/installer/util/copy_tree_work_item_unittest.cc

Issue 2321573002: //chrome misc: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix Win compilation Created 4 years, 3 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/copy_tree_work_item_unittest.cc
diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc
index bffdd151bc5f7976e7c5c6897c699f272b3f15c1..e34c2ed7718f1e09e8467ac25c42497f6a400934 100644
--- a/chrome/installer/util/copy_tree_work_item_unittest.cc
+++ b/chrome/installer/util/copy_tree_work_item_unittest.cc
@@ -76,13 +76,13 @@ const wchar_t text_content_2[] = L"Overwrite Me";
// Copy one file from source to destination.
TEST_F(CopyTreeWorkItemTest, CopyFile) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From.txt");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
// Create destination path
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -92,7 +92,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) {
// test Do()
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(), WorkItem::ALWAYS,
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::ALWAYS,
base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -113,13 +113,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) {
// regardless since the content at destination file is different from source.
TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From.txt");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
// Create destination file
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -131,7 +131,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) {
// test Do() with always_overwrite being true.
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(), WorkItem::ALWAYS,
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::ALWAYS,
base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -151,12 +151,9 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) {
// test Do() with always_overwrite being false.
// the file is still overwritten since the content is different.
- work_item.reset(
- WorkItem::CreateCopyTreeWorkItem(file_name_from,
- file_name_to,
- temp_dir_.path(),
- WorkItem::IF_DIFFERENT,
- base::FilePath()));
+ work_item.reset(WorkItem::CreateCopyTreeWorkItem(
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::IF_DIFFERENT,
+ base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -180,13 +177,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) {
// If always_overwrite being false, the file is unchanged.
TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From.txt");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
// Create destination file
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -198,7 +195,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) {
// test Do() with always_overwrite being true.
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(), WorkItem::ALWAYS,
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::ALWAYS,
base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -228,12 +225,9 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) {
EXPECT_FALSE(base::PathExists(backup_file));
// test Do() with always_overwrite being false. nothing should change.
- work_item.reset(
- WorkItem::CreateCopyTreeWorkItem(file_name_from,
- file_name_to,
- temp_dir_.path(),
- WorkItem::IF_DIFFERENT,
- base::FilePath()));
+ work_item.reset(WorkItem::CreateCopyTreeWorkItem(
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::IF_DIFFERENT,
+ base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -258,13 +252,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) {
// Copy one file and without rollback. Verify all temporary files are deleted.
TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From.txt");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
// Create destination file
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -280,7 +274,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) {
// test Do().
std::unique_ptr<CopyTreeWorkItem> work_item(
WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(),
+ file_name_from, file_name_to, temp_dir_.GetPath(),
WorkItem::IF_DIFFERENT, base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -308,7 +302,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) {
// be moved to backup location after Do() and moved back after Rollback().
TEST_F(CopyTreeWorkItemTest, CopyFileInUse) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
@@ -318,7 +312,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) {
::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
base::FilePath exe_full_path(exe_full_path_str);
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -341,7 +335,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) {
// test Do().
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(), WorkItem::IF_DIFFERENT,
+ file_name_from, file_name_to, temp_dir_.GetPath(), WorkItem::IF_DIFFERENT,
base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -384,7 +378,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) {
// destination folder after Do() and should be rolled back after Rollback().
TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
@@ -394,7 +388,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) {
::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
base::FilePath exe_full_path(exe_full_path_str);
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -418,7 +412,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) {
// test Do().
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(),
+ file_name_from, file_name_to, temp_dir_.GetPath(),
WorkItem::NEW_NAME_IF_IN_USE, alternate_to));
EXPECT_TRUE(work_item->Do());
@@ -450,9 +444,8 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) {
// Now the process has terminated, lets try overwriting the file again
work_item.reset(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to,
- temp_dir_.path(), WorkItem::NEW_NAME_IF_IN_USE,
- alternate_to));
+ file_name_from, file_name_to, temp_dir_.GetPath(),
+ WorkItem::NEW_NAME_IF_IN_USE, alternate_to));
if (IsFileInUse(file_name_to))
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2));
// If file is still in use, the rest of the test will fail.
@@ -492,7 +485,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) {
// Flaky, http://crbug.com/59785.
TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
@@ -502,7 +495,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) {
::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
base::FilePath exe_full_path(exe_full_path_str);
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -512,13 +505,13 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) {
ASSERT_TRUE(base::PathExists(file_name_to));
// Get the path of backup file
- base::FilePath backup_file(temp_dir_.path());
+ base::FilePath backup_file(temp_dir_.GetPath());
backup_file = backup_file.AppendASCII("File_To");
// test Do().
std::unique_ptr<CopyTreeWorkItem> work_item(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(), WorkItem::IF_NOT_PRESENT,
- base::FilePath()));
+ file_name_from, file_name_to, temp_dir_.GetPath(),
+ WorkItem::IF_NOT_PRESENT, base::FilePath()));
EXPECT_TRUE(work_item->Do());
// verify that the source, destination have not changed and backup path
@@ -543,9 +536,8 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) {
// Now delete the destination and try copying the file again.
base::DeleteFile(file_name_to, false);
work_item.reset(WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to,
- temp_dir_.path(), WorkItem::IF_NOT_PRESENT,
- base::FilePath()));
+ file_name_from, file_name_to, temp_dir_.GetPath(),
+ WorkItem::IF_NOT_PRESENT, base::FilePath()));
EXPECT_TRUE(work_item->Do());
// verify that the source, destination are the same and backup path
@@ -571,7 +563,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) {
// Flaky, http://crbug.com/59783.
TEST_F(CopyTreeWorkItemTest, DISABLED_CopyFileInUseAndCleanup) {
// Create source file
- base::FilePath file_name_from(test_dir_.path());
+ base::FilePath file_name_from(test_dir_.GetPath());
file_name_from = file_name_from.AppendASCII("File_From");
CreateTextFile(file_name_from.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from));
@@ -581,7 +573,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_CopyFileInUseAndCleanup) {
::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH);
base::FilePath exe_full_path(exe_full_path_str);
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir");
base::CreateDirectory(dir_name_to);
ASSERT_TRUE(base::PathExists(dir_name_to));
@@ -608,7 +600,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_CopyFileInUseAndCleanup) {
{
std::unique_ptr<CopyTreeWorkItem> work_item(
WorkItem::CreateCopyTreeWorkItem(
- file_name_from, file_name_to, temp_dir_.path(),
+ file_name_from, file_name_to, temp_dir_.GetPath(),
WorkItem::IF_DIFFERENT, base::FilePath()));
EXPECT_TRUE(work_item->Do());
@@ -642,7 +634,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_CopyFileInUseAndCleanup) {
// Flaky, http://crbug.com/59784.
TEST_F(CopyTreeWorkItemTest, DISABLED_CopyTree) {
// Create source tree
- base::FilePath dir_name_from(test_dir_.path());
+ base::FilePath dir_name_from(test_dir_.GetPath());
dir_name_from = dir_name_from.AppendASCII("from");
base::CreateDirectory(dir_name_from);
ASSERT_TRUE(base::PathExists(dir_name_from));
@@ -667,14 +659,14 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_CopyTree) {
CreateTextFile(file_name_from_2.value(), text_content_1);
ASSERT_TRUE(base::PathExists(file_name_from_2));
- base::FilePath dir_name_to(test_dir_.path());
+ base::FilePath dir_name_to(test_dir_.GetPath());
dir_name_to = dir_name_to.AppendASCII("to");
// test Do()
{
std::unique_ptr<CopyTreeWorkItem> work_item(
WorkItem::CreateCopyTreeWorkItem(dir_name_from, dir_name_to,
- temp_dir_.path(), WorkItem::ALWAYS,
+ temp_dir_.GetPath(), WorkItem::ALWAYS,
base::FilePath()));
EXPECT_TRUE(work_item->Do());
« no previous file with comments | « chrome/installer/util/conditional_work_item_list_unittest.cc ('k') | chrome/installer/util/create_dir_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698