| 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 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "content/public/browser/download_interrupt_reasons.h" |
| 10 #include "content/public/browser/download_manager.h" | 11 #include "content/public/browser/download_manager.h" |
| 11 #include "content/public/browser/download_save_info.h" | 12 #include "content/public/browser/download_save_info.h" |
| 12 #include "content/public/browser/download_url_parameters.h" | 13 #include "content/public/browser/download_url_parameters.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 class DownloadRequestHandle; | 18 class DownloadRequestHandle; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 22 template <typename StatusType> |
| 23 class ByteStreamReader; |
| 24 |
| 21 // To avoid leaking download_request_handle.h to embedders. | 25 // To avoid leaking download_request_handle.h to embedders. |
| 22 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); | 26 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); |
| 23 | 27 |
| 24 class MockDownloadManager : public DownloadManager { | 28 class MockDownloadManager : public DownloadManager { |
| 25 public: | 29 public: |
| 26 // Structure to make it possible to match more than 10 arguments on | 30 // Structure to make it possible to match more than 10 arguments on |
| 27 // CreateDownloadItem. | 31 // CreateDownloadItem. |
| 28 struct CreateDownloadItemAdapter { | 32 struct CreateDownloadItemAdapter { |
| 29 uint32 id; | 33 uint32 id; |
| 30 base::FilePath current_path; | 34 base::FilePath current_path; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // DownloadManager: | 71 // DownloadManager: |
| 68 MOCK_METHOD1(SetDelegate, void(DownloadManagerDelegate* delegate)); | 72 MOCK_METHOD1(SetDelegate, void(DownloadManagerDelegate* delegate)); |
| 69 MOCK_CONST_METHOD0(GetDelegate, DownloadManagerDelegate*()); | 73 MOCK_CONST_METHOD0(GetDelegate, DownloadManagerDelegate*()); |
| 70 MOCK_METHOD0(Shutdown, void()); | 74 MOCK_METHOD0(Shutdown, void()); |
| 71 MOCK_METHOD1(GetAllDownloads, void(DownloadVector* downloads)); | 75 MOCK_METHOD1(GetAllDownloads, void(DownloadVector* downloads)); |
| 72 MOCK_METHOD1(Init, bool(BrowserContext* browser_context)); | 76 MOCK_METHOD1(Init, bool(BrowserContext* browser_context)); |
| 73 | 77 |
| 74 // Gasket for handling scoped_ptr arguments. | 78 // Gasket for handling scoped_ptr arguments. |
| 75 virtual void StartDownload( | 79 virtual void StartDownload( |
| 76 scoped_ptr<DownloadCreateInfo> info, | 80 scoped_ptr<DownloadCreateInfo> info, |
| 77 scoped_ptr<ByteStreamReader> stream, | 81 scoped_ptr<ByteStreamReader<DownloadInterruptReason> > stream, |
| 78 const DownloadUrlParameters::OnStartedCallback& callback) OVERRIDE; | 82 const DownloadUrlParameters::OnStartedCallback& callback) OVERRIDE; |
| 79 | 83 |
| 80 MOCK_METHOD2(MockStartDownload, | 84 MOCK_METHOD2(MockStartDownload, |
| 81 void(DownloadCreateInfo*, ByteStreamReader*)); | 85 void(DownloadCreateInfo*, |
| 86 ByteStreamReader<DownloadInterruptReason>*)); |
| 82 MOCK_METHOD2(RemoveDownloadsBetween, int(base::Time remove_begin, | 87 MOCK_METHOD2(RemoveDownloadsBetween, int(base::Time remove_begin, |
| 83 base::Time remove_end)); | 88 base::Time remove_end)); |
| 84 MOCK_METHOD1(RemoveDownloads, int(base::Time remove_begin)); | 89 MOCK_METHOD1(RemoveDownloads, int(base::Time remove_begin)); |
| 85 MOCK_METHOD0(RemoveAllDownloads, int()); | 90 MOCK_METHOD0(RemoveAllDownloads, int()); |
| 86 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); | 91 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); |
| 87 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE { | 92 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE { |
| 88 DownloadUrlMock(params.get()); | 93 DownloadUrlMock(params.get()); |
| 89 } | 94 } |
| 90 MOCK_METHOD1(AddObserver, void(Observer* observer)); | 95 MOCK_METHOD1(AddObserver, void(Observer* observer)); |
| 91 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); | 96 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 | 116 |
| 112 MOCK_CONST_METHOD0(InProgressCount, int()); | 117 MOCK_CONST_METHOD0(InProgressCount, int()); |
| 113 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); | 118 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
| 114 MOCK_METHOD0(CheckForHistoryFilesRemoval, void()); | 119 MOCK_METHOD0(CheckForHistoryFilesRemoval, void()); |
| 115 MOCK_METHOD1(GetDownload, DownloadItem*(uint32 id)); | 120 MOCK_METHOD1(GetDownload, DownloadItem*(uint32 id)); |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 } // namespace content | 123 } // namespace content |
| 119 | 124 |
| 120 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ | 125 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |