| 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 58a79538731d96fb2e80d39335adcc574b905830..63e51151bd2b8d786c109c49e65427e1c594c545 100644
|
| --- a/content/browser/download/base_file_unittest.cc
|
| +++ b/content/browser/download/base_file_unittest.cc
|
| @@ -51,7 +51,8 @@ class BaseFileTest : public testing::Test {
|
| virtual void SetUp() {
|
| ResetHash();
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| - base_file_.reset(new BaseFile(FilePath(),
|
| + base_file_.reset(new BaseFile(temp_dir_.path(),
|
| + FilePath(),
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -102,7 +103,8 @@ class BaseFileTest : public testing::Test {
|
| }
|
|
|
| void MakeFileWithHash() {
|
| - base_file_.reset(new BaseFile(FilePath(),
|
| + base_file_.reset(new BaseFile(temp_dir_.path(),
|
| + FilePath(),
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -157,10 +159,11 @@ class BaseFileTest : public testing::Test {
|
|
|
| // Helper functions.
|
| // Create a file. Returns the complete file path.
|
| - static FilePath CreateTestFile() {
|
| + FilePath CreateTestFile() {
|
| FilePath file_name;
|
| linked_ptr<net::FileStream> dummy_file_stream;
|
| - BaseFile file(FilePath(),
|
| + BaseFile file(temp_dir_.path(),
|
| + FilePath(),
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -182,10 +185,11 @@ class BaseFileTest : public testing::Test {
|
| }
|
|
|
| // Create a file with the specified file name.
|
| - static void CreateFileWithName(const FilePath& file_name) {
|
| + void CreateFileWithName(const FilePath& file_name) {
|
| EXPECT_NE(FilePath::StringType(), file_name.value());
|
| linked_ptr<net::FileStream> dummy_file_stream;
|
| - BaseFile duplicate_file(file_name,
|
| + BaseFile duplicate_file(temp_dir_.path(),
|
| + file_name,
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -406,7 +410,8 @@ TEST_F(BaseFileTest, MultipleWritesInterruptedWithHash) {
|
|
|
| // Create another file
|
| linked_ptr<net::FileStream> second_stream;
|
| - BaseFile second_file(FilePath(),
|
| + BaseFile second_file(temp_dir_.path(),
|
| + FilePath(),
|
| GURL(),
|
| GURL(),
|
| base_file_->bytes_so_far(),
|
| @@ -489,7 +494,8 @@ TEST_F(BaseFileTest, RenameWithError) {
|
| // Write data to the file multiple times.
|
| TEST_F(BaseFileTest, MultipleWritesWithError) {
|
| ASSERT_TRUE(OpenMockFileStream());
|
| - base_file_.reset(new BaseFile(mock_file_stream_->get_path(),
|
| + base_file_.reset(new BaseFile(temp_dir_.path(),
|
| + mock_file_stream_->get_path(),
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -534,7 +540,8 @@ TEST_F(BaseFileTest, AppendToBaseFile) {
|
| set_expected_data(kTestData4);
|
|
|
| // Use the file we've just created.
|
| - base_file_.reset(new BaseFile(existing_file_name,
|
| + base_file_.reset(new BaseFile(temp_dir_.path(),
|
| + existing_file_name,
|
| GURL(),
|
| GURL(),
|
| kTestDataLength4,
|
| @@ -568,7 +575,8 @@ TEST_F(BaseFileTest, ReadonlyBaseFile) {
|
| EXPECT_TRUE(file_util::MakeFileUnwritable(readonly_file_name));
|
|
|
| // Try to overwrite it.
|
| - base_file_.reset(new BaseFile(readonly_file_name,
|
| + base_file_.reset(new BaseFile(temp_dir_.path(),
|
| + readonly_file_name,
|
| GURL(),
|
| GURL(),
|
| 0,
|
| @@ -641,3 +649,13 @@ TEST_F(BaseFileTest, SpeedAfterNoElapsedTime) {
|
| ASSERT_EQ(0, CurrentSpeedAtTime(StartTick()));
|
| base_file_->Finish();
|
| }
|
| +
|
| +// Test that a temporary file is created in the default download directory.
|
| +TEST_F(BaseFileTest, CreatedInDefaultDirectory) {
|
| + ASSERT_TRUE(base_file_->full_path().empty());
|
| + ASSERT_EQ(net::OK, base_file_->Initialize());
|
| + EXPECT_FALSE(base_file_->full_path().empty());
|
| + // The default download directory was set to be temp_dir_.path() in SetUp().
|
| + EXPECT_EQ(temp_dir_.path(), base_file_->full_path().DirName());
|
| + base_file_->Finish();
|
| +}
|
|
|