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