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