| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/test/test_file_util.h" | 8 #include "base/test/test_file_util.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/byte_stream.h" | 10 #include "content/browser/byte_stream.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 454 } |
| 455 | 455 |
| 456 // Test to make sure we get the proper error on failure. | 456 // Test to make sure we get the proper error on failure. |
| 457 TEST_F(DownloadFileTest, RenameError) { | 457 TEST_F(DownloadFileTest, RenameError) { |
| 458 ASSERT_TRUE(CreateDownloadFile(0, true)); | 458 ASSERT_TRUE(CreateDownloadFile(0, true)); |
| 459 base::FilePath initial_path(download_file_->FullPath()); | 459 base::FilePath initial_path(download_file_->FullPath()); |
| 460 | 460 |
| 461 // Create a subdirectory. | 461 // Create a subdirectory. |
| 462 base::FilePath tempdir( | 462 base::FilePath tempdir( |
| 463 initial_path.DirName().Append(FILE_PATH_LITERAL("tempdir"))); | 463 initial_path.DirName().Append(FILE_PATH_LITERAL("tempdir"))); |
| 464 ASSERT_TRUE(file_util::CreateDirectory(tempdir)); | 464 ASSERT_TRUE(base::CreateDirectory(tempdir)); |
| 465 base::FilePath target_path(tempdir.Append(initial_path.BaseName())); | 465 base::FilePath target_path(tempdir.Append(initial_path.BaseName())); |
| 466 | 466 |
| 467 // Targets | 467 // Targets |
| 468 base::FilePath target_path_suffixed( | 468 base::FilePath target_path_suffixed( |
| 469 target_path.InsertBeforeExtensionASCII(" (1)")); | 469 target_path.InsertBeforeExtensionASCII(" (1)")); |
| 470 ASSERT_FALSE(base::PathExists(target_path)); | 470 ASSERT_FALSE(base::PathExists(target_path)); |
| 471 ASSERT_FALSE(base::PathExists(target_path_suffixed)); | 471 ASSERT_FALSE(base::PathExists(target_path_suffixed)); |
| 472 | 472 |
| 473 // Make the directory unwritable and try to rename within it. | 473 // Make the directory unwritable and try to rename within it. |
| 474 { | 474 { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 597 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
| 598 bytes_); | 598 bytes_); |
| 599 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 599 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
| 600 | 600 |
| 601 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 601 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
| 602 DestroyDownloadFile(0); | 602 DestroyDownloadFile(0); |
| 603 } | 603 } |
| 604 | 604 |
| 605 } // namespace content | 605 } // namespace content |
| OLD | NEW |