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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 base::FilePath target_path(tempdir.Append(initial_path.BaseName())); | 463 base::FilePath target_path(tempdir.Append(initial_path.BaseName())); |
464 | 464 |
465 // Targets | 465 // Targets |
466 base::FilePath target_path_suffixed( | 466 base::FilePath target_path_suffixed( |
467 target_path.InsertBeforeExtensionASCII(" (1)")); | 467 target_path.InsertBeforeExtensionASCII(" (1)")); |
468 ASSERT_FALSE(base::PathExists(target_path)); | 468 ASSERT_FALSE(base::PathExists(target_path)); |
469 ASSERT_FALSE(base::PathExists(target_path_suffixed)); | 469 ASSERT_FALSE(base::PathExists(target_path_suffixed)); |
470 | 470 |
471 // Make the directory unwritable and try to rename within it. | 471 // Make the directory unwritable and try to rename within it. |
472 { | 472 { |
473 file_util::PermissionRestorer restorer(tempdir); | 473 base::FilePermissionRestorer restorer(tempdir); |
474 ASSERT_TRUE(file_util::MakeFileUnwritable(tempdir)); | 474 ASSERT_TRUE(base::MakeFileUnwritable(tempdir)); |
475 | 475 |
476 // Expect nulling out of further processing. | 476 // Expect nulling out of further processing. |
477 EXPECT_CALL(*input_stream_, RegisterCallback(IsNullCallback())); | 477 EXPECT_CALL(*input_stream_, RegisterCallback(IsNullCallback())); |
478 EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, | 478 EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, |
479 RenameAndAnnotate(target_path, NULL)); | 479 RenameAndAnnotate(target_path, NULL)); |
480 EXPECT_FALSE(base::PathExists(target_path_suffixed)); | 480 EXPECT_FALSE(base::PathExists(target_path_suffixed)); |
481 } | 481 } |
482 | 482 |
483 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 483 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
484 loop_.RunUntilIdle(); | 484 loop_.RunUntilIdle(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 595 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
596 bytes_); | 596 bytes_); |
597 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 597 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
598 | 598 |
599 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 599 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
600 DestroyDownloadFile(0); | 600 DestroyDownloadFile(0); |
601 } | 601 } |
602 | 602 |
603 } // namespace content | 603 } // namespace content |
OLD | NEW |