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.
5 #include "content/public/test/mock_download_manager.h"
7 #include "content/browser/byte_stream.h"
8 #include "content/browser/download/download_create_info.h"
12 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter(
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
,
24 DownloadItem::DownloadState state
,
25 DownloadDangerType danger_type
,
26 DownloadInterruptReason interrupt_reason
,
29 current_path(current_path
),
30 target_path(target_path
),
32 referrer_url(referrer_url
),
33 start_time(start_time
),
35 received_bytes(received_bytes
),
36 total_bytes(total_bytes
),
38 danger_type(danger_type
),
39 interrupt_reason(interrupt_reason
),
42 MockDownloadManager::CreateDownloadItemAdapter::CreateDownloadItemAdapter(
43 const CreateDownloadItemAdapter
& rhs
)
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
),
52 last_modified(rhs
.last_modified
),
53 received_bytes(rhs
.received_bytes
),
54 total_bytes(rhs
.total_bytes
),
56 danger_type(rhs
.danger_type
),
57 interrupt_reason(rhs
.interrupt_reason
),
60 MockDownloadManager::CreateDownloadItemAdapter::~CreateDownloadItemAdapter() {}
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
&&
72 last_modified
== rhs
.last_modified
&&
73 received_bytes
== rhs
.received_bytes
&&
74 total_bytes
== rhs
.total_bytes
&&
76 danger_type
== rhs
.danger_type
&&
77 interrupt_reason
== rhs
.interrupt_reason
&&
78 opened
== rhs
.opened
);
81 MockDownloadManager::MockDownloadManager() {}
83 MockDownloadManager::~MockDownloadManager() {}
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());
92 DownloadItem
* MockDownloadManager::CreateDownloadItem(
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
,
104 DownloadItem::DownloadState state
,
105 DownloadDangerType danger_type
,
106 DownloadInterruptReason interrupt_reason
,
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
);
115 } // namespace content