| Index: chrome/browser/download/base_file_unittest.cc
|
| diff --git a/chrome/browser/download/base_file_unittest.cc b/chrome/browser/download/base_file_unittest.cc
|
| index f8da90b32c237fe351f364a2cf02dc35dd5122d3..c4ef0589a7efe503fbd77a4acca597c04a400ccd 100644
|
| --- a/chrome/browser/download/base_file_unittest.cc
|
| +++ b/chrome/browser/download/base_file_unittest.cc
|
| @@ -25,7 +25,8 @@ class BaseFileTest : public testing::Test {
|
| }
|
|
|
| virtual void SetUp() {
|
| - ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| + ASSERT_TRUE(save_dir_.CreateUniqueTempDir());
|
| + ASSERT_TRUE(renamed_dir_.CreateUniqueTempDir());
|
| base_file_.reset(
|
| new BaseFile(FilePath(), GURL(), GURL(), 0, file_stream_));
|
| }
|
| @@ -65,8 +66,11 @@ class BaseFileTest : public testing::Test {
|
| // BaseClass instance we are testing.
|
| scoped_ptr<BaseFile> base_file_;
|
|
|
| + // Temporary directory for downloaded files.
|
| + ScopedTempDir save_dir_;
|
| +
|
| // Temporary directory for renamed downloads.
|
| - ScopedTempDir temp_dir_;
|
| + ScopedTempDir renamed_dir_;
|
|
|
| // Expect the file to survive deletion of the BaseFile instance.
|
| bool expect_file_survives_;
|
| @@ -89,7 +93,7 @@ TEST_F(BaseFileTest, CreateDestroy) {
|
|
|
| // Cancel the download explicitly.
|
| TEST_F(BaseFileTest, Cancel) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
| EXPECT_TRUE(file_util::PathExists(base_file_->full_path()));
|
| base_file_->Cancel();
|
| EXPECT_FALSE(file_util::PathExists(base_file_->full_path()));
|
| @@ -99,7 +103,7 @@ TEST_F(BaseFileTest, Cancel) {
|
| // Write data to the file and detach it, so it doesn't get deleted
|
| // automatically when base_file_ is destructed.
|
| TEST_F(BaseFileTest, WriteAndDetach) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| base_file_->Finish();
|
| base_file_->Detach();
|
| @@ -108,7 +112,7 @@ TEST_F(BaseFileTest, WriteAndDetach) {
|
|
|
| // Write data to the file and detach it, and calculate its sha256 hash.
|
| TEST_F(BaseFileTest, WriteWithHashAndDetach) {
|
| - ASSERT_TRUE(base_file_->Initialize(true));
|
| + ASSERT_TRUE(base_file_->Initialize(true, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| base_file_->Finish();
|
|
|
| @@ -123,11 +127,11 @@ TEST_F(BaseFileTest, WriteWithHashAndDetach) {
|
|
|
| // Rename the file after writing to it, then detach.
|
| TEST_F(BaseFileTest, WriteThenRenameAndDetach) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
|
|
| FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(file_util::PathExists(initial_path));
|
| - FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + FilePath new_path(renamed_dir_.path().AppendASCII("NewFile"));
|
| EXPECT_FALSE(file_util::PathExists(new_path));
|
|
|
| AppendDataToFile(kTestData1);
|
| @@ -143,14 +147,14 @@ TEST_F(BaseFileTest, WriteThenRenameAndDetach) {
|
|
|
| // Write data to the file once.
|
| TEST_F(BaseFileTest, SingleWrite) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| base_file_->Finish();
|
| }
|
|
|
| // Write data to the file multiple times.
|
| TEST_F(BaseFileTest, MultipleWrites) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| AppendDataToFile(kTestData2);
|
| AppendDataToFile(kTestData3);
|
| @@ -161,7 +165,7 @@ TEST_F(BaseFileTest, MultipleWrites) {
|
|
|
| // Write data to the file once and calculate its sha256 hash.
|
| TEST_F(BaseFileTest, SingleWriteWithHash) {
|
| - ASSERT_TRUE(base_file_->Initialize(true));
|
| + ASSERT_TRUE(base_file_->Initialize(true, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| base_file_->Finish();
|
|
|
| @@ -175,7 +179,7 @@ TEST_F(BaseFileTest, SingleWriteWithHash) {
|
| TEST_F(BaseFileTest, MultipleWritesWithHash) {
|
| std::string hash;
|
|
|
| - ASSERT_TRUE(base_file_->Initialize(true));
|
| + ASSERT_TRUE(base_file_->Initialize(true, save_dir_.path()));
|
| AppendDataToFile(kTestData1);
|
| AppendDataToFile(kTestData2);
|
| AppendDataToFile(kTestData3);
|
| @@ -190,11 +194,11 @@ TEST_F(BaseFileTest, MultipleWritesWithHash) {
|
|
|
| // Rename the file after all writes to it.
|
| TEST_F(BaseFileTest, WriteThenRename) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
|
|
| FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(file_util::PathExists(initial_path));
|
| - FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + FilePath new_path(renamed_dir_.path().AppendASCII("NewFile"));
|
| EXPECT_FALSE(file_util::PathExists(new_path));
|
|
|
| AppendDataToFile(kTestData1);
|
| @@ -208,11 +212,11 @@ TEST_F(BaseFileTest, WriteThenRename) {
|
|
|
| // Rename the file while the download is still in progress.
|
| TEST_F(BaseFileTest, RenameWhileInProgress) {
|
| - ASSERT_TRUE(base_file_->Initialize(false));
|
| + ASSERT_TRUE(base_file_->Initialize(false, save_dir_.path()));
|
|
|
| FilePath initial_path(base_file_->full_path());
|
| EXPECT_TRUE(file_util::PathExists(initial_path));
|
| - FilePath new_path(temp_dir_.path().AppendASCII("NewFile"));
|
| + FilePath new_path(renamed_dir_.path().AppendASCII("NewFile"));
|
| EXPECT_FALSE(file_util::PathExists(new_path));
|
|
|
| AppendDataToFile(kTestData1);
|
|
|