Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/download/download_history_unittest.cc

Issue 1924473003: [Downloads] Use the initiating StoragePartition for resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/download/download_history.h" 5 #include "chrome/browser/download/download_history.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
213 CHECK(infos.get()); 213 CHECK(infos.get());
214 EXPECT_CALL(manager(), AddObserver(_)).WillOnce(WithArg<0>(Invoke( 214 EXPECT_CALL(manager(), AddObserver(_)).WillOnce(WithArg<0>(Invoke(
215 this, &DownloadHistoryTest::SetManagerObserver))); 215 this, &DownloadHistoryTest::SetManagerObserver)));
216 EXPECT_CALL(manager(), RemoveObserver(_)); 216 EXPECT_CALL(manager(), RemoveObserver(_));
217 download_created_index_ = 0; 217 download_created_index_ = 0;
218 for (size_t index = 0; index < infos->size(); ++index) { 218 for (size_t index = 0; index < infos->size(); ++index) {
219 const history::DownloadRow& row = infos->at(index); 219 const history::DownloadRow& row = infos->at(index);
220 content::MockDownloadManager::CreateDownloadItemAdapter adapter( 220 content::MockDownloadManager::CreateDownloadItemAdapter adapter(
221 row.guid, history::ToContentDownloadId(row.id), row.current_path, 221 row.guid, history::ToContentDownloadId(row.id), row.current_path,
222 row.target_path, row.url_chain, row.referrer_url, row.tab_url, 222 row.target_path, row.url_chain, row.referrer_url, row.site_url,
223 row.tab_referrer_url, row.mime_type, row.original_mime_type, 223 row.tab_url, row.tab_referrer_url, row.mime_type,
224 row.start_time, row.end_time, row.etag, row.last_modified, 224 row.original_mime_type, row.start_time, row.end_time, row.etag,
225 row.received_bytes, row.total_bytes, std::string(), 225 row.last_modified, row.received_bytes, row.total_bytes, std::string(),
226 history::ToContentDownloadState(row.state), 226 history::ToContentDownloadState(row.state),
227 history::ToContentDownloadDangerType(row.danger_type), 227 history::ToContentDownloadDangerType(row.danger_type),
228 history::ToContentDownloadInterruptReason(row.interrupt_reason), 228 history::ToContentDownloadInterruptReason(row.interrupt_reason),
229 row.opened); 229 row.opened);
230 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter)) 230 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter))
231 .WillOnce(DoAll( 231 .WillOnce(DoAll(
232 InvokeWithoutArgs( 232 InvokeWithoutArgs(
233 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder), 233 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder),
234 Return(&item(index)))); 234 Return(&item(index))));
235 } 235 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void InitBasicItem(const base::FilePath::CharType* path, 321 void InitBasicItem(const base::FilePath::CharType* path,
322 const char* url_string, 322 const char* url_string,
323 const char* referrer_string, 323 const char* referrer_string,
324 history::DownloadRow* info) { 324 history::DownloadRow* info) {
325 GURL url(url_string); 325 GURL url(url_string);
326 GURL referrer(referrer_string); 326 GURL referrer(referrer_string);
327 std::vector<GURL> url_chain; 327 std::vector<GURL> url_chain;
328 url_chain.push_back(url); 328 url_chain.push_back(url);
329 InitItem(base::GenerateGUID(), static_cast<uint32_t>(items_.size() + 1), 329 InitItem(base::GenerateGUID(), static_cast<uint32_t>(items_.size() + 1),
330 base::FilePath(path), base::FilePath(path), url_chain, referrer, 330 base::FilePath(path), base::FilePath(path), url_chain, referrer,
331 GURL("http://example.com/tab-url"), 331 GURL("http://example.com"), GURL("http://example.com/tab-url"),
332 GURL("http://example.com/tab-referrer-url"), 332 GURL("http://example.com/tab-referrer-url"),
333 "application/octet-stream", "application/octet-stream", 333 "application/octet-stream", "application/octet-stream",
334 (base::Time::Now() - base::TimeDelta::FromMinutes(10)), 334 (base::Time::Now() - base::TimeDelta::FromMinutes(10)),
335 (base::Time::Now() - base::TimeDelta::FromMinutes(1)), "Etag", 335 (base::Time::Now() - base::TimeDelta::FromMinutes(1)), "Etag",
336 "abc", 100, 100, content::DownloadItem::COMPLETE, 336 "abc", 100, 100, content::DownloadItem::COMPLETE,
337 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 337 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
338 content::DOWNLOAD_INTERRUPT_REASON_NONE, false, std::string(), 338 content::DOWNLOAD_INTERRUPT_REASON_NONE, false, std::string(),
339 std::string(), info); 339 std::string(), info);
340 } 340 }
341 341
342 void InitItem(const std::string& guid, 342 void InitItem(const std::string& guid,
343 uint32_t id, 343 uint32_t id,
344 const base::FilePath& current_path, 344 const base::FilePath& current_path,
345 const base::FilePath& target_path, 345 const base::FilePath& target_path,
346 const std::vector<GURL>& url_chain, 346 const std::vector<GURL>& url_chain,
347 const GURL& referrer, 347 const GURL& referrer,
348 const GURL& site_url,
348 const GURL& tab_url, 349 const GURL& tab_url,
349 const GURL& tab_referrer_url, 350 const GURL& tab_referrer_url,
350 const std::string& mime_type, 351 const std::string& mime_type,
351 const std::string& original_mime_type, 352 const std::string& original_mime_type,
352 const base::Time& start_time, 353 const base::Time& start_time,
353 const base::Time& end_time, 354 const base::Time& end_time,
354 const std::string& etag, 355 const std::string& etag,
355 const std::string& last_modified, 356 const std::string& last_modified,
356 int64_t received_bytes, 357 int64_t received_bytes,
357 int64_t total_bytes, 358 int64_t total_bytes,
358 content::DownloadItem::DownloadState state, 359 content::DownloadItem::DownloadState state,
359 content::DownloadDangerType danger_type, 360 content::DownloadDangerType danger_type,
360 content::DownloadInterruptReason interrupt_reason, 361 content::DownloadInterruptReason interrupt_reason,
361 bool opened, 362 bool opened,
362 const std::string& by_extension_id, 363 const std::string& by_extension_id,
363 const std::string& by_extension_name, 364 const std::string& by_extension_name,
364 history::DownloadRow* info) { 365 history::DownloadRow* info) {
365 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 366 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
366 367
367 size_t index = items_.size(); 368 size_t index = items_.size();
368 StrictMockDownloadItem* mock_item = new StrictMockDownloadItem(); 369 StrictMockDownloadItem* mock_item = new StrictMockDownloadItem();
369 items_.push_back(mock_item); 370 items_.push_back(mock_item);
370 371
371 info->current_path = current_path; 372 info->current_path = current_path;
372 info->target_path = target_path; 373 info->target_path = target_path;
373 info->url_chain = url_chain; 374 info->url_chain = url_chain;
374 info->referrer_url = referrer; 375 info->referrer_url = referrer;
376 info->site_url = site_url;
375 info->tab_url = tab_url; 377 info->tab_url = tab_url;
376 info->tab_referrer_url = tab_referrer_url; 378 info->tab_referrer_url = tab_referrer_url;
377 info->mime_type = mime_type; 379 info->mime_type = mime_type;
378 info->original_mime_type = original_mime_type; 380 info->original_mime_type = original_mime_type;
379 info->start_time = start_time; 381 info->start_time = start_time;
380 info->end_time = end_time; 382 info->end_time = end_time;
381 info->etag = etag; 383 info->etag = etag;
382 info->last_modified = last_modified; 384 info->last_modified = last_modified;
383 info->received_bytes = received_bytes; 385 info->received_bytes = received_bytes;
384 info->total_bytes = total_bytes; 386 info->total_bytes = total_bytes;
(...skipping 16 matching lines...) Expand all
401 DCHECK_LE(1u, url_chain.size()); 403 DCHECK_LE(1u, url_chain.size());
402 EXPECT_CALL(item(index), GetURL()) 404 EXPECT_CALL(item(index), GetURL())
403 .WillRepeatedly(ReturnRefOfCopy(url_chain[0])); 405 .WillRepeatedly(ReturnRefOfCopy(url_chain[0]));
404 EXPECT_CALL(item(index), GetUrlChain()) 406 EXPECT_CALL(item(index), GetUrlChain())
405 .WillRepeatedly(ReturnRefOfCopy(url_chain)); 407 .WillRepeatedly(ReturnRefOfCopy(url_chain));
406 EXPECT_CALL(item(index), GetMimeType()).WillRepeatedly(Return(mime_type)); 408 EXPECT_CALL(item(index), GetMimeType()).WillRepeatedly(Return(mime_type));
407 EXPECT_CALL(item(index), GetOriginalMimeType()).WillRepeatedly(Return( 409 EXPECT_CALL(item(index), GetOriginalMimeType()).WillRepeatedly(Return(
408 original_mime_type)); 410 original_mime_type));
409 EXPECT_CALL(item(index), GetReferrerUrl()) 411 EXPECT_CALL(item(index), GetReferrerUrl())
410 .WillRepeatedly(ReturnRefOfCopy(referrer)); 412 .WillRepeatedly(ReturnRefOfCopy(referrer));
413 EXPECT_CALL(item(index), GetSiteUrl())
414 .WillRepeatedly(ReturnRefOfCopy(site_url));
411 EXPECT_CALL(item(index), GetTabUrl()) 415 EXPECT_CALL(item(index), GetTabUrl())
412 .WillRepeatedly(ReturnRefOfCopy(tab_url)); 416 .WillRepeatedly(ReturnRefOfCopy(tab_url));
413 EXPECT_CALL(item(index), GetTabReferrerUrl()) 417 EXPECT_CALL(item(index), GetTabReferrerUrl())
414 .WillRepeatedly(ReturnRefOfCopy(tab_referrer_url)); 418 .WillRepeatedly(ReturnRefOfCopy(tab_referrer_url));
415 EXPECT_CALL(item(index), GetStartTime()).WillRepeatedly(Return(start_time)); 419 EXPECT_CALL(item(index), GetStartTime()).WillRepeatedly(Return(start_time));
416 EXPECT_CALL(item(index), GetEndTime()).WillRepeatedly(Return(end_time)); 420 EXPECT_CALL(item(index), GetEndTime()).WillRepeatedly(Return(end_time));
417 EXPECT_CALL(item(index), GetETag()).WillRepeatedly(ReturnRefOfCopy(etag)); 421 EXPECT_CALL(item(index), GetETag()).WillRepeatedly(ReturnRefOfCopy(etag));
418 EXPECT_CALL(item(index), GetLastModifiedTime()) 422 EXPECT_CALL(item(index), GetLastModifiedTime())
419 .WillRepeatedly(ReturnRefOfCopy(last_modified)); 423 .WillRepeatedly(ReturnRefOfCopy(last_modified));
420 EXPECT_CALL(item(index), GetReceivedBytes()) 424 EXPECT_CALL(item(index), GetReceivedBytes())
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 FinishCreateDownload(); 895 FinishCreateDownload();
892 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); 896 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0)));
893 897
894 // ItemAdded should call OnDownloadUpdated, which should detect that the item 898 // ItemAdded should call OnDownloadUpdated, which should detect that the item
895 // changed while it was being added and call UpdateDownload immediately. 899 // changed while it was being added and call UpdateDownload immediately.
896 info.opened = true; 900 info.opened = true;
897 ExpectDownloadUpdated(info); 901 ExpectDownloadUpdated(info);
898 } 902 }
899 903
900 } // anonymous namespace 904 } // anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_history.cc ('k') | chrome/browser/download/download_ui_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698