| 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/mock_download_file.h" | 5 #include "content/browser/download/mock_download_file.h" |
| 6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
| 7 | 7 |
| 8 using ::testing::_; | 8 using ::testing::_; |
| 9 using ::testing::Return; | 9 using ::testing::Return; |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 void SuccessRun(const DownloadFile::InitializeCallback& callback, | 14 void SuccessRun( |
| 15 const DownloadItem::ReceivedSlices& received_slices) { | 15 const DownloadFile::InitializeCallback& initialize_callback, |
| 16 callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE); | 16 const DownloadFile::CancelRequestCallback& cancel_request_callback, |
| 17 const DownloadItem::ReceivedSlices& received_slices) { |
| 18 initialize_callback.Run(DOWNLOAD_INTERRUPT_REASON_NONE); |
| 17 } | 19 } |
| 18 | 20 |
| 19 } // namespace | 21 } // namespace |
| 20 | 22 |
| 21 MockDownloadFile::MockDownloadFile() { | 23 MockDownloadFile::MockDownloadFile() { |
| 22 // This is here because |Initialize()| is normally called right after | 24 // This is here because |Initialize()| is normally called right after |
| 23 // construction. | 25 // construction. |
| 24 ON_CALL(*this, Initialize(_, _)).WillByDefault(::testing::Invoke(SuccessRun)); | 26 ON_CALL(*this, Initialize(_, _, _)) |
| 27 .WillByDefault(::testing::Invoke(SuccessRun)); |
| 25 } | 28 } |
| 26 | 29 |
| 27 MockDownloadFile::~MockDownloadFile() { | 30 MockDownloadFile::~MockDownloadFile() { |
| 28 } | 31 } |
| 29 | 32 |
| 30 void MockDownloadFile::AddByteStream( | 33 void MockDownloadFile::AddByteStream( |
| 31 std::unique_ptr<ByteStreamReader> stream_reader, | 34 std::unique_ptr<ByteStreamReader> stream_reader, |
| 32 int64_t offset, | 35 int64_t offset, |
| 33 int64_t length) { | 36 int64_t length) { |
| 34 // Gmock currently can't mock method that takes move-only parameters, | 37 // Gmock currently can't mock method that takes move-only parameters, |
| 35 // delegate the EXPECT_CALL count to |DoAddByteStream|. | 38 // delegate the EXPECT_CALL count to |DoAddByteStream|. |
| 36 DoAddByteStream(stream_reader.get(), offset, length); | 39 DoAddByteStream(stream_reader.get(), offset, length); |
| 37 } | 40 } |
| 38 | 41 |
| 39 } // namespace content | 42 } // namespace content |
| OLD | NEW |