diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-25 21:05:12 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-25 21:05:12 +0000 |
commit | 4d5ae3782302f6a9a844ae64c7527c4110cf7688 (patch) | |
tree | 77f5cfa85dda86dbb4dd56c291ffb2063ac16a61 /chrome/installer | |
parent | f533387862c3b2c8148cfac88ecee15d7c88804d (diff) | |
download | chromium_src-4d5ae3782302f6a9a844ae64c7527c4110cf7688.zip chromium_src-4d5ae3782302f6a9a844ae64c7527c4110cf7688.tar.gz chromium_src-4d5ae3782302f6a9a844ae64c7527c4110cf7688.tar.bz2 |
Remove uses of deprecated version of FileUtil::PathExists() in the installer.
BUG=None
TEST=run installer_util_unittests.exe
Review URL: http://codereview.chromium.org/174189
Patch from Thiago Farina <thiago.farina@gmail.com>.
Review URL: http://codereview.chromium.org/173369
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/util/copy_tree_work_item_unittest.cc | 356 | ||||
-rw-r--r-- | chrome/installer/util/create_dir_work_item_unittest.cc | 62 | ||||
-rw-r--r-- | chrome/installer/util/create_reg_key_work_item_unittest.cc | 113 | ||||
-rw-r--r-- | chrome/installer/util/delete_tree_work_item_unittest.cc | 110 | ||||
-rw-r--r-- | chrome/installer/util/helper_unittest.cc | 126 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item_unittest.cc | 197 | ||||
-rw-r--r-- | chrome/installer/util/work_item_list_unittest.cc | 20 |
7 files changed, 515 insertions, 469 deletions
diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index 77b6719..4be5d33 100644 --- a/chrome/installer/util/copy_tree_work_item_unittest.cc +++ b/chrome/installer/util/copy_tree_work_item_unittest.cc @@ -92,23 +92,24 @@ namespace { // Copy one file from source to destination. TEST_F(CopyTreeWorkItemTest, CopyFile) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From.txt"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From.txt"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination path - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To.txt"); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To.txt"); // test Do() scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::ALWAYS)); @@ -130,25 +131,26 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) { // regardless since the content at destination file is different from source. TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From.txt"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From.txt"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To.txt"); - CreateTextFile(file_name_to, text_content_2); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To.txt"); + CreateTextFile(file_name_to.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(file_name_to)); // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::ALWAYS)); @@ -156,21 +158,22 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_2)); // 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, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::IF_DIFFERENT)); @@ -178,16 +181,16 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_2)); } // Copy one file, with the existing one in destination having the same @@ -196,29 +199,30 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // If always_overwrite being false, the file is unchanged. TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From.txt"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From.txt"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To.txt"); - CreateTextFile(file_name_to, text_content_1); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To.txt"); + CreateTextFile(file_name_to.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To.txt"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To.txt"); // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::ALWAYS)); @@ -226,26 +230,27 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // we verify the file is overwritten by checking the existence of backup // file. EXPECT_TRUE(file_util::PathExists(backup_file)); - EXPECT_EQ(0, ReadTextFile(backup_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(backup_file.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // the backup file should be gone after rollback EXPECT_FALSE(file_util::PathExists(backup_file)); // test Do() with always_overwrite being false. nothing should change. work_item.reset( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::IF_DIFFERENT)); @@ -253,8 +258,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // we verify the file is not overwritten by checking that the backup // file does not exist. EXPECT_FALSE(file_util::PathExists(backup_file)); @@ -264,38 +269,39 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); EXPECT_FALSE(file_util::PathExists(backup_file)); } // Copy one file and without rollback. Verify all temporary files are deleted. TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From.txt"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From.txt"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To.txt"); - CreateTextFile(file_name_to, text_content_2); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To.txt"); + CreateTextFile(file_name_to.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To.txt"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To.txt"); { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::IF_DIFFERENT)); @@ -303,11 +309,11 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // verify the file is moved to backup place. EXPECT_TRUE(file_util::PathExists(backup_file)); - EXPECT_EQ(0, ReadTextFile(backup_file).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(backup_file.value()).compare(text_content_2)); } // verify the backup file is cleaned up as well. @@ -319,43 +325,45 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { // be moved to backup location after Do() and moved back after Rollback(). TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create an executable in destination path by copying ourself to it. wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); + FilePath exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To"); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To"); file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " << exe_full_path << " to " << file_name_to; + LOG(INFO) << "copy ourself from " + << exe_full_path.value() << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; ASSERT_TRUE( - ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.c_str()), + ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::IF_DIFFERENT)); @@ -363,8 +371,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // verify the file in used is moved to backup place. EXPECT_TRUE(file_util::PathExists(backup_file)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, backup_file)); @@ -374,7 +382,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); // the backup file should be gone after rollback EXPECT_FALSE(file_util::PathExists(backup_file)); @@ -394,53 +402,55 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { // destination folder after Do() and should be rolled back after Rollback(). TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create an executable in destination path by copying ourself to it. wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); + FilePath exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to), alternate_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To"); - file_util::AppendToPath(&alternate_to, L"Alternate_To"); + FilePath file_name_to(dir_name_to), alternate_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To"); + alternate_to = alternate_to.AppendASCII("Alternate_To"); file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " << exe_full_path << " to " << file_name_to; + LOG(INFO) << "copy ourself from " + << exe_full_path.value() << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; ASSERT_TRUE( - ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.c_str()), + ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, - alternate_to)); + alternate_to.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); // verify that the backup path does not exist EXPECT_FALSE(file_util::PathExists(backup_file)); @@ -451,7 +461,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); EXPECT_FALSE(file_util::PathExists(backup_file)); // the alternate file should be gone after rollback @@ -464,18 +474,19 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { CloseHandle(pi.hThread); // Now the process has terminated, lets try overwriting the file again - work_item.reset(WorkItem::CreateCopyTreeWorkItem(file_name_from, - file_name_to, temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, - alternate_to)); - if (IsFileInUse(file_name_to)) + work_item.reset(WorkItem::CreateCopyTreeWorkItem( + file_name_from.ToWStringHack(), file_name_to.ToWStringHack(), + temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, + alternate_to.ToWStringHack())); + if (IsFileInUse(file_name_to.value())) PlatformThread::Sleep(2000); // If file is still in use, the rest of the test will fail. - ASSERT_FALSE(IsFileInUse(file_name_to)); + ASSERT_FALSE(IsFileInUse(file_name_to.value())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(file_name_from, file_name_to)); // verify that the backup path does exist EXPECT_TRUE(file_util::PathExists(backup_file)); @@ -486,7 +497,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); // the backup file should be gone after rollback EXPECT_FALSE(file_util::PathExists(backup_file)); @@ -500,39 +511,41 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // Rollback(). TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create an executable in destination path by copying ourself to it. wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath exe_full_path(exe_full_path_str); + + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To"); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To"); file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_.ToWStringHack(), WorkItem::IF_NOT_PRESENT, L"")); + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), + WorkItem::IF_NOT_PRESENT, L"")); EXPECT_TRUE(work_item->Do()); // verify that the source, destination have not changed and backup path // does not exist EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); EXPECT_FALSE(file_util::PathExists(backup_file)); @@ -543,23 +556,23 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // does not exist after rollback also EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, file_name_to)); EXPECT_FALSE(file_util::PathExists(backup_file)); // Now delete the destination and try copying the file again. file_util::Delete(file_name_to, true); work_item.reset(WorkItem::CreateCopyTreeWorkItem( - file_name_from, file_name_to, temp_dir_.ToWStringHack(), - WorkItem::IF_NOT_PRESENT, L"")); + file_name_from.ToWStringHack(), file_name_to.ToWStringHack(), + temp_dir_.ToWStringHack(), WorkItem::IF_NOT_PRESENT, L"")); EXPECT_TRUE(work_item->Do()); // verify that the source, destination are the same and backup path // does not exist EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); EXPECT_FALSE(file_util::PathExists(backup_file)); // test rollback() @@ -568,7 +581,7 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // verify that the destination does not exist anymore EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_FALSE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); EXPECT_FALSE(file_util::PathExists(backup_file)); } @@ -576,44 +589,46 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // Verify it is moved to backup location and stays there. TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { // Create source file - std::wstring file_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&file_name_from, L"File_From"); - CreateTextFile(file_name_from, text_content_1); + FilePath file_name_from(test_dir_); + file_name_from = file_name_from.AppendASCII("File_From"); + CreateTextFile(file_name_from.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create an executable in destination path by copying ourself to it. wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); + FilePath exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); - CreateDirectory(dir_name_to.c_str(), NULL); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("Copy_To_Subdir"); + CreateDirectory(dir_name_to.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); - std::wstring file_name_to(dir_name_to); - file_util::AppendToPath(&file_name_to, L"File_To"); + FilePath file_name_to(dir_name_to); + file_name_to = file_name_to.AppendASCII("File_To"); file_util::CopyFile(exe_full_path, file_name_to); ASSERT_TRUE(file_util::PathExists(file_name_to)); - LOG(INFO) << "copy ourself from " << exe_full_path << " to " << file_name_to; + LOG(INFO) << "copy ourself from " + << exe_full_path.value() << " to " << file_name_to.value(); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; ASSERT_TRUE( - ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.c_str()), + ::CreateProcess(NULL, const_cast<wchar_t*>(file_name_to.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_.ToWStringHack()); - file_util::AppendToPath(&backup_file, L"File_To"); + FilePath backup_file(temp_dir_); + backup_file = backup_file.AppendASCII("File_To"); // test Do(). { scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, + WorkItem::CreateCopyTreeWorkItem(file_name_from.ToWStringHack(), + file_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::IF_DIFFERENT)); @@ -621,8 +636,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { EXPECT_TRUE(file_util::PathExists(file_name_from)); EXPECT_TRUE(file_util::PathExists(file_name_to)); - EXPECT_EQ(0, ReadTextFile(file_name_from).compare(text_content_1)); - EXPECT_EQ(0, ReadTextFile(file_name_to).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_from.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(file_name_to.value()).compare(text_content_1)); // verify the file in used is moved to backup place. EXPECT_TRUE(file_util::PathExists(backup_file)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, backup_file)); @@ -642,55 +657,58 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { // Copy a tree from source to destination. TEST_F(CopyTreeWorkItemTest, CopyTree) { // Create source tree - std::wstring dir_name_from(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_from, L"from"); - CreateDirectory(dir_name_from.c_str(), NULL); + FilePath dir_name_from(test_dir_); + dir_name_from = dir_name_from.AppendASCII("from"); + CreateDirectory(dir_name_from.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_from)); - std::wstring dir_name_from_1(dir_name_from); - file_util::AppendToPath(&dir_name_from_1, L"1"); - CreateDirectory(dir_name_from_1.c_str(), NULL); + FilePath dir_name_from_1(dir_name_from); + dir_name_from_1 = dir_name_from_1.AppendASCII("1"); + CreateDirectory(dir_name_from_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_from_1)); - std::wstring dir_name_from_2(dir_name_from); - file_util::AppendToPath(&dir_name_from_2, L"2"); - CreateDirectory(dir_name_from_2.c_str(), NULL); + FilePath dir_name_from_2(dir_name_from); + dir_name_from_2 = dir_name_from_2.AppendASCII("2"); + CreateDirectory(dir_name_from_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_from_2)); - std::wstring file_name_from_1(dir_name_from_1); - file_util::AppendToPath(&file_name_from_1, L"File_1.txt"); - CreateTextFile(file_name_from_1, text_content_1); + FilePath file_name_from_1(dir_name_from_1); + file_name_from_1 = file_name_from_1.AppendASCII("File_1.txt"); + CreateTextFile(file_name_from_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from_1)); - std::wstring file_name_from_2(dir_name_from_2); - file_util::AppendToPath(&file_name_from_2, L"File_2.txt"); - CreateTextFile(file_name_from_2, text_content_1); + FilePath file_name_from_2(dir_name_from_2); + file_name_from_2 = file_name_from_2.AppendASCII("File_2.txt"); + CreateTextFile(file_name_from_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from_2)); - std::wstring dir_name_to(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_to, L"to"); + FilePath dir_name_to(test_dir_); + dir_name_to = dir_name_to.AppendASCII("to"); // test Do() { scoped_ptr<CopyTreeWorkItem> work_item( - WorkItem::CreateCopyTreeWorkItem(dir_name_from, dir_name_to, + WorkItem::CreateCopyTreeWorkItem(dir_name_from.ToWStringHack(), + dir_name_to.ToWStringHack(), temp_dir_.ToWStringHack(), WorkItem::ALWAYS)); EXPECT_TRUE(work_item->Do()); } - std::wstring file_name_to_1(dir_name_to); - file_util::AppendToPath(&file_name_to_1, L"1"); - file_util::AppendToPath(&file_name_to_1, L"File_1.txt"); + FilePath file_name_to_1(dir_name_to); + file_name_to_1 = file_name_to_1.AppendASCII("1"); + file_name_to_1 = file_name_to_1.AppendASCII("File_1.txt"); EXPECT_TRUE(file_util::PathExists(file_name_to_1)); - LOG(INFO) << "compare " << file_name_from_1 << " and " << file_name_to_1; + LOG(INFO) << "compare " + << file_name_from_1.value() << " and " << file_name_to_1.value(); EXPECT_TRUE(file_util::ContentsEqual(file_name_from_1, file_name_to_1)); - std::wstring file_name_to_2(dir_name_to); - file_util::AppendToPath(&file_name_to_2, L"2"); - file_util::AppendToPath(&file_name_to_2, L"File_2.txt"); + FilePath file_name_to_2(dir_name_to); + file_name_to_2 = file_name_to_2.AppendASCII("2"); + file_name_to_2 = file_name_to_2.AppendASCII("File_2.txt"); EXPECT_TRUE(file_util::PathExists(file_name_to_2)); - LOG(INFO) << "compare " << file_name_from_2 << " and " << file_name_to_2; + LOG(INFO) << "compare " + << file_name_from_2.value() << " and " << file_name_to_2.value(); EXPECT_TRUE(file_util::ContentsEqual(file_name_from_2, file_name_to_2)); } diff --git a/chrome/installer/util/create_dir_work_item_unittest.cc b/chrome/installer/util/create_dir_work_item_unittest.cc index 2588966..8c44038 100644 --- a/chrome/installer/util/create_dir_work_item_unittest.cc +++ b/chrome/installer/util/create_dir_work_item_unittest.cc @@ -37,20 +37,20 @@ namespace { }; TEST_F(CreateDirWorkItemTest, CreatePath) { - std::wstring parent_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&parent_dir, L"a"); - CreateDirectory(parent_dir.c_str(), NULL); + FilePath parent_dir(test_dir_); + parent_dir = parent_dir.AppendASCII("a"); + CreateDirectory(parent_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(parent_dir)); - std::wstring top_dir_to_create(parent_dir); - file_util::AppendToPath(&top_dir_to_create, L"b"); + FilePath top_dir_to_create(parent_dir); + top_dir_to_create = top_dir_to_create.AppendASCII("b"); - std::wstring dir_to_create(top_dir_to_create); - file_util::AppendToPath(&dir_to_create, L"c"); - file_util::AppendToPath(&dir_to_create, L"d"); + FilePath dir_to_create(top_dir_to_create); + dir_to_create = dir_to_create.AppendASCII("c"); + dir_to_create = dir_to_create.AppendASCII("d"); scoped_ptr<CreateDirWorkItem> work_item( - WorkItem::CreateCreateDirWorkItem(dir_to_create)); + WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack())); EXPECT_TRUE(work_item->Do()); @@ -64,13 +64,13 @@ TEST_F(CreateDirWorkItemTest, CreatePath) { } TEST_F(CreateDirWorkItemTest, CreateExistingPath) { - std::wstring dir_to_create(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_to_create, L"aa"); - CreateDirectory(dir_to_create.c_str(), NULL); + FilePath dir_to_create(test_dir_); + dir_to_create = dir_to_create.AppendASCII("aa"); + CreateDirectory(dir_to_create.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_to_create)); scoped_ptr<CreateDirWorkItem> work_item( - WorkItem::CreateCreateDirWorkItem(dir_to_create)); + WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack())); EXPECT_TRUE(work_item->Do()); @@ -84,26 +84,26 @@ TEST_F(CreateDirWorkItemTest, CreateExistingPath) { } TEST_F(CreateDirWorkItemTest, CreateSharedPath) { - std::wstring dir_to_create_1(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_to_create_1, L"aaa"); + FilePath dir_to_create_1(test_dir_); + dir_to_create_1 = dir_to_create_1.AppendASCII("aaa"); - std::wstring dir_to_create_2(dir_to_create_1); - file_util::AppendToPath(&dir_to_create_2, L"bbb"); + FilePath dir_to_create_2(dir_to_create_1); + dir_to_create_2 = dir_to_create_2.AppendASCII("bbb"); - std::wstring dir_to_create_3(dir_to_create_2); - file_util::AppendToPath(&dir_to_create_3, L"ccc"); + FilePath dir_to_create_3(dir_to_create_2); + dir_to_create_3 = dir_to_create_3.AppendASCII("ccc"); scoped_ptr<CreateDirWorkItem> work_item( - WorkItem::CreateCreateDirWorkItem(dir_to_create_3)); + WorkItem::CreateCreateDirWorkItem(dir_to_create_3.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(dir_to_create_3)); // Create another directory under dir_to_create_2 - std::wstring dir_to_create_4(dir_to_create_2); - file_util::AppendToPath(&dir_to_create_4, L"ddd"); - CreateDirectory(dir_to_create_4.c_str(), NULL); + FilePath dir_to_create_4(dir_to_create_2); + dir_to_create_4 = dir_to_create_4.AppendASCII("ddd"); + CreateDirectory(dir_to_create_4.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_to_create_4)); work_item->Rollback(); @@ -117,23 +117,23 @@ TEST_F(CreateDirWorkItemTest, CreateSharedPath) { } TEST_F(CreateDirWorkItemTest, RollbackWithMissingDir) { - std::wstring dir_to_create_1(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_to_create_1, L"aaaa"); + FilePath dir_to_create_1(test_dir_); + dir_to_create_1 = dir_to_create_1.AppendASCII("aaaa"); - std::wstring dir_to_create_2(dir_to_create_1); - file_util::AppendToPath(&dir_to_create_2, L"bbbb"); + FilePath dir_to_create_2(dir_to_create_1); + dir_to_create_2 = dir_to_create_2.AppendASCII("bbbb"); - std::wstring dir_to_create_3(dir_to_create_2); - file_util::AppendToPath(&dir_to_create_3, L"cccc"); + FilePath dir_to_create_3(dir_to_create_2); + dir_to_create_3 = dir_to_create_3.AppendASCII("cccc"); scoped_ptr<CreateDirWorkItem> work_item( - WorkItem::CreateCreateDirWorkItem(dir_to_create_3)); + WorkItem::CreateCreateDirWorkItem(dir_to_create_3.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(dir_to_create_3)); - RemoveDirectory(dir_to_create_3.c_str()); + RemoveDirectory(dir_to_create_3.value().c_str()); ASSERT_FALSE(file_util::PathExists(dir_to_create_3)); work_item->Rollback(); diff --git a/chrome/installer/util/create_reg_key_work_item_unittest.cc b/chrome/installer/util/create_reg_key_work_item_unittest.cc index 2029b5b..4f8a9ee 100644 --- a/chrome/installer/util/create_reg_key_work_item_unittest.cc +++ b/chrome/installer/util/create_reg_key_work_item_unittest.cc @@ -35,135 +35,149 @@ namespace { TEST_F(CreateRegKeyWorkItemTest, CreateKey) { RegKey key; - std::wstring parent_key(test_root); - file_util::AppendToPath(&parent_key, L"a"); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.c_str(), KEY_READ)); + FilePath parent_key(test_root); + parent_key = parent_key.AppendASCII("a"); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, parent_key.value().c_str(), + KEY_READ)); - std::wstring top_key_to_create(parent_key); - file_util::AppendToPath(&top_key_to_create, L"b"); + FilePath top_key_to_create(parent_key); + top_key_to_create = top_key_to_create.AppendASCII("b"); - std::wstring key_to_create(top_key_to_create); - file_util::AppendToPath(&key_to_create, L"c"); - file_util::AppendToPath(&key_to_create, L"d"); + FilePath key_to_create(top_key_to_create); + key_to_create = key_to_create.AppendASCII("c"); + key_to_create = key_to_create.AppendASCII("d"); scoped_ptr<CreateRegKeyWorkItem> work_item( - WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, key_to_create)); + WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, + key_to_create.ToWStringHack())); EXPECT_TRUE(work_item->Do()); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.value().c_str(), + KEY_READ)); work_item->Rollback(); // Rollback should delete all the keys up to top_key_to_create. - EXPECT_FALSE(key.Open(HKEY_CURRENT_USER, top_key_to_create.c_str(), + EXPECT_FALSE(key.Open(HKEY_CURRENT_USER, top_key_to_create.value().c_str(), KEY_READ)); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, parent_key.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, parent_key.value().c_str(), + KEY_READ)); } TEST_F(CreateRegKeyWorkItemTest, CreateExistingKey) { RegKey key; - std::wstring key_to_create(test_root); - file_util::AppendToPath(&key_to_create, L"aa"); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); + FilePath key_to_create(test_root); + key_to_create = key_to_create.AppendASCII("aa"); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, key_to_create.value().c_str(), + KEY_READ)); scoped_ptr<CreateRegKeyWorkItem> work_item( - WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, key_to_create)); + WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, + key_to_create.ToWStringHack())); EXPECT_TRUE(work_item->Do()); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.value().c_str(), + KEY_READ)); work_item->Rollback(); // Rollback should not remove the key since it exists before // the CreateRegKeyWorkItem is called. - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.value().c_str(), + KEY_READ)); } TEST_F(CreateRegKeyWorkItemTest, CreateSharedKey) { RegKey key; - std::wstring key_to_create_1(test_root); - file_util::AppendToPath(&key_to_create_1, L"aaa"); + FilePath key_to_create_1(test_root); + key_to_create_1 = key_to_create_1.AppendASCII("aaa"); - std::wstring key_to_create_2(key_to_create_1); - file_util::AppendToPath(&key_to_create_2, L"bbb"); + FilePath key_to_create_2(key_to_create_1); + key_to_create_2 = key_to_create_2.AppendASCII("bbb"); - std::wstring key_to_create_3(key_to_create_2); - file_util::AppendToPath(&key_to_create_3, L"ccc"); + FilePath key_to_create_3(key_to_create_2); + key_to_create_3 = key_to_create_3.AppendASCII("ccc"); scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create_3)); + key_to_create_3.ToWStringHack())); EXPECT_TRUE(work_item->Do()); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_3.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_3.value().c_str(), + KEY_READ)); // Create another key under key_to_create_2 - std::wstring key_to_create_4(key_to_create_2); - file_util::AppendToPath(&key_to_create_4, L"ddd"); - ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, key_to_create_4.c_str(), + FilePath key_to_create_4(key_to_create_2); + key_to_create_4 = key_to_create_4.AppendASCII("ddd"); + ASSERT_TRUE(key.Create(HKEY_CURRENT_USER, key_to_create_4.value().c_str(), KEY_READ)); work_item->Rollback(); // Rollback should delete key_to_create_3. - EXPECT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_3.c_str(), KEY_READ)); + EXPECT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_3.value().c_str(), + KEY_READ)); // Rollback should not delete key_to_create_2 as it is shared. - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_2.c_str(), KEY_READ)); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_4.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_2.value().c_str(), + KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_4.value().c_str(), + KEY_READ)); } TEST_F(CreateRegKeyWorkItemTest, RollbackWithMissingKey) { RegKey key; - std::wstring key_to_create_1(test_root); - file_util::AppendToPath(&key_to_create_1, L"aaaa"); + FilePath key_to_create_1(test_root); + key_to_create_1 = key_to_create_1.AppendASCII("aaaa"); - std::wstring key_to_create_2(key_to_create_1); - file_util::AppendToPath(&key_to_create_2, L"bbbb"); + FilePath key_to_create_2(key_to_create_1); + key_to_create_2 = key_to_create_2.AppendASCII("bbbb"); - std::wstring key_to_create_3(key_to_create_2); - file_util::AppendToPath(&key_to_create_3, L"cccc"); + FilePath key_to_create_3(key_to_create_2); + key_to_create_3 = key_to_create_3.AppendASCII("cccc"); scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create_3)); + key_to_create_3.ToWStringHack())); EXPECT_TRUE(work_item->Do()); - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_3.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create_3.value().c_str(), + KEY_READ)); key.Close(); // now delete key_to_create_3 - ASSERT_TRUE(RegDeleteKey(HKEY_CURRENT_USER, key_to_create_3.c_str()) == - ERROR_SUCCESS); - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_3.c_str(), + ASSERT_TRUE(RegDeleteKey(HKEY_CURRENT_USER, + key_to_create_3.value().c_str()) == ERROR_SUCCESS); + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_3.value().c_str(), KEY_READ)); work_item->Rollback(); // key_to_create_3 has already been deleted, Rollback should delete // the rest. - ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_1.c_str(), + ASSERT_FALSE(key.Open(HKEY_CURRENT_USER, key_to_create_1.value().c_str(), KEY_READ)); } TEST_F(CreateRegKeyWorkItemTest, RollbackWithSetValue) { RegKey key; - std::wstring key_to_create(test_root); - file_util::AppendToPath(&key_to_create, L"aaaaa"); + FilePath key_to_create(test_root); + key_to_create = key_to_create.AppendASCII("aaaaa"); scoped_ptr<CreateRegKeyWorkItem> work_item( - WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, key_to_create)); + WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, + key_to_create.ToWStringHack())); EXPECT_TRUE(work_item->Do()); // Write a value under the key we just created. - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.value().c_str(), KEY_READ | KEY_SET_VALUE)); EXPECT_TRUE(key.WriteValue(L"name", L"value")); key.Close(); @@ -171,5 +185,6 @@ TEST_F(CreateRegKeyWorkItemTest, RollbackWithSetValue) { work_item->Rollback(); // Rollback should not remove the key. - EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.c_str(), KEY_READ)); + EXPECT_TRUE(key.Open(HKEY_CURRENT_USER, key_to_create.value().c_str(), + KEY_READ)); } diff --git a/chrome/installer/util/delete_tree_work_item_unittest.cc b/chrome/installer/util/delete_tree_work_item_unittest.cc index 4eea87d..9ec3c0b 100644 --- a/chrome/installer/util/delete_tree_work_item_unittest.cc +++ b/chrome/installer/util/delete_tree_work_item_unittest.cc @@ -60,34 +60,35 @@ namespace { // Delete a tree without key path. Everything should be deleted. TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); - CreateDirectory(dir_name_delete.c_str(), NULL); + FilePath dir_name_delete(test_dir_); + dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); + CreateDirectory(dir_name_delete.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); - std::wstring dir_name_delete_1(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_1, L"1"); - CreateDirectory(dir_name_delete_1.c_str(), NULL); + FilePath dir_name_delete_1(dir_name_delete); + dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); + CreateDirectory(dir_name_delete_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_1)); - std::wstring dir_name_delete_2(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_2, L"2"); - CreateDirectory(dir_name_delete_2.c_str(), NULL); + FilePath dir_name_delete_2(dir_name_delete); + dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); + CreateDirectory(dir_name_delete_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_2)); - std::wstring file_name_delete_1(dir_name_delete_1); - file_util::AppendToPath(&file_name_delete_1, L"File_1.txt"); - CreateTextFile(file_name_delete_1, text_content_1); + FilePath file_name_delete_1(dir_name_delete_1); + file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); + CreateTextFile(file_name_delete_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_1)); - std::wstring file_name_delete_2(dir_name_delete_2); - file_util::AppendToPath(&file_name_delete_2, L"File_2.txt"); - CreateTextFile(file_name_delete_2, text_content_1); + FilePath file_name_delete_2(dir_name_delete_2); + file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); + CreateTextFile(file_name_delete_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_2)); // test Do() scoped_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, std::wstring())); + WorkItem::CreateDeleteTreeWorkItem(dir_name_delete.ToWStringHack(), + std::wstring())); EXPECT_TRUE(work_item->Do()); // everything should be gone @@ -107,34 +108,35 @@ TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { // Rollback should bring back everything TEST_F(DeleteTreeWorkItemTest, DeleteTree) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); - CreateDirectory(dir_name_delete.c_str(), NULL); + FilePath dir_name_delete(test_dir_); + dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); + CreateDirectory(dir_name_delete.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); - std::wstring dir_name_delete_1(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_1, L"1"); - CreateDirectory(dir_name_delete_1.c_str(), NULL); + FilePath dir_name_delete_1(dir_name_delete); + dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); + CreateDirectory(dir_name_delete_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_1)); - std::wstring dir_name_delete_2(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_2, L"2"); - CreateDirectory(dir_name_delete_2.c_str(), NULL); + FilePath dir_name_delete_2(dir_name_delete); + dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); + CreateDirectory(dir_name_delete_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_2)); - std::wstring file_name_delete_1(dir_name_delete_1); - file_util::AppendToPath(&file_name_delete_1, L"File_1.txt"); - CreateTextFile(file_name_delete_1, text_content_1); + FilePath file_name_delete_1(dir_name_delete_1); + file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); + CreateTextFile(file_name_delete_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_1)); - std::wstring file_name_delete_2(dir_name_delete_2); - file_util::AppendToPath(&file_name_delete_2, L"File_2.txt"); - CreateTextFile(file_name_delete_2, text_content_1); + FilePath file_name_delete_2(dir_name_delete_2); + file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); + CreateTextFile(file_name_delete_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_2)); // test Do() scoped_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, file_name_delete_1)); + WorkItem::CreateDeleteTreeWorkItem(dir_name_delete.ToWStringHack(), + file_name_delete_1.ToWStringHack())); EXPECT_TRUE(work_item->Do()); // everything should be gone @@ -152,56 +154,58 @@ TEST_F(DeleteTreeWorkItemTest, DeleteTree) { // Delete a tree with key_path in use. Everything should still be there. TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_.ToWStringHack()); - file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); - CreateDirectory(dir_name_delete.c_str(), NULL); + FilePath dir_name_delete(test_dir_); + dir_name_delete = dir_name_delete.AppendASCII("to_be_delete"); + CreateDirectory(dir_name_delete.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); - std::wstring dir_name_delete_1(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_1, L"1"); - CreateDirectory(dir_name_delete_1.c_str(), NULL); + FilePath dir_name_delete_1(dir_name_delete); + dir_name_delete_1 = dir_name_delete_1.AppendASCII("1"); + CreateDirectory(dir_name_delete_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_1)); - std::wstring dir_name_delete_2(dir_name_delete); - file_util::AppendToPath(&dir_name_delete_2, L"2"); - CreateDirectory(dir_name_delete_2.c_str(), NULL); + FilePath dir_name_delete_2(dir_name_delete); + dir_name_delete_2 = dir_name_delete_2.AppendASCII("2"); + CreateDirectory(dir_name_delete_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete_2)); - std::wstring file_name_delete_1(dir_name_delete_1); - file_util::AppendToPath(&file_name_delete_1, L"File_1.txt"); - CreateTextFile(file_name_delete_1, text_content_1); + FilePath file_name_delete_1(dir_name_delete_1); + file_name_delete_1 = file_name_delete_1.AppendASCII("File_1.txt"); + CreateTextFile(file_name_delete_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_1)); - std::wstring file_name_delete_2(dir_name_delete_2); - file_util::AppendToPath(&file_name_delete_2, L"File_2.txt"); - CreateTextFile(file_name_delete_2, text_content_1); + FilePath file_name_delete_2(dir_name_delete_2); + file_name_delete_2 = file_name_delete_2.AppendASCII("File_2.txt"); + CreateTextFile(file_name_delete_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_delete_2)); // Create a key path file. - std::wstring key_path(dir_name_delete); - file_util::AppendToPath(&key_path, L"key_file.exe"); + FilePath key_path(dir_name_delete); + key_path = key_path.AppendASCII("key_file.exe"); wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileNameW(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); + FilePath exe_full_path(exe_full_path_str); file_util::CopyFile(exe_full_path, key_path); ASSERT_TRUE(file_util::PathExists(key_path)); - LOG(INFO) << "copy ourself from " << exe_full_path << " to " << key_path; + LOG(INFO) << "copy ourself from " + << exe_full_path.value() << " to " << key_path.value(); // Run the key path file to keep it in use. STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; ASSERT_TRUE( - ::CreateProcessW(NULL, const_cast<wchar_t*>(key_path.c_str()), + ::CreateProcessW(NULL, const_cast<wchar_t*>(key_path.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // test Do(). { scoped_ptr<DeleteTreeWorkItem> work_item( - WorkItem::CreateDeleteTreeWorkItem(dir_name_delete, key_path)); + WorkItem::CreateDeleteTreeWorkItem(dir_name_delete.ToWStringHack(), + key_path.ToWStringHack())); // delete should fail as file in use. EXPECT_FALSE(work_item->Do()); diff --git a/chrome/installer/util/helper_unittest.cc b/chrome/installer/util/helper_unittest.cc index d9985d8..e1d46c9 100644 --- a/chrome/installer/util/helper_unittest.cc +++ b/chrome/installer/util/helper_unittest.cc @@ -59,53 +59,53 @@ namespace { // should be deleted. TEST_F(SetupHelperTest, Delete) { // Create a Chrome dir - std::wstring chrome_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&chrome_dir, L"chrome"); - CreateDirectory(chrome_dir.c_str(), NULL); + FilePath chrome_dir(test_dir_); + chrome_dir = chrome_dir.AppendASCII("chrome"); + CreateDirectory(chrome_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir)); - std::wstring chrome_dir_1(chrome_dir); - file_util::AppendToPath(&chrome_dir_1, L"1.0.1.0"); - CreateDirectory(chrome_dir_1.c_str(), NULL); + FilePath chrome_dir_1(chrome_dir); + chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); + CreateDirectory(chrome_dir_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); - std::wstring chrome_dir_2(chrome_dir); - file_util::AppendToPath(&chrome_dir_2, L"1.0.2.0"); - CreateDirectory(chrome_dir_2.c_str(), NULL); + FilePath chrome_dir_2(chrome_dir); + chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); + CreateDirectory(chrome_dir_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); - std::wstring chrome_dir_3(chrome_dir); - file_util::AppendToPath(&chrome_dir_3, L"1.0.3.0"); - CreateDirectory(chrome_dir_3.c_str(), NULL); + FilePath chrome_dir_3(chrome_dir); + chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); + CreateDirectory(chrome_dir_3.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); - std::wstring chrome_dir_4(chrome_dir); - file_util::AppendToPath(&chrome_dir_4, L"1.0.4.0"); - CreateDirectory(chrome_dir_4.c_str(), NULL); + FilePath chrome_dir_4(chrome_dir); + chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); + CreateDirectory(chrome_dir_4.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); - std::wstring chrome_dll_1(chrome_dir_1); - file_util::AppendToPath(&chrome_dll_1, L"chrome.dll"); - CreateTextFile(chrome_dll_1, text_content_1); + FilePath chrome_dll_1(chrome_dir_1); + chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); - std::wstring chrome_dll_2(chrome_dir_2); - file_util::AppendToPath(&chrome_dll_2, L"chrome.dll"); - CreateTextFile(chrome_dll_2, text_content_1); + FilePath chrome_dll_2(chrome_dir_2); + chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_2)); - std::wstring chrome_dll_3(chrome_dir_3); - file_util::AppendToPath(&chrome_dll_3, L"chrome.dll"); - CreateTextFile(chrome_dll_3, text_content_1); + FilePath chrome_dll_3(chrome_dir_3); + chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_3.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); - std::wstring chrome_dll_4(chrome_dir_4); - file_util::AppendToPath(&chrome_dll_4, L"chrome.dll"); - CreateTextFile(chrome_dll_4, text_content_1); + FilePath chrome_dll_4(chrome_dir_4); + chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_4.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); std::wstring latest_version(L"1.0.4.0"); - installer::RemoveOldVersionDirs(chrome_dir, latest_version); + installer::RemoveOldVersionDirs(chrome_dir.value(), latest_version); // old versions should be gone EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); @@ -118,67 +118,67 @@ TEST_F(SetupHelperTest, Delete) { // Delete older version directories, keeping the one in used intact. TEST_F(SetupHelperTest, DeleteInUsed) { // Create a Chrome dir - std::wstring chrome_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&chrome_dir, L"chrome"); - CreateDirectory(chrome_dir.c_str(), NULL); + FilePath chrome_dir(test_dir_); + chrome_dir = chrome_dir.AppendASCII("chrome"); + CreateDirectory(chrome_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir)); - std::wstring chrome_dir_1(chrome_dir); - file_util::AppendToPath(&chrome_dir_1, L"1.0.1.0"); - CreateDirectory(chrome_dir_1.c_str(), NULL); + FilePath chrome_dir_1(chrome_dir); + chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); + CreateDirectory(chrome_dir_1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_1)); - std::wstring chrome_dir_2(chrome_dir); - file_util::AppendToPath(&chrome_dir_2, L"1.0.2.0"); - CreateDirectory(chrome_dir_2.c_str(), NULL); + FilePath chrome_dir_2(chrome_dir); + chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); + CreateDirectory(chrome_dir_2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_2)); - std::wstring chrome_dir_3(chrome_dir); - file_util::AppendToPath(&chrome_dir_3, L"1.0.3.0"); - CreateDirectory(chrome_dir_3.c_str(), NULL); + FilePath chrome_dir_3(chrome_dir); + chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); + CreateDirectory(chrome_dir_3.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_3)); - std::wstring chrome_dir_4(chrome_dir); - file_util::AppendToPath(&chrome_dir_4, L"1.0.4.0"); - CreateDirectory(chrome_dir_4.c_str(), NULL); + FilePath chrome_dir_4(chrome_dir); + chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); + CreateDirectory(chrome_dir_4.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir_4)); - std::wstring chrome_dll_1(chrome_dir_1); - file_util::AppendToPath(&chrome_dll_1, L"chrome.dll"); - CreateTextFile(chrome_dll_1, text_content_1); + FilePath chrome_dll_1(chrome_dir_1); + chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_1.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_1)); - std::wstring chrome_dll_2(chrome_dir_2); - file_util::AppendToPath(&chrome_dll_2, L"chrome.dll"); - CreateTextFile(chrome_dll_2, text_content_1); + FilePath chrome_dll_2(chrome_dir_2); + chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_2.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_2)); // Open the file to make it in use. std::ofstream file; - file.open(chrome_dll_2.c_str()); + file.open(chrome_dll_2.value().c_str()); - std::wstring chrome_othera_2(chrome_dir_2); - file_util::AppendToPath(&chrome_othera_2, L"othera.dll"); - CreateTextFile(chrome_othera_2, text_content_2); + FilePath chrome_othera_2(chrome_dir_2); + chrome_othera_2 = chrome_othera_2.AppendASCII("othera.dll"); + CreateTextFile(chrome_othera_2.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(chrome_othera_2)); - std::wstring chrome_otherb_2(chrome_dir_2); - file_util::AppendToPath(&chrome_otherb_2, L"otherb.dll"); - CreateTextFile(chrome_otherb_2, text_content_2); + FilePath chrome_otherb_2(chrome_dir_2); + chrome_otherb_2 = chrome_otherb_2.AppendASCII("otherb.dll"); + CreateTextFile(chrome_otherb_2.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(chrome_otherb_2)); - std::wstring chrome_dll_3(chrome_dir_3); - file_util::AppendToPath(&chrome_dll_3, L"chrome.dll"); - CreateTextFile(chrome_dll_3, text_content_1); + FilePath chrome_dll_3(chrome_dir_3); + chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_3.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_3)); - std::wstring chrome_dll_4(chrome_dir_4); - file_util::AppendToPath(&chrome_dll_4, L"chrome.dll"); - CreateTextFile(chrome_dll_4, text_content_1); + FilePath chrome_dll_4(chrome_dir_4); + chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); + CreateTextFile(chrome_dll_4.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(chrome_dll_4)); std::wstring latest_version(L"1.0.4.0"); - installer::RemoveOldVersionDirs(chrome_dir, latest_version); + installer::RemoveOldVersionDirs(chrome_dir.value(), latest_version); // old versions not in used should be gone EXPECT_FALSE(file_util::PathExists(chrome_dir_1)); diff --git a/chrome/installer/util/move_tree_work_item_unittest.cc b/chrome/installer/util/move_tree_work_item_unittest.cc index abf6160..182f5ab 100644 --- a/chrome/installer/util/move_tree_work_item_unittest.cc +++ b/chrome/installer/util/move_tree_work_item_unittest.cc @@ -77,34 +77,35 @@ namespace { // exist. TEST_F(MoveTreeWorkItemTest, MoveDirectory) { // Create two level deep source dir - std::wstring from_dir1(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir1, L"From_Dir1"); - CreateDirectory(from_dir1.c_str(), NULL); + FilePath from_dir1(test_dir_); + from_dir1 = from_dir1.AppendASCII("From_Dir1"); + CreateDirectory(from_dir1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir1)); - std::wstring from_dir2(from_dir1); - file_util::AppendToPath(&from_dir2, L"From_Dir2"); - CreateDirectory(from_dir2.c_str(), NULL); + FilePath from_dir2(from_dir1); + from_dir2 = from_dir2.AppendASCII("From_Dir2"); + CreateDirectory(from_dir2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir2)); - std::wstring from_file(from_dir2); - file_util::AppendToPath(&from_file, L"From_File"); - CreateTextFile(from_file, text_content_1); + FilePath from_file(from_dir2); + from_file = from_file.AppendASCII("From_File"); + CreateTextFile(from_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(from_file)); // Generate destination path - std::wstring to_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_dir, L"To_Dir"); + FilePath to_dir(test_dir_); + to_dir = to_dir.AppendASCII("To_Dir"); ASSERT_FALSE(file_util::PathExists(to_dir)); - std::wstring to_file(to_dir); - file_util::AppendToPath(&to_file, L"From_Dir2"); - file_util::AppendToPath(&to_file, L"From_File"); + FilePath to_file(to_dir); + to_file = to_file.AppendASCII("From_Dir2"); + to_file = to_file.AppendASCII("From_File"); ASSERT_FALSE(file_util::PathExists(to_file)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1, to_dir, temp_dir_.ToWStringHack())); + from_dir1.ToWStringHack(), to_dir.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -123,40 +124,41 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectory) { // exists. TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { // Create two level deep source dir - std::wstring from_dir1(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir1, L"From_Dir1"); - CreateDirectory(from_dir1.c_str(), NULL); + FilePath from_dir1(test_dir_); + from_dir1 = from_dir1.AppendASCII("From_Dir1"); + CreateDirectory(from_dir1.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir1)); - std::wstring from_dir2(from_dir1); - file_util::AppendToPath(&from_dir2, L"From_Dir2"); - CreateDirectory(from_dir2.c_str(), NULL); + FilePath from_dir2(from_dir1); + from_dir2 = from_dir2.AppendASCII("From_Dir2"); + CreateDirectory(from_dir2.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir2)); - std::wstring from_file(from_dir2); - file_util::AppendToPath(&from_file, L"From_File"); - CreateTextFile(from_file, text_content_1); + FilePath from_file(from_dir2); + from_file = from_file.AppendASCII("From_File"); + CreateTextFile(from_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(from_file)); // Create destination path - std::wstring to_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_dir, L"To_Dir"); - CreateDirectory(to_dir.c_str(), NULL); + FilePath to_dir(test_dir_); + to_dir = to_dir.AppendASCII("To_Dir"); + CreateDirectory(to_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); - std::wstring orig_to_file(to_dir); - file_util::AppendToPath(&orig_to_file, L"To_File"); - CreateTextFile(orig_to_file, text_content_2); + FilePath orig_to_file(to_dir); + orig_to_file = orig_to_file.AppendASCII("To_File"); + CreateTextFile(orig_to_file.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(orig_to_file)); - std::wstring new_to_file(to_dir); - file_util::AppendToPath(&new_to_file, L"From_Dir2"); - file_util::AppendToPath(&new_to_file, L"From_File"); + FilePath new_to_file(to_dir); + new_to_file = new_to_file.AppendASCII("From_Dir2"); + new_to_file = new_to_file.AppendASCII("From_File"); ASSERT_FALSE(file_util::PathExists(new_to_file)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1, to_dir, temp_dir_.ToWStringHack())); + from_dir1.ToWStringHack(), to_dir.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -171,38 +173,40 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_FALSE(file_util::PathExists(new_to_file)); EXPECT_TRUE(file_util::PathExists(orig_to_file)); - EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(text_content_2)); - EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(orig_to_file.ToWStringHack()).compare( + text_content_2)); + EXPECT_EQ(0, ReadTextFile(from_file.ToWStringHack()).compare(text_content_1)); } // Move one file from source to destination when destination does not // exist. TEST_F(MoveTreeWorkItemTest, MoveAFile) { // Create a file inside source dir - std::wstring from_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir, L"From_Dir"); - CreateDirectory(from_dir.c_str(), NULL); + FilePath from_dir(test_dir_); + from_dir = from_dir.AppendASCII("From_Dir"); + CreateDirectory(from_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); - std::wstring from_file(from_dir); - file_util::AppendToPath(&from_file, L"From_File"); - CreateTextFile(from_file, text_content_1); + FilePath from_file(from_dir); + from_file = from_file.AppendASCII("From_File"); + CreateTextFile(from_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(from_file)); // Generate destination file name - std::wstring to_file(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_file, L"To_File"); + FilePath to_file(test_dir_); + to_file = to_file.AppendASCII("To_File"); ASSERT_FALSE(file_util::PathExists(to_file)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_.ToWStringHack())); + from_file.ToWStringHack(), to_file.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); @@ -210,105 +214,108 @@ TEST_F(MoveTreeWorkItemTest, MoveAFile) { EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_TRUE(file_util::PathExists(from_file)); EXPECT_FALSE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); } // Move one file from source to destination when destination already // exists. TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { // Create a file inside source dir - std::wstring from_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir, L"From_Dir"); - CreateDirectory(from_dir.c_str(), NULL); + FilePath from_dir(test_dir_); + from_dir = from_dir.AppendASCII("From_Dir"); + CreateDirectory(from_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); - std::wstring from_file(from_dir); - file_util::AppendToPath(&from_file, L"From_File"); - CreateTextFile(from_file, text_content_1); + FilePath from_file(from_dir); + from_file = from_file.AppendASCII("From_File"); + CreateTextFile(from_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(from_file)); // Create destination path - std::wstring to_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_dir, L"To_Dir"); - CreateDirectory(to_dir.c_str(), NULL); + FilePath to_dir(test_dir_); + to_dir = to_dir.AppendASCII("To_Dir"); + CreateDirectory(to_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); - std::wstring to_file(to_dir); - file_util::AppendToPath(&to_file, L"To_File"); - CreateTextFile(to_file, text_content_2); + FilePath to_file(to_dir); + to_file = to_file.AppendASCII("To_File"); + CreateTextFile(to_file.value(), text_content_2); ASSERT_TRUE(file_util::PathExists(to_file)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_dir, temp_dir_.ToWStringHack())); + from_file.ToWStringHack(), to_dir.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_FALSE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(to_dir).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_dir.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(from_dir)); - EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_2)); } // Move one file from source to destination when destination already // exists and is in use. TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { // Create a file inside source dir - std::wstring from_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir, L"From_Dir"); - CreateDirectory(from_dir.c_str(), NULL); + FilePath from_dir(test_dir_); + from_dir = from_dir.AppendASCII("From_Dir"); + CreateDirectory(from_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); - std::wstring from_file(from_dir); - file_util::AppendToPath(&from_file, L"From_File"); - CreateTextFile(from_file, text_content_1); + FilePath from_file(from_dir); + from_file = from_file.AppendASCII("From_File"); + CreateTextFile(from_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(from_file)); // Create an executable in destination path by copying ourself to it. - std::wstring to_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_dir, L"To_Dir"); - CreateDirectory(to_dir.c_str(), NULL); + FilePath to_dir(test_dir_); + to_dir = to_dir.AppendASCII("To_Dir"); + CreateDirectory(to_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); - std::wstring to_file(to_dir); - file_util::AppendToPath(&to_file, L"To_File"); + FilePath exe_full_path(exe_full_path_str); + FilePath to_file(to_dir); + to_file = to_file.AppendASCII("To_File"); file_util::CopyFile(exe_full_path, to_file); ASSERT_TRUE(file_util::PathExists(to_file)); // Run the executable in destination path STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; - ASSERT_TRUE(::CreateProcess(NULL, const_cast<wchar_t*>(to_file.c_str()), + ASSERT_TRUE(::CreateProcess(NULL, + const_cast<wchar_t*>(to_file.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_.ToWStringHack())); + from_file.ToWStringHack(), to_file.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(from_dir)); - EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, to_file)); @@ -321,41 +328,43 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { // Move one file that is in use to destination. TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { // Create an executable for source by copying ourself to a new source dir. - std::wstring from_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&from_dir, L"From_Dir"); - CreateDirectory(from_dir.c_str(), NULL); + FilePath from_dir(test_dir_); + from_dir = from_dir.AppendASCII("From_Dir"); + CreateDirectory(from_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); - std::wstring exe_full_path(exe_full_path_str); - std::wstring from_file(from_dir); - file_util::AppendToPath(&from_file, L"From_File"); + FilePath exe_full_path(exe_full_path_str); + FilePath from_file(from_dir); + from_file = from_file.AppendASCII("From_File"); file_util::CopyFile(exe_full_path, from_file); ASSERT_TRUE(file_util::PathExists(from_file)); // Create a destination source dir and generate destination file name. - std::wstring to_dir(test_dir_.ToWStringHack()); - file_util::AppendToPath(&to_dir, L"To_Dir"); - CreateDirectory(to_dir.c_str(), NULL); + FilePath to_dir(test_dir_); + to_dir = to_dir.AppendASCII("To_Dir"); + CreateDirectory(to_dir.value().c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); - std::wstring to_file(to_dir); - file_util::AppendToPath(&to_file, L"To_File"); - CreateTextFile(to_file, text_content_1); + FilePath to_file(to_dir); + to_file = to_file.AppendASCII("To_File"); + CreateTextFile(to_file.value(), text_content_1); ASSERT_TRUE(file_util::PathExists(to_file)); // Run the executable in source path STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; - ASSERT_TRUE(::CreateProcess(NULL, const_cast<wchar_t*>(from_file.c_str()), + ASSERT_TRUE(::CreateProcess(NULL, + const_cast<wchar_t*>(from_file.value().c_str()), NULL, NULL, FALSE, CREATE_NO_WINDOW | CREATE_SUSPENDED, NULL, NULL, &si, &pi)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_.ToWStringHack())); + from_file.ToWStringHack(), to_file.ToWStringHack(), + temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); @@ -381,5 +390,5 @@ TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); } diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc index cf8bfd2..160db14 100644 --- a/chrome/installer/util/work_item_list_unittest.cc +++ b/chrome/installer/util/work_item_list_unittest.cc @@ -55,14 +55,14 @@ TEST_F(WorkItemListTest, ExecutionSuccess) { scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); scoped_ptr<WorkItem> work_item; - std::wstring top_dir_to_create(test_dir_.ToWStringHack()); - file_util::AppendToPath(&top_dir_to_create, L"a"); - std::wstring dir_to_create(top_dir_to_create); - file_util::AppendToPath(&dir_to_create, L"b"); + FilePath top_dir_to_create(test_dir_); + 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"); ASSERT_FALSE(file_util::PathExists(dir_to_create)); work_item.reset(reinterpret_cast<WorkItem*>( - WorkItem::CreateCreateDirWorkItem(dir_to_create))); + WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack()))); EXPECT_TRUE(work_item_list->AddWorkItem(work_item.release())); std::wstring key_to_create(test_root); @@ -104,14 +104,14 @@ TEST_F(WorkItemListTest, ExecutionFailAndRollback) { scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); scoped_ptr<WorkItem> work_item; - std::wstring top_dir_to_create(test_dir_.ToWStringHack()); - file_util::AppendToPath(&top_dir_to_create, L"a"); - std::wstring dir_to_create(top_dir_to_create); - file_util::AppendToPath(&dir_to_create, L"b"); + FilePath top_dir_to_create(test_dir_); + 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"); ASSERT_FALSE(file_util::PathExists(dir_to_create)); work_item.reset(reinterpret_cast<WorkItem*>( - WorkItem::CreateCreateDirWorkItem(dir_to_create))); + WorkItem::CreateCreateDirWorkItem(dir_to_create.ToWStringHack()))); EXPECT_TRUE(work_item_list->AddWorkItem(work_item.release())); std::wstring key_to_create(test_root); |