| 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_TEST_MOCK_DOWNLOAD_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_MANAGER_H_ | 6 #define CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 // To avoid leaking download_request_handle.h to embedders. | 25 // To avoid leaking download_request_handle.h to embedders. |
| 26 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); | 26 void PrintTo(const DownloadRequestHandle& params, std::ostream* os); |
| 27 | 27 |
| 28 class MockDownloadManager : public DownloadManager { | 28 class MockDownloadManager : public DownloadManager { |
| 29 public: | 29 public: |
| 30 // 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 |
| 31 // CreateDownloadItem. | 31 // CreateDownloadItem. |
| 32 struct CreateDownloadItemAdapter { | 32 struct CreateDownloadItemAdapter { |
| 33 std::string guid; |
| 33 uint32_t id; | 34 uint32_t id; |
| 34 base::FilePath current_path; | 35 base::FilePath current_path; |
| 35 base::FilePath target_path; | 36 base::FilePath target_path; |
| 36 std::vector<GURL> url_chain; | 37 std::vector<GURL> url_chain; |
| 37 GURL referrer_url; | 38 GURL referrer_url; |
| 38 std::string mime_type; | 39 std::string mime_type; |
| 39 std::string original_mime_type; | 40 std::string original_mime_type; |
| 40 base::Time start_time; | 41 base::Time start_time; |
| 41 base::Time end_time; | 42 base::Time end_time; |
| 42 std::string etag; | 43 std::string etag; |
| 43 std::string last_modified; | 44 std::string last_modified; |
| 44 int64_t received_bytes; | 45 int64_t received_bytes; |
| 45 int64_t total_bytes; | 46 int64_t total_bytes; |
| 46 DownloadItem::DownloadState state; | 47 DownloadItem::DownloadState state; |
| 47 DownloadDangerType danger_type; | 48 DownloadDangerType danger_type; |
| 48 DownloadInterruptReason interrupt_reason; | 49 DownloadInterruptReason interrupt_reason; |
| 49 bool opened; | 50 bool opened; |
| 50 | 51 |
| 51 CreateDownloadItemAdapter(uint32_t id, | 52 CreateDownloadItemAdapter(const std::string& guid, |
| 53 uint32_t id, |
| 52 const base::FilePath& current_path, | 54 const base::FilePath& current_path, |
| 53 const base::FilePath& target_path, | 55 const base::FilePath& target_path, |
| 54 const std::vector<GURL>& url_chain, | 56 const std::vector<GURL>& url_chain, |
| 55 const GURL& referrer_url, | 57 const GURL& referrer_url, |
| 56 const std::string& mime_type, | 58 const std::string& mime_type, |
| 57 const std::string& original_mime_type, | 59 const std::string& original_mime_type, |
| 58 const base::Time& start_time, | 60 const base::Time& start_time, |
| 59 const base::Time& end_time, | 61 const base::Time& end_time, |
| 60 const std::string& etag, | 62 const std::string& etag, |
| 61 const std::string& last_modified, | 63 const std::string& last_modified, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::Time remove_end)); | 98 base::Time remove_end)); |
| 97 MOCK_METHOD0(RemoveAllDownloads, int()); | 99 MOCK_METHOD0(RemoveAllDownloads, int()); |
| 98 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); | 100 MOCK_METHOD1(DownloadUrlMock, void(DownloadUrlParameters*)); |
| 99 void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) override { | 101 void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) override { |
| 100 DownloadUrlMock(params.get()); | 102 DownloadUrlMock(params.get()); |
| 101 } | 103 } |
| 102 MOCK_METHOD1(AddObserver, void(Observer* observer)); | 104 MOCK_METHOD1(AddObserver, void(Observer* observer)); |
| 103 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); | 105 MOCK_METHOD1(RemoveObserver, void(Observer* observer)); |
| 104 | 106 |
| 105 // Redirects to mock method to get around gmock 10 argument limit. | 107 // Redirects to mock method to get around gmock 10 argument limit. |
| 106 DownloadItem* CreateDownloadItem(uint32_t id, | 108 DownloadItem* CreateDownloadItem(const std::string& guid, |
| 109 uint32_t id, |
| 107 const base::FilePath& current_path, | 110 const base::FilePath& current_path, |
| 108 const base::FilePath& target_path, | 111 const base::FilePath& target_path, |
| 109 const std::vector<GURL>& url_chain, | 112 const std::vector<GURL>& url_chain, |
| 110 const GURL& referrer_url, | 113 const GURL& referrer_url, |
| 111 const std::string& mime_type, | 114 const std::string& mime_type, |
| 112 const std::string& original_mime_type, | 115 const std::string& original_mime_type, |
| 113 const base::Time& start_time, | 116 const base::Time& start_time, |
| 114 const base::Time& end_time, | 117 const base::Time& end_time, |
| 115 const std::string& etag, | 118 const std::string& etag, |
| 116 const std::string& last_modified, | 119 const std::string& last_modified, |
| 117 int64_t received_bytes, | 120 int64_t received_bytes, |
| 118 int64_t total_bytes, | 121 int64_t total_bytes, |
| 119 DownloadItem::DownloadState state, | 122 DownloadItem::DownloadState state, |
| 120 DownloadDangerType danger_type, | 123 DownloadDangerType danger_type, |
| 121 DownloadInterruptReason interrupt_reason, | 124 DownloadInterruptReason interrupt_reason, |
| 122 bool opened) override; | 125 bool opened) override; |
| 123 | 126 |
| 124 MOCK_METHOD1(MockCreateDownloadItem, | 127 MOCK_METHOD1(MockCreateDownloadItem, |
| 125 DownloadItem*(CreateDownloadItemAdapter adapter)); | 128 DownloadItem*(CreateDownloadItemAdapter adapter)); |
| 126 | 129 |
| 127 MOCK_CONST_METHOD0(InProgressCount, int()); | 130 MOCK_CONST_METHOD0(InProgressCount, int()); |
| 128 MOCK_CONST_METHOD0(NonMaliciousInProgressCount, int()); | 131 MOCK_CONST_METHOD0(NonMaliciousInProgressCount, int()); |
| 129 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); | 132 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
| 130 MOCK_METHOD0(CheckForHistoryFilesRemoval, void()); | 133 MOCK_METHOD0(CheckForHistoryFilesRemoval, void()); |
| 131 MOCK_METHOD1(GetDownload, DownloadItem*(uint32_t id)); | 134 MOCK_METHOD1(GetDownload, DownloadItem*(uint32_t id)); |
| 135 MOCK_METHOD1(GetDownloadByGuid, DownloadItem*(const std::string&)); |
| 132 }; | 136 }; |
| 133 | 137 |
| 134 } // namespace content | 138 } // namespace content |
| 135 | 139 |
| 136 #endif // CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_MANAGER_H_ | 140 #endif // CONTENT_PUBLIC_TEST_MOCK_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |