mock_download_manager.cc revision 7dbb3d5cf0c15f500944d211057644d6a2f37371
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 10namespace content { 11 12MockDownloadManager::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 int64 received_bytes, 21 int64 total_bytes, 22 DownloadItem::DownloadState state, 23 DownloadDangerType danger_type, 24 DownloadInterruptReason interrupt_reason, 25 bool opened) 26 : id(id), 27 current_path(current_path), 28 target_path(target_path), 29 url_chain(url_chain), 30 referrer_url(referrer_url), 31 start_time(start_time), 32 end_time(end_time), 33 received_bytes(received_bytes), 34 total_bytes(total_bytes), 35 state(state), 36 danger_type(danger_type), 37 interrupt_reason(interrupt_reason), 38 opened(opened) {} 39 40MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter( 41 const CreateDownloadItemAdapter& rhs) 42 : id(rhs.id), 43 current_path(rhs.current_path), 44 target_path(rhs.target_path), 45 url_chain(rhs.url_chain), 46 referrer_url(rhs.referrer_url), 47 start_time(rhs.start_time), 48 end_time(rhs.end_time), 49 received_bytes(rhs.received_bytes), 50 total_bytes(rhs.total_bytes), 51 state(rhs.state), 52 danger_type(rhs.danger_type), 53 interrupt_reason(rhs.interrupt_reason), 54 opened(rhs.opened) {} 55 56MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {} 57 58bool MockDownloadManager::CreateDownloadItemAdapter::operator==( 59 const CreateDownloadItemAdapter& rhs) { 60 return (id == rhs.id && 61 current_path == rhs.current_path && 62 target_path == rhs.target_path && 63 url_chain == rhs.url_chain && 64 referrer_url == rhs.referrer_url && 65 start_time == rhs.start_time && 66 end_time == rhs.end_time && 67 received_bytes == rhs.received_bytes && 68 total_bytes == rhs.total_bytes && 69 state == rhs.state && 70 danger_type == rhs.danger_type && 71 interrupt_reason == rhs.interrupt_reason && 72 opened == rhs.opened); 73} 74 75MockDownloadManager::MockDownloadManager() {} 76 77MockDownloadManager::~MockDownloadManager() {} 78 79void MockDownloadManager::StartDownload( 80 scoped_ptr<DownloadCreateInfo> info, 81 scoped_ptr<ByteStreamReader> stream, 82 const DownloadUrlParameters::OnStartedCallback& callback) { 83 MockStartDownload(info.get(), stream.get()); 84} 85 86DownloadItem* MockDownloadManager::CreateDownloadItem( 87 uint32 id, 88 const base::FilePath& current_path, 89 const base::FilePath& target_path, 90 const std::vector<GURL>& url_chain, 91 const GURL& referrer_url, 92 const base::Time& start_time, 93 const base::Time& end_time, 94 int64 received_bytes, 95 int64 total_bytes, 96 DownloadItem::DownloadState state, 97 DownloadDangerType danger_type, 98 DownloadInterruptReason interrupt_reason, 99 bool opened) { 100 CreateDownloadItemAdapter adapter( 101 id, current_path, target_path, url_chain, referrer_url, start_time, 102 end_time, received_bytes, total_bytes, state, danger_type, 103 interrupt_reason, opened); 104 return MockCreateDownloadItem(adapter); 105} 106 107} // namespace content 108