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