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

Side by Side Diff: content/browser/download/download_file_manager_unittest.cc

Issue 9639001: Move download interrupt reasons to content\public (the enum that's used by chrome). The rest keep i… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 8 years, 9 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 | Annotate | Revision Log
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 "content/browser/download/download_file_manager.h" 5 #include "content/browser/download/download_file_manager.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "content/browser/browser_thread_impl.h" 12 #include "content/browser/browser_thread_impl.h"
13 #include "content/browser/download/download_buffer.h" 13 #include "content/browser/download/download_buffer.h"
14 #include "content/browser/download/download_create_info.h" 14 #include "content/browser/download/download_create_info.h"
15 #include "content/browser/download/download_interrupt_reasons_impl.h"
15 #include "content/browser/download/download_request_handle.h" 16 #include "content/browser/download/download_request_handle.h"
16 #include "content/browser/download/mock_download_file.h" 17 #include "content/browser/download/mock_download_file.h"
17 #include "content/public/browser/download_id.h" 18 #include "content/public/browser/download_id.h"
18 #include "content/test/mock_download_manager.h" 19 #include "content/test/mock_download_manager.h"
19 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using content::BrowserThread; 25 using content::BrowserThread;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 download_file_manager_->UpdateDownload(id, download_buffer_.get()); 263 download_file_manager_->UpdateDownload(id, download_buffer_.get());
263 264
264 if (error_to_insert != net::OK) { 265 if (error_to_insert != net::OK) {
265 EXPECT_CALL(*download_manager_, 266 EXPECT_CALL(*download_manager_,
266 OnDownloadInterrupted( 267 OnDownloadInterrupted(
267 id.local(), 268 id.local(),
268 byte_count_[id], 269 byte_count_[id],
269 "", 270 "",
270 ConvertNetErrorToInterruptReason(error_to_insert, 271 content::ConvertNetErrorToInterruptReason(
271 DOWNLOAD_INTERRUPT_FROM_DISK))); 272 error_to_insert, content::DOWNLOAD_INTERRUPT_FROM_DISK)));
272 273
273 ProcessAllPendingMessages(); 274 ProcessAllPendingMessages();
274 ++error_count_[id]; 275 ++error_count_[id];
275 } 276 }
276 277
277 ClearExpectations(id); 278 ClearExpectations(id);
278 delete [] expected_data; 279 delete [] expected_data;
279 } 280 }
280 281
281 // Renames the download file. 282 // Renames the download file.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 download_file_manager_->RenameCompletingDownloadFile( 341 download_file_manager_->RenameCompletingDownloadFile(
341 id, new_path, (should_overwrite == OVERWRITE)); 342 id, new_path, (should_overwrite == OVERWRITE));
342 } 343 }
343 344
344 if (rename_error != net::OK) { 345 if (rename_error != net::OK) {
345 EXPECT_CALL(*download_manager_, 346 EXPECT_CALL(*download_manager_,
346 OnDownloadInterrupted( 347 OnDownloadInterrupted(
347 id.local(), 348 id.local(),
348 byte_count_[id], 349 byte_count_[id],
349 "", 350 "",
350 ConvertNetErrorToInterruptReason( 351 content::ConvertNetErrorToInterruptReason(
351 rename_error, DOWNLOAD_INTERRUPT_FROM_DISK))); 352 rename_error,
353 content::DOWNLOAD_INTERRUPT_FROM_DISK)));
352 ProcessAllPendingMessages(); 354 ProcessAllPendingMessages();
353 ++error_count_[id]; 355 ++error_count_[id];
354 } else if (state == COMPLETE) { 356 } else if (state == COMPLETE) {
355 EXPECT_CALL(*download_manager_, OnDownloadRenamedToFinalName( 357 EXPECT_CALL(*download_manager_, OnDownloadRenamedToFinalName(
356 id.local(), unique_path, _)); 358 id.local(), unique_path, _));
357 ProcessAllPendingMessages(); 359 ProcessAllPendingMessages();
358 } 360 }
359 } 361 }
360 362
361 // Finish the download operation. 363 // Finish the download operation.
362 // |id| is the download ID of the download file. 364 // |id| is the download ID of the download file.
363 // |reason| is the interrupt reason to inject. For no interrupt, use 365 // |reason| is the interrupt reason to inject. For no interrupt, use
364 // DOWNLOAD_INTERRUPT_REASON_NONE. 366 // DOWNLOAD_INTERRUPT_REASON_NONE.
365 // |security_string| is the extra security information, if interrupted. 367 // |security_string| is the extra security information, if interrupted.
366 void OnResponseCompleted(const DownloadId& id, 368 void OnResponseCompleted(const DownloadId& id,
367 InterruptReason reason, 369 content::DownloadInterruptReason reason,
368 const std::string& security_string) { 370 const std::string& security_string) {
369 // OnResponseCompleted 371 // OnResponseCompleted
370 // GetDownloadFile 372 // GetDownloadFile
371 // DownloadFile::Finish 373 // DownloadFile::Finish
372 // DownloadFile::GetDownloadManager 374 // DownloadFile::GetDownloadManager
373 // DownloadFile::BytesSoFar 375 // DownloadFile::BytesSoFar
374 // Process one message in the message loop 376 // Process one message in the message loop
375 // 377 //
376 // OK: 378 // OK:
377 // DownloadFile::GetHash 379 // DownloadFile::GetHash
378 // DownloadManager::OnResponseCompleted 380 // DownloadManager::OnResponseCompleted
379 // 381 //
380 // On Error: 382 // On Error:
381 // DownloadManager::OnDownloadInterrupted 383 // DownloadManager::OnDownloadInterrupted
382 MockDownloadFile* file = download_file_factory_->GetExistingFile(id); 384 MockDownloadFile* file = download_file_factory_->GetExistingFile(id);
383 ASSERT_TRUE(file != NULL); 385 ASSERT_TRUE(file != NULL);
384 386
385 EXPECT_CALL(*file, Finish()); 387 EXPECT_CALL(*file, Finish());
386 EXPECT_CALL(*file, GetDownloadManager()); 388 EXPECT_CALL(*file, GetDownloadManager());
387 if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) { 389 if (reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) {
388 EXPECT_CALL(*file, GetHash(_)) 390 EXPECT_CALL(*file, GetHash(_))
389 .WillOnce(Return(false)); 391 .WillOnce(Return(false));
390 } else { 392 } else {
391 EXPECT_CALL(*file, GetHashState()); 393 EXPECT_CALL(*file, GetHashState());
392 } 394 }
393 EXPECT_CALL(*file, BytesSoFar()) 395 EXPECT_CALL(*file, BytesSoFar())
394 .Times(AtLeast(1)) 396 .Times(AtLeast(1))
395 .WillRepeatedly(Return(byte_count_[id])); 397 .WillRepeatedly(Return(byte_count_[id]));
396 398
397 download_file_manager_->OnResponseCompleted(id, reason, security_string); 399 download_file_manager_->OnResponseCompleted(id, reason, security_string);
398 400
399 if (reason == DOWNLOAD_INTERRUPT_REASON_NONE) { 401 if (reason == content::DOWNLOAD_INTERRUPT_REASON_NONE) {
400 EXPECT_CALL(*download_manager_, 402 EXPECT_CALL(*download_manager_,
401 OnResponseCompleted(id.local(), byte_count_[id], "")) 403 OnResponseCompleted(id.local(), byte_count_[id], ""))
402 .Times(1); 404 .Times(1);
403 } else { 405 } else {
404 EXPECT_EQ(0, error_count_[id]); 406 EXPECT_EQ(0, error_count_[id]);
405 407
406 EXPECT_CALL(*download_manager_, 408 EXPECT_CALL(*download_manager_,
407 OnDownloadInterrupted(id.local(), 409 OnDownloadInterrupted(id.local(),
408 byte_count_[id], 410 byte_count_[id],
409 "", 411 "",
410 reason)) 412 reason))
411 .Times(1); 413 .Times(1);
412 } 414 }
413 415
414 ProcessAllPendingMessages(); 416 ProcessAllPendingMessages();
415 417
416 if (reason != DOWNLOAD_INTERRUPT_REASON_NONE) 418 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE)
417 ++error_count_[id]; 419 ++error_count_[id];
418 420
419 ClearExpectations(id); 421 ClearExpectations(id);
420 } 422 }
421 423
422 void CleanUp(DownloadId id) { 424 void CleanUp(DownloadId id) {
423 // Expected calls: 425 // Expected calls:
424 // DownloadFileManager::CancelDownload 426 // DownloadFileManager::CancelDownload
425 // DownloadFile::Cancel 427 // DownloadFile::Cancel
426 // DownloadFileManager::EraseDownload 428 // DownloadFileManager::EraseDownload
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // Same as StartDownload, at first. 511 // Same as StartDownload, at first.
510 DownloadCreateInfo* info = new DownloadCreateInfo; 512 DownloadCreateInfo* info = new DownloadCreateInfo;
511 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 513 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
512 514
513 StartDownload(info, dummy_id); 515 StartDownload(info, dummy_id);
514 516
515 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 517 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
516 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 518 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
517 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 519 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
518 520
519 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 521 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
520 522
521 CleanUp(dummy_id); 523 CleanUp(dummy_id);
522 } 524 }
523 525
524 TEST_F(DownloadFileManagerTest, CompleteDownloadWithError) { 526 TEST_F(DownloadFileManagerTest, CompleteDownloadWithError) {
525 // Same as StartDownload, at first. 527 // Same as StartDownload, at first.
526 DownloadCreateInfo* info = new DownloadCreateInfo; 528 DownloadCreateInfo* info = new DownloadCreateInfo;
527 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 529 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
528 530
529 StartDownload(info, dummy_id); 531 StartDownload(info, dummy_id);
530 532
531 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 533 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
532 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 534 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
533 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 535 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
534 536
535 OnResponseCompleted(dummy_id, 537 OnResponseCompleted(dummy_id,
536 DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED, 538 content::DOWNLOAD_INTERRUPT_REASON_FILE_VIRUS_INFECTED,
537 ""); 539 "");
538 540
539 CleanUp(dummy_id); 541 CleanUp(dummy_id);
540 } 542 }
541 543
542 TEST_F(DownloadFileManagerTest, RenameInProgress) { 544 TEST_F(DownloadFileManagerTest, RenameInProgress) {
543 // Same as StartDownload, at first. 545 // Same as StartDownload, at first.
544 DownloadCreateInfo* info = new DownloadCreateInfo; 546 DownloadCreateInfo* info = new DownloadCreateInfo;
545 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 547 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
546 ScopedTempDir download_dir; 548 ScopedTempDir download_dir;
547 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 549 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
548 550
549 StartDownload(info, dummy_id); 551 StartDownload(info, dummy_id);
550 552
551 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 553 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
552 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 554 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
553 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 555 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
554 RenameFile(dummy_id, foo, foo, net::OK, IN_PROGRESS, OVERWRITE); 556 RenameFile(dummy_id, foo, foo, net::OK, IN_PROGRESS, OVERWRITE);
555 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 557 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
556 558
557 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 559 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
558 560
559 CleanUp(dummy_id); 561 CleanUp(dummy_id);
560 } 562 }
561 563
562 TEST_F(DownloadFileManagerTest, RenameInProgressWithError) { 564 TEST_F(DownloadFileManagerTest, RenameInProgressWithError) {
563 // Same as StartDownload, at first. 565 // Same as StartDownload, at first.
564 DownloadCreateInfo* info = new DownloadCreateInfo; 566 DownloadCreateInfo* info = new DownloadCreateInfo;
565 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 567 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
566 ScopedTempDir download_dir; 568 ScopedTempDir download_dir;
567 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 569 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
(...skipping 15 matching lines...) Expand all
583 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 585 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
584 ScopedTempDir download_dir; 586 ScopedTempDir download_dir;
585 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 587 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
586 588
587 StartDownload(info, dummy_id); 589 StartDownload(info, dummy_id);
588 590
589 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 591 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
590 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 592 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
591 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 593 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
592 594
593 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 595 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
594 596
595 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 597 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
596 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE); 598 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE);
597 599
598 CleanUp(dummy_id); 600 CleanUp(dummy_id);
599 } 601 }
600 602
601 TEST_F(DownloadFileManagerTest, RenameCompletingWithUniquification) { 603 TEST_F(DownloadFileManagerTest, RenameCompletingWithUniquification) {
602 // Same as StartDownload, at first. 604 // Same as StartDownload, at first.
603 DownloadCreateInfo* info = new DownloadCreateInfo; 605 DownloadCreateInfo* info = new DownloadCreateInfo;
604 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 606 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
605 ScopedTempDir download_dir; 607 ScopedTempDir download_dir;
606 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 608 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
607 609
608 StartDownload(info, dummy_id); 610 StartDownload(info, dummy_id);
609 611
610 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 612 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
611 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 613 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
612 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 614 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
613 615
614 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 616 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
615 617
616 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 618 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
617 FilePath unique_foo(foo.InsertBeforeExtension(FILE_PATH_LITERAL(" (1)"))); 619 FilePath unique_foo(foo.InsertBeforeExtension(FILE_PATH_LITERAL(" (1)")));
618 // Create a file at |foo|. Since we are specifying DONT_OVERWRITE, 620 // Create a file at |foo|. Since we are specifying DONT_OVERWRITE,
619 // RenameCompletingDownloadFile() should pick "foo (1).txt" instead of 621 // RenameCompletingDownloadFile() should pick "foo (1).txt" instead of
620 // overwriting this file. 622 // overwriting this file.
621 ASSERT_EQ(0, file_util::WriteFile(foo, "", 0)); 623 ASSERT_EQ(0, file_util::WriteFile(foo, "", 0));
622 RenameFile(dummy_id, foo, unique_foo, net::OK, COMPLETE, DONT_OVERWRITE); 624 RenameFile(dummy_id, foo, unique_foo, net::OK, COMPLETE, DONT_OVERWRITE);
623 625
624 CleanUp(dummy_id); 626 CleanUp(dummy_id);
625 } 627 }
626 628
627 TEST_F(DownloadFileManagerTest, RenameCompletingWithError) { 629 TEST_F(DownloadFileManagerTest, RenameCompletingWithError) {
628 // Same as StartDownload, at first. 630 // Same as StartDownload, at first.
629 DownloadCreateInfo* info = new DownloadCreateInfo; 631 DownloadCreateInfo* info = new DownloadCreateInfo;
630 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 632 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
631 ScopedTempDir download_dir; 633 ScopedTempDir download_dir;
632 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 634 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
633 635
634 StartDownload(info, dummy_id); 636 StartDownload(info, dummy_id);
635 637
636 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 638 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
637 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 639 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
638 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 640 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
639 641
640 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 642 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
641 643
642 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 644 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
643 RenameFile(dummy_id, foo, foo, net::ERR_FILE_PATH_TOO_LONG, 645 RenameFile(dummy_id, foo, foo, net::ERR_FILE_PATH_TOO_LONG,
644 COMPLETE, OVERWRITE); 646 COMPLETE, OVERWRITE);
645 647
646 CleanUp(dummy_id); 648 CleanUp(dummy_id);
647 } 649 }
648 650
649 TEST_F(DownloadFileManagerTest, RenameTwice) { 651 TEST_F(DownloadFileManagerTest, RenameTwice) {
650 // Same as StartDownload, at first. 652 // Same as StartDownload, at first.
651 DownloadCreateInfo* info = new DownloadCreateInfo; 653 DownloadCreateInfo* info = new DownloadCreateInfo;
652 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId); 654 DownloadId dummy_id(download_manager_.get(), kDummyDownloadId);
653 ScopedTempDir download_dir; 655 ScopedTempDir download_dir;
654 ASSERT_TRUE(download_dir.CreateUniqueTempDir()); 656 ASSERT_TRUE(download_dir.CreateUniqueTempDir());
655 657
656 StartDownload(info, dummy_id); 658 StartDownload(info, dummy_id);
657 659
658 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK); 660 UpdateDownload(dummy_id, kTestData1, strlen(kTestData1), net::OK);
659 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK); 661 UpdateDownload(dummy_id, kTestData2, strlen(kTestData2), net::OK);
660 FilePath crfoo(download_dir.path().Append( 662 FilePath crfoo(download_dir.path().Append(
661 FILE_PATH_LITERAL("foo.txt.crdownload"))); 663 FILE_PATH_LITERAL("foo.txt.crdownload")));
662 RenameFile(dummy_id, crfoo, crfoo, net::OK, IN_PROGRESS, OVERWRITE); 664 RenameFile(dummy_id, crfoo, crfoo, net::OK, IN_PROGRESS, OVERWRITE);
663 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 665 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
664 666
665 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 667 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
666 668
667 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 669 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
668 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE); 670 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE);
669 671
670 CleanUp(dummy_id); 672 CleanUp(dummy_id);
671 } 673 }
672 674
673 TEST_F(DownloadFileManagerTest, TwoDownloads) { 675 TEST_F(DownloadFileManagerTest, TwoDownloads) {
674 // Same as StartDownload, at first. 676 // Same as StartDownload, at first.
675 DownloadCreateInfo* info = new DownloadCreateInfo; 677 DownloadCreateInfo* info = new DownloadCreateInfo;
(...skipping 18 matching lines...) Expand all
694 696
695 FilePath crfoo(download_dir.path().Append( 697 FilePath crfoo(download_dir.path().Append(
696 FILE_PATH_LITERAL("foo.txt.crdownload"))); 698 FILE_PATH_LITERAL("foo.txt.crdownload")));
697 RenameFile(dummy_id, crfoo, crfoo, net::OK, IN_PROGRESS, OVERWRITE); 699 RenameFile(dummy_id, crfoo, crfoo, net::OK, IN_PROGRESS, OVERWRITE);
698 700
699 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK); 701 UpdateDownload(dummy_id, kTestData3, strlen(kTestData3), net::OK);
700 702
701 UpdateDownload(dummy_id2, kTestData5, strlen(kTestData5), net::OK); 703 UpdateDownload(dummy_id2, kTestData5, strlen(kTestData5), net::OK);
702 UpdateDownload(dummy_id2, kTestData6, strlen(kTestData6), net::OK); 704 UpdateDownload(dummy_id2, kTestData6, strlen(kTestData6), net::OK);
703 705
704 OnResponseCompleted(dummy_id2, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 706 OnResponseCompleted(dummy_id2, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
705 707
706 OnResponseCompleted(dummy_id, DOWNLOAD_INTERRUPT_REASON_NONE, ""); 708 OnResponseCompleted(dummy_id, content::DOWNLOAD_INTERRUPT_REASON_NONE, "");
707 709
708 FilePath bar(download_dir.path().Append(FILE_PATH_LITERAL("bar.txt"))); 710 FilePath bar(download_dir.path().Append(FILE_PATH_LITERAL("bar.txt")));
709 RenameFile(dummy_id2, bar, bar, net::OK, COMPLETE, OVERWRITE); 711 RenameFile(dummy_id2, bar, bar, net::OK, COMPLETE, OVERWRITE);
710 712
711 CleanUp(dummy_id2); 713 CleanUp(dummy_id2);
712 714
713 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt"))); 715 FilePath foo(download_dir.path().Append(FILE_PATH_LITERAL("foo.txt")));
714 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE); 716 RenameFile(dummy_id, foo, foo, net::OK, COMPLETE, OVERWRITE);
715 717
716 CleanUp(dummy_id); 718 CleanUp(dummy_id);
717 } 719 }
718 720
719 721
720 // TODO(ahendrickson) -- A test for updating progress. 722 // TODO(ahendrickson) -- A test for updating progress.
721 // Expected call sequence: 723 // Expected call sequence:
722 // UpdateInProgressDownloads 724 // UpdateInProgressDownloads
723 // DownloadFile::GetDownloadFile 725 // DownloadFile::GetDownloadFile
724 // Process one message in the message loop 726 // Process one message in the message loop
725 // DownloadManager::UpdateDownload 727 // DownloadManager::UpdateDownload
726 728
727 // TODO(ahendrickson) -- A test for download manager shutdown. 729 // TODO(ahendrickson) -- A test for download manager shutdown.
728 // Expected call sequence: 730 // Expected call sequence:
729 // OnDownloadManagerShutdown 731 // OnDownloadManagerShutdown
730 // DownloadFile::GetDownloadManager 732 // DownloadFile::GetDownloadManager
731 // DownloadFile::CancelDownloadRequest 733 // DownloadFile::CancelDownloadRequest
732 // DownloadFile::~DownloadFile 734 // DownloadFile::~DownloadFile
OLDNEW
« no previous file with comments | « content/browser/download/download_file_manager.cc ('k') | content/browser/download/download_interrupt_reasons_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698