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