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