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