| 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/public/test/mock_download_manager.h" | 5 #include "content/public/test/mock_download_manager.h" |
| 6 | 6 |
| 7 #include "content/browser/byte_stream.h" | 7 #include "content/browser/byte_stream.h" |
| 8 #include "content/browser/download/download_create_info.h" | 8 #include "content/browser/download/download_create_info.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( | 12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( |
| 13 const std::string& guid, | 13 const std::string& guid, |
| 14 uint32_t id, | 14 uint32_t id, |
| 15 const base::FilePath& current_path, | 15 const base::FilePath& current_path, |
| 16 const base::FilePath& target_path, | 16 const base::FilePath& target_path, |
| 17 const std::vector<GURL>& url_chain, | 17 const std::vector<GURL>& url_chain, |
| 18 const GURL& referrer_url, | 18 const GURL& referrer_url, |
| 19 const GURL& tab_url, |
| 20 const GURL& tab_referrer_url, |
| 19 const std::string& mime_type, | 21 const std::string& mime_type, |
| 20 const std::string& original_mime_type, | 22 const std::string& original_mime_type, |
| 21 const base::Time& start_time, | 23 const base::Time& start_time, |
| 22 const base::Time& end_time, | 24 const base::Time& end_time, |
| 23 const std::string& etag, | 25 const std::string& etag, |
| 24 const std::string& last_modified, | 26 const std::string& last_modified, |
| 25 int64_t received_bytes, | 27 int64_t received_bytes, |
| 26 int64_t total_bytes, | 28 int64_t total_bytes, |
| 27 const std::string& hash, | 29 const std::string& hash, |
| 28 DownloadItem::DownloadState state, | 30 DownloadItem::DownloadState state, |
| 29 DownloadDangerType danger_type, | 31 DownloadDangerType danger_type, |
| 30 DownloadInterruptReason interrupt_reason, | 32 DownloadInterruptReason interrupt_reason, |
| 31 bool opened) | 33 bool opened) |
| 32 : guid(guid), | 34 : guid(guid), |
| 33 id(id), | 35 id(id), |
| 34 current_path(current_path), | 36 current_path(current_path), |
| 35 target_path(target_path), | 37 target_path(target_path), |
| 36 url_chain(url_chain), | 38 url_chain(url_chain), |
| 37 referrer_url(referrer_url), | 39 referrer_url(referrer_url), |
| 40 tab_url(tab_url), |
| 41 tab_referrer_url(tab_referrer_url), |
| 38 mime_type(mime_type), | 42 mime_type(mime_type), |
| 39 original_mime_type(original_mime_type), | 43 original_mime_type(original_mime_type), |
| 40 start_time(start_time), | 44 start_time(start_time), |
| 41 end_time(end_time), | 45 end_time(end_time), |
| 42 received_bytes(received_bytes), | 46 received_bytes(received_bytes), |
| 43 total_bytes(total_bytes), | 47 total_bytes(total_bytes), |
| 44 hash(hash), | 48 hash(hash), |
| 45 state(state), | 49 state(state), |
| 46 danger_type(danger_type), | 50 danger_type(danger_type), |
| 47 interrupt_reason(interrupt_reason), | 51 interrupt_reason(interrupt_reason), |
| 48 opened(opened) {} | 52 opened(opened) {} |
| 49 | 53 |
| 50 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( | 54 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( |
| 51 const CreateDownloadItemAdapter& rhs) | 55 const CreateDownloadItemAdapter& rhs) |
| 52 : guid(rhs.guid), | 56 : guid(rhs.guid), |
| 53 id(rhs.id), | 57 id(rhs.id), |
| 54 current_path(rhs.current_path), | 58 current_path(rhs.current_path), |
| 55 target_path(rhs.target_path), | 59 target_path(rhs.target_path), |
| 56 url_chain(rhs.url_chain), | 60 url_chain(rhs.url_chain), |
| 57 referrer_url(rhs.referrer_url), | 61 referrer_url(rhs.referrer_url), |
| 62 tab_url(rhs.tab_url), |
| 63 tab_referrer_url(rhs.tab_referrer_url), |
| 58 start_time(rhs.start_time), | 64 start_time(rhs.start_time), |
| 59 end_time(rhs.end_time), | 65 end_time(rhs.end_time), |
| 60 etag(rhs.etag), | 66 etag(rhs.etag), |
| 61 last_modified(rhs.last_modified), | 67 last_modified(rhs.last_modified), |
| 62 received_bytes(rhs.received_bytes), | 68 received_bytes(rhs.received_bytes), |
| 63 total_bytes(rhs.total_bytes), | 69 total_bytes(rhs.total_bytes), |
| 64 state(rhs.state), | 70 state(rhs.state), |
| 65 danger_type(rhs.danger_type), | 71 danger_type(rhs.danger_type), |
| 66 interrupt_reason(rhs.interrupt_reason), | 72 interrupt_reason(rhs.interrupt_reason), |
| 67 opened(rhs.opened) {} | 73 opened(rhs.opened) {} |
| 68 | 74 |
| 69 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} | 75 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} |
| 70 | 76 |
| 71 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( | 77 bool MockDownloadManager::CreateDownloadItemAdapter::operator==( |
| 72 const CreateDownloadItemAdapter& rhs) const { | 78 const CreateDownloadItemAdapter& rhs) const { |
| 73 return ( | 79 return ( |
| 74 guid == rhs.guid && id == rhs.id && current_path == rhs.current_path && | 80 guid == rhs.guid && id == rhs.id && current_path == rhs.current_path && |
| 75 target_path == rhs.target_path && url_chain == rhs.url_chain && | 81 target_path == rhs.target_path && url_chain == rhs.url_chain && |
| 76 referrer_url == rhs.referrer_url && mime_type == rhs.mime_type && | 82 referrer_url == rhs.referrer_url && tab_url == rhs.tab_url && |
| 83 tab_referrer_url == rhs.tab_referrer_url && mime_type == rhs.mime_type && |
| 77 original_mime_type == rhs.original_mime_type && | 84 original_mime_type == rhs.original_mime_type && |
| 78 start_time == rhs.start_time && end_time == rhs.end_time && | 85 start_time == rhs.start_time && end_time == rhs.end_time && |
| 79 etag == rhs.etag && last_modified == rhs.last_modified && | 86 etag == rhs.etag && last_modified == rhs.last_modified && |
| 80 received_bytes == rhs.received_bytes && total_bytes == rhs.total_bytes && | 87 received_bytes == rhs.received_bytes && total_bytes == rhs.total_bytes && |
| 81 state == rhs.state && danger_type == rhs.danger_type && | 88 state == rhs.state && danger_type == rhs.danger_type && |
| 82 interrupt_reason == rhs.interrupt_reason && opened == rhs.opened); | 89 interrupt_reason == rhs.interrupt_reason && opened == rhs.opened); |
| 83 } | 90 } |
| 84 | 91 |
| 85 MockDownloadManager::MockDownloadManager() {} | 92 MockDownloadManager::MockDownloadManager() {} |
| 86 | 93 |
| 87 MockDownloadManager::~MockDownloadManager() {} | 94 MockDownloadManager::~MockDownloadManager() {} |
| 88 | 95 |
| 89 void MockDownloadManager::StartDownload( | 96 void MockDownloadManager::StartDownload( |
| 90 std::unique_ptr<DownloadCreateInfo> info, | 97 std::unique_ptr<DownloadCreateInfo> info, |
| 91 std::unique_ptr<ByteStreamReader> stream, | 98 std::unique_ptr<ByteStreamReader> stream, |
| 92 const DownloadUrlParameters::OnStartedCallback& callback) { | 99 const DownloadUrlParameters::OnStartedCallback& callback) { |
| 93 MockStartDownload(info.get(), stream.get()); | 100 MockStartDownload(info.get(), stream.get()); |
| 94 } | 101 } |
| 95 | 102 |
| 96 DownloadItem* MockDownloadManager::CreateDownloadItem( | 103 DownloadItem* MockDownloadManager::CreateDownloadItem( |
| 97 const std::string& guid, | 104 const std::string& guid, |
| 98 uint32_t id, | 105 uint32_t id, |
| 99 const base::FilePath& current_path, | 106 const base::FilePath& current_path, |
| 100 const base::FilePath& target_path, | 107 const base::FilePath& target_path, |
| 101 const std::vector<GURL>& url_chain, | 108 const std::vector<GURL>& url_chain, |
| 102 const GURL& referrer_url, | 109 const GURL& referrer_url, |
| 110 const GURL& tab_url, |
| 111 const GURL& tab_referrer_url, |
| 103 const std::string& mime_type, | 112 const std::string& mime_type, |
| 104 const std::string& original_mime_type, | 113 const std::string& original_mime_type, |
| 105 const base::Time& start_time, | 114 const base::Time& start_time, |
| 106 const base::Time& end_time, | 115 const base::Time& end_time, |
| 107 const std::string& etag, | 116 const std::string& etag, |
| 108 const std::string& last_modified, | 117 const std::string& last_modified, |
| 109 int64_t received_bytes, | 118 int64_t received_bytes, |
| 110 int64_t total_bytes, | 119 int64_t total_bytes, |
| 111 const std::string& hash, | 120 const std::string& hash, |
| 112 DownloadItem::DownloadState state, | 121 DownloadItem::DownloadState state, |
| 113 DownloadDangerType danger_type, | 122 DownloadDangerType danger_type, |
| 114 DownloadInterruptReason interrupt_reason, | 123 DownloadInterruptReason interrupt_reason, |
| 115 bool opened) { | 124 bool opened) { |
| 116 CreateDownloadItemAdapter adapter(guid, | 125 CreateDownloadItemAdapter adapter( |
| 117 id, | 126 guid, id, current_path, target_path, url_chain, referrer_url, tab_url, |
| 118 current_path, | 127 tab_referrer_url, mime_type, original_mime_type, start_time, end_time, |
| 119 target_path, | 128 etag, last_modified, received_bytes, total_bytes, hash, state, |
| 120 url_chain, | 129 danger_type, interrupt_reason, opened); |
| 121 referrer_url, | |
| 122 mime_type, | |
| 123 original_mime_type, | |
| 124 start_time, | |
| 125 end_time, | |
| 126 etag, | |
| 127 last_modified, | |
| 128 received_bytes, | |
| 129 total_bytes, | |
| 130 hash, | |
| 131 state, | |
| 132 danger_type, | |
| 133 interrupt_reason, | |
| 134 opened); | |
| 135 return MockCreateDownloadItem(adapter); | 130 return MockCreateDownloadItem(adapter); |
| 136 } | 131 } |
| 137 | 132 |
| 138 } // namespace content | 133 } // namespace content |
| OLD | NEW |