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 "content/browser/download/base_file.h" | 5 #include "content/browser/download/base_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 FilePath full_path = base_file_->full_path(); | 71 FilePath full_path = base_file_->full_path(); |
72 | 72 |
73 if (!expected_data_.empty() && !expected_error_) { | 73 if (!expected_data_.empty() && !expected_error_) { |
74 // Make sure the data has been properly written to disk. | 74 // Make sure the data has been properly written to disk. |
75 std::string disk_data; | 75 std::string disk_data; |
76 EXPECT_TRUE(file_util::ReadFileToString(full_path, &disk_data)); | 76 EXPECT_TRUE(file_util::ReadFileToString(full_path, &disk_data)); |
77 EXPECT_EQ(expected_data_, disk_data); | 77 EXPECT_EQ(expected_data_, disk_data); |
78 } | 78 } |
79 | 79 |
| 80 // Stream pointers should be closed before |base_file_| to allow stream |
| 81 // objects to be actually closed and deleted and to allow the files to be |
| 82 // deleted on Win in BaseFile destructor. |
| 83 file_stream_.reset(); |
| 84 mock_file_stream_.reset(); |
80 // Make sure the mock BrowserThread outlives the BaseFile to satisfy | 85 // Make sure the mock BrowserThread outlives the BaseFile to satisfy |
81 // thread checks inside it. | 86 // thread checks inside it. |
82 base_file_.reset(); | 87 base_file_.reset(); |
83 | 88 |
84 EXPECT_EQ(expect_file_survives_, file_util::PathExists(full_path)); | 89 EXPECT_EQ(expect_file_survives_, file_util::PathExists(full_path)); |
85 } | 90 } |
86 | 91 |
87 void ResetHash() { | 92 void ResetHash() { |
88 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 93 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
89 memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen); | 94 memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 // be a string-wise match to base_file_->full_path().DirName() even though | 658 // be a string-wise match to base_file_->full_path().DirName() even though |
654 // they are in the same directory. | 659 // they are in the same directory. |
655 FilePath temp_file; | 660 FilePath temp_file; |
656 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), | 661 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), |
657 &temp_file)); | 662 &temp_file)); |
658 ASSERT_FALSE(temp_file.empty()); | 663 ASSERT_FALSE(temp_file.empty()); |
659 EXPECT_STREQ(temp_file.DirName().value().c_str(), | 664 EXPECT_STREQ(temp_file.DirName().value().c_str(), |
660 base_file_->full_path().DirName().value().c_str()); | 665 base_file_->full_path().DirName().value().c_str()); |
661 base_file_->Finish(); | 666 base_file_->Finish(); |
662 } | 667 } |
OLD | NEW |