| Index: content/browser/download/base_file_unittest.cc
|
| diff --git a/content/browser/download/base_file_unittest.cc b/content/browser/download/base_file_unittest.cc
|
| index 42990109468f5a8b8bbc0464c7fb0a477a558d75..f852641614116608d485efb91a215bbb6e1ec143 100644
|
| --- a/content/browser/download/base_file_unittest.cc
|
| +++ b/content/browser/download/base_file_unittest.cc
|
| @@ -90,7 +90,7 @@ class BaseFileTest : public testing::Test {
|
|
|
| bool InitializeFile() {
|
| DownloadInterruptReason result = base_file_->Initialize(
|
| - base::FilePath(), temp_dir_.path(), base::File(), 0, std::string(),
|
| + base::FilePath(), temp_dir_.GetPath(), base::File(), 0, std::string(),
|
| std::unique_ptr<crypto::SecureHash>());
|
| EXPECT_EQ(expected_error_, result);
|
| return result == DOWNLOAD_INTERRUPT_REASON_NONE;
|
| @@ -124,7 +124,7 @@ class BaseFileTest : public testing::Test {
|
|
|
| EXPECT_EQ(
|
| DOWNLOAD_INTERRUPT_REASON_NONE,
|
| - file.Initialize(base::FilePath(), temp_dir_.path(), base::File(), 0,
|
| + file.Initialize(base::FilePath(), temp_dir_.GetPath(), base::File(), 0,
|
| std::string(), std::unique_ptr<crypto::SecureHash>()));
|
| file_name = file.full_path();
|
| EXPECT_NE(base::FilePath::StringType(), file_name.value());
|
| @@ -143,7 +143,7 @@ class BaseFileTest : public testing::Test {
|
| EXPECT_NE(base::FilePath::StringType(), file_name.value());
|
| BaseFile duplicate_file((net::BoundNetLog()));
|
| EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_NONE,
|
| - duplicate_file.Initialize(file_name, temp_dir_.path(),
|
| + duplicate_file.Initialize(file_name, temp_dir_.GetPath(),
|
| base::File(), 0, std::string(),
|
| std::unique_ptr<crypto::SecureHash>()));
|
| // Write something into it.
|
| @@ -248,7 +248,7 @@ TEST_F(BaseFileTest, WriteThenRenameAndDetach) {
|
|
|
| base::FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(base::PathExists(initial_path));
|
| - base::FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + base::FilePath new_path(temp_dir_.GetPath().AppendASCII("NewFile"));
|
| EXPECT_FALSE(base::PathExists(new_path));
|
|
|
| ASSERT_TRUE(AppendDataToFile(kTestData1));
|
| @@ -288,7 +288,7 @@ TEST_F(BaseFileTest, MultipleWritesInterruptedWithHash) {
|
| // Get the hash state and file name.
|
| std::unique_ptr<crypto::SecureHash> hash_state = base_file_->Finish();
|
|
|
| - base::FilePath new_file_path(temp_dir_.path().Append(
|
| + base::FilePath new_file_path(temp_dir_.GetPath().Append(
|
| base::FilePath(FILE_PATH_LITERAL("second_file"))));
|
|
|
| ASSERT_TRUE(base::CopyFile(base_file_->full_path(), new_file_path));
|
| @@ -314,7 +314,7 @@ TEST_F(BaseFileTest, WriteThenRename) {
|
|
|
| base::FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(base::PathExists(initial_path));
|
| - base::FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + base::FilePath new_path(temp_dir_.GetPath().AppendASCII("NewFile"));
|
| EXPECT_FALSE(base::PathExists(new_path));
|
|
|
| ASSERT_TRUE(AppendDataToFile(kTestData1));
|
| @@ -333,7 +333,7 @@ TEST_F(BaseFileTest, RenameWhileInProgress) {
|
|
|
| base::FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(base::PathExists(initial_path));
|
| - base::FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + base::FilePath new_path(temp_dir_.GetPath().AppendASCII("NewFile"));
|
| EXPECT_FALSE(base::PathExists(new_path));
|
|
|
| ASSERT_TRUE(AppendDataToFile(kTestData1));
|
| @@ -355,7 +355,7 @@ TEST_F(BaseFileTest, RenameWithError) {
|
|
|
| // TestDir is a subdirectory in |temp_dir_| that we will make read-only so
|
| // that the rename will fail.
|
| - base::FilePath test_dir(temp_dir_.path().AppendASCII("TestDir"));
|
| + base::FilePath test_dir(temp_dir_.GetPath().AppendASCII("TestDir"));
|
| ASSERT_TRUE(base::CreateDirectory(test_dir));
|
|
|
| base::FilePath new_path(test_dir.AppendASCII("TestFile"));
|
| @@ -375,7 +375,7 @@ TEST_F(BaseFileTest, RenameWithError) {
|
| TEST_F(BaseFileTest, RenameWithErrorInProgress) {
|
| ASSERT_TRUE(InitializeFile());
|
|
|
| - base::FilePath test_dir(temp_dir_.path().AppendASCII("TestDir"));
|
| + base::FilePath test_dir(temp_dir_.GetPath().AppendASCII("TestDir"));
|
| ASSERT_TRUE(base::CreateDirectory(test_dir));
|
|
|
| base::FilePath new_path(test_dir.AppendASCII("TestFile"));
|
| @@ -513,7 +513,7 @@ TEST_F(BaseFileTest, ReadonlyBaseFile) {
|
| // Open an existing file and continue writing to it. The hash of the partial
|
| // file is known and matches the existing contents.
|
| TEST_F(BaseFileTest, ExistingBaseFileKnownHash) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| ASSERT_EQ(kTestDataLength1,
|
| base::WriteFile(file_path, kTestData1, kTestDataLength1));
|
|
|
| @@ -532,7 +532,7 @@ TEST_F(BaseFileTest, ExistingBaseFileKnownHash) {
|
| // Open an existing file and continue writing to it. The hash of the partial
|
| // file is unknown.
|
| TEST_F(BaseFileTest, ExistingBaseFileUnknownHash) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| ASSERT_EQ(kTestDataLength1,
|
| base::WriteFile(file_path, kTestData1, kTestDataLength1));
|
|
|
| @@ -548,7 +548,7 @@ TEST_F(BaseFileTest, ExistingBaseFileUnknownHash) {
|
|
|
| // Open an existing file. The contentsof the file doesn't match the known hash.
|
| TEST_F(BaseFileTest, ExistingBaseFileIncorrectHash) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| ASSERT_EQ(kTestDataLength2,
|
| base::WriteFile(file_path, kTestData2, kTestDataLength2));
|
|
|
| @@ -563,7 +563,7 @@ TEST_F(BaseFileTest, ExistingBaseFileIncorrectHash) {
|
|
|
| // Open a large existing file with a known hash and continue writing to it.
|
| TEST_F(BaseFileTest, ExistingBaseFileLargeSizeKnownHash) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| std::string big_buffer(1024 * 200, 'a');
|
| ASSERT_EQ(static_cast<int>(big_buffer.size()),
|
| base::WriteFile(file_path, big_buffer.data(), big_buffer.size()));
|
| @@ -593,7 +593,7 @@ TEST_F(BaseFileTest, ExistingBaseFileLargeSizeKnownHash) {
|
|
|
| // Open a large existing file. The contents doesn't match the known hash.
|
| TEST_F(BaseFileTest, ExistingBaseFileLargeSizeIncorrectHash) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| std::string big_buffer(1024 * 200, 'a');
|
| ASSERT_EQ(static_cast<int>(big_buffer.size()),
|
| base::WriteFile(file_path, big_buffer.data(), big_buffer.size()));
|
| @@ -615,7 +615,7 @@ TEST_F(BaseFileTest, ExistingBaseFileLargeSizeIncorrectHash) {
|
|
|
| // Open an existing file. The size of the file is too short.
|
| TEST_F(BaseFileTest, ExistingBaseFileTooShort) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| ASSERT_EQ(kTestDataLength1,
|
| base::WriteFile(file_path, kTestData1, kTestDataLength1));
|
|
|
| @@ -628,7 +628,7 @@ TEST_F(BaseFileTest, ExistingBaseFileTooShort) {
|
|
|
| // Open an existing file. The size is larger than expected.
|
| TEST_F(BaseFileTest, ExistingBaseFileKnownHashTooLong) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| std::string contents;
|
| contents.append(kTestData1);
|
| contents.append("Something extra");
|
| @@ -650,7 +650,7 @@ TEST_F(BaseFileTest, ExistingBaseFileKnownHashTooLong) {
|
| // Open an existing file. The size is large than expected and the hash is
|
| // unknown.
|
| TEST_F(BaseFileTest, ExistingBaseFileUnknownHashTooLong) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| std::string contents;
|
| contents.append(kTestData1);
|
| contents.append("Something extra");
|
| @@ -671,7 +671,7 @@ TEST_F(BaseFileTest, ExistingBaseFileUnknownHashTooLong) {
|
| // enough to requre multiple Read()s to complete. This provides additional code
|
| // coverage for the CalculatePartialHash() logic.
|
| TEST_F(BaseFileTest, ExistingBaseFileUnknownHashTooLongForLargeFile) {
|
| - base::FilePath file_path = temp_dir_.path().AppendASCII("existing");
|
| + base::FilePath file_path = temp_dir_.GetPath().AppendASCII("existing");
|
| const size_t kFileSize = 1024 * 1024;
|
| const size_t kIntermediateSize = kFileSize / 2 + 111;
|
| // |contents| is 100 bytes longer than kIntermediateSize. The latter is the
|
| @@ -704,11 +704,12 @@ TEST_F(BaseFileTest, CreatedInDefaultDirectory) {
|
| EXPECT_FALSE(base_file_->full_path().empty());
|
|
|
| // On Windows, CreateTemporaryFileInDir() will cause a path with short names
|
| - // to be expanded into a path with long names. Thus temp_dir.path() might not
|
| + // to be expanded into a path with long names. Thus temp_dir.GetPath() might
|
| + // not
|
| // be a string-wise match to base_file_->full_path().DirName() even though
|
| // they are in the same directory.
|
| base::FilePath temp_file;
|
| - ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &temp_file));
|
| + ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &temp_file));
|
| ASSERT_FALSE(temp_file.empty());
|
| EXPECT_STREQ(temp_file.DirName().value().c_str(),
|
| base_file_->full_path().DirName().value().c_str());
|
|
|