| 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/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 public: | 38 public: |
| 39 static const unsigned char kEmptySha256Hash[crypto::kSHA256Length]; | 39 static const unsigned char kEmptySha256Hash[crypto::kSHA256Length]; |
| 40 | 40 |
| 41 BaseFileTest() | 41 BaseFileTest() |
| 42 : expect_file_survives_(false), | 42 : expect_file_survives_(false), |
| 43 expect_in_progress_(true), | 43 expect_in_progress_(true), |
| 44 expected_error_(DOWNLOAD_INTERRUPT_REASON_NONE), | 44 expected_error_(DOWNLOAD_INTERRUPT_REASON_NONE), |
| 45 file_thread_(BrowserThread::FILE, &message_loop_) { | 45 file_thread_(BrowserThread::FILE, &message_loop_) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void SetUp() { | 48 void SetUp() override { |
| 49 ResetHash(); | 49 ResetHash(); |
| 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 51 base_file_.reset(new BaseFile(base::FilePath(), | 51 base_file_.reset(new BaseFile(base::FilePath(), |
| 52 GURL(), | 52 GURL(), |
| 53 GURL(), | 53 GURL(), |
| 54 0, | 54 0, |
| 55 false, | 55 false, |
| 56 std::string(), | 56 std::string(), |
| 57 base::File(), | 57 base::File(), |
| 58 net::BoundNetLog())); | 58 net::BoundNetLog())); |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual void TearDown() { | 61 void TearDown() override { |
| 62 EXPECT_FALSE(base_file_->in_progress()); | 62 EXPECT_FALSE(base_file_->in_progress()); |
| 63 if (!expected_error_) { | 63 if (!expected_error_) { |
| 64 EXPECT_EQ(static_cast<int64>(expected_data_.size()), | 64 EXPECT_EQ(static_cast<int64>(expected_data_.size()), |
| 65 base_file_->bytes_so_far()); | 65 base_file_->bytes_so_far()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 base::FilePath full_path = base_file_->full_path(); | 68 base::FilePath full_path = base_file_->full_path(); |
| 69 | 69 |
| 70 if (!expected_data_.empty() && !expected_error_) { | 70 if (!expected_data_.empty() && !expected_error_) { |
| 71 // Make sure the data has been properly written to disk. | 71 // Make sure the data has been properly written to disk. |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 684 |
| 685 const char kData[] = "hello"; | 685 const char kData[] = "hello"; |
| 686 const int kDataLength = static_cast<int>(arraysize(kData) - 1); | 686 const int kDataLength = static_cast<int>(arraysize(kData) - 1); |
| 687 ASSERT_EQ(kDataLength, base::WriteFile(full_path, kData, kDataLength)); | 687 ASSERT_EQ(kDataLength, base::WriteFile(full_path, kData, kDataLength)); |
| 688 // The file that we created here should stick around when the BaseFile is | 688 // The file that we created here should stick around when the BaseFile is |
| 689 // destroyed during TearDown. | 689 // destroyed during TearDown. |
| 690 expect_file_survives_ = true; | 690 expect_file_survives_ = true; |
| 691 } | 691 } |
| 692 | 692 |
| 693 } // namespace content | 693 } // namespace content |
| OLD | NEW |