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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 scoped_ptr<crypto::SecureHash> secure_hash_; | 215 scoped_ptr<crypto::SecureHash> secure_hash_; |
216 | 216 |
217 unsigned char sha256_hash_[kSha256HashLen]; | 217 unsigned char sha256_hash_[kSha256HashLen]; |
218 | 218 |
219 private: | 219 private: |
220 // Keep track of what data should be saved to the disk file. | 220 // Keep track of what data should be saved to the disk file. |
221 std::string expected_data_; | 221 std::string expected_data_; |
222 DownloadInterruptReason expected_error_; | 222 DownloadInterruptReason expected_error_; |
223 | 223 |
224 // Mock file thread to satisfy debug checks in BaseFile. | 224 // Mock file thread to satisfy debug checks in BaseFile. |
225 MessageLoop message_loop_; | 225 base::MessageLoop message_loop_; |
226 BrowserThreadImpl file_thread_; | 226 BrowserThreadImpl file_thread_; |
227 }; | 227 }; |
228 | 228 |
229 // This will initialize the entire array to zero. | 229 // This will initialize the entire array to zero. |
230 const unsigned char BaseFileTest::kEmptySha256Hash[] = { 0 }; | 230 const unsigned char BaseFileTest::kEmptySha256Hash[] = { 0 }; |
231 | 231 |
232 // Test the most basic scenario: just create the object and do a sanity check | 232 // Test the most basic scenario: just create the object and do a sanity check |
233 // on all its accessors. This is actually a case that rarely happens | 233 // on all its accessors. This is actually a case that rarely happens |
234 // in production, where we would at least Initialize it. | 234 // in production, where we would at least Initialize it. |
235 TEST_F(BaseFileTest, CreateDestroy) { | 235 TEST_F(BaseFileTest, CreateDestroy) { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 base::FilePath temp_file; | 665 base::FilePath temp_file; |
666 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), | 666 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), |
667 &temp_file)); | 667 &temp_file)); |
668 ASSERT_FALSE(temp_file.empty()); | 668 ASSERT_FALSE(temp_file.empty()); |
669 EXPECT_STREQ(temp_file.DirName().value().c_str(), | 669 EXPECT_STREQ(temp_file.DirName().value().c_str(), |
670 base_file_->full_path().DirName().value().c_str()); | 670 base_file_->full_path().DirName().value().c_str()); |
671 base_file_->Finish(); | 671 base_file_->Finish(); |
672 } | 672 } |
673 | 673 |
674 } // namespace content | 674 } // namespace content |
OLD | NEW |