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/logging.h" | 9 #include "base/logging.h" |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "base/scoped_temp_dir.h" | |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
13 #include "content/browser/browser_thread_impl.h" | 13 #include "content/browser/browser_thread_impl.h" |
14 #include "content/public/browser/download_interrupt_reasons.h" | 14 #include "content/public/browser/download_interrupt_reasons.h" |
15 #include "crypto/secure_hash.h" | 15 #include "crypto/secure_hash.h" |
16 #include "net/base/file_stream.h" | 16 #include "net/base/file_stream.h" |
17 #include "net/base/mock_file_stream.h" | 17 #include "net/base/mock_file_stream.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 expected_error_ = err; | 196 expected_error_ = err; |
197 } | 197 } |
198 | 198 |
199 protected: | 199 protected: |
200 linked_ptr<net::testing::MockFileStream> mock_file_stream_; | 200 linked_ptr<net::testing::MockFileStream> mock_file_stream_; |
201 | 201 |
202 // BaseClass instance we are testing. | 202 // BaseClass instance we are testing. |
203 scoped_ptr<BaseFile> base_file_; | 203 scoped_ptr<BaseFile> base_file_; |
204 | 204 |
205 // Temporary directory for renamed downloads. | 205 // Temporary directory for renamed downloads. |
206 ScopedTempDir temp_dir_; | 206 base::ScopedTempDir temp_dir_; |
207 | 207 |
208 // Expect the file to survive deletion of the BaseFile instance. | 208 // Expect the file to survive deletion of the BaseFile instance. |
209 bool expect_file_survives_; | 209 bool expect_file_survives_; |
210 | 210 |
211 // Expect the file to be in progress. | 211 // Expect the file to be in progress. |
212 bool expect_in_progress_; | 212 bool expect_in_progress_; |
213 | 213 |
214 // Hash calculator. | 214 // Hash calculator. |
215 scoped_ptr<crypto::SecureHash> secure_hash_; | 215 scoped_ptr<crypto::SecureHash> secure_hash_; |
216 | 216 |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 FilePath temp_file; | 660 FilePath temp_file; |
661 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), | 661 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), |
662 &temp_file)); | 662 &temp_file)); |
663 ASSERT_FALSE(temp_file.empty()); | 663 ASSERT_FALSE(temp_file.empty()); |
664 EXPECT_STREQ(temp_file.DirName().value().c_str(), | 664 EXPECT_STREQ(temp_file.DirName().value().c_str(), |
665 base_file_->full_path().DirName().value().c_str()); | 665 base_file_->full_path().DirName().value().c_str()); |
666 base_file_->Finish(); | 666 base_file_->Finish(); |
667 } | 667 } |
668 | 668 |
669 } // namespace content | 669 } // namespace content |
OLD | NEW |