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

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

Issue 7796014: Make cancel remove cancelled download from active queues at time of cancel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix to try to get past main waterfall failure. Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <set> 6 #include <set>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 ui::DataUnits amount_units = ui::GetByteDisplayUnits(kTestDataLen); 527 ui::DataUnits amount_units = ui::GetByteDisplayUnits(kTestDataLen);
528 string16 simple_size = 528 string16 simple_size =
529 ui::FormatBytesWithUnits(error_size, amount_units, false); 529 ui::FormatBytesWithUnits(error_size, amount_units, false);
530 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality( 530 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality(
531 ui::FormatBytesWithUnits(kTestDataLen, amount_units, true)); 531 ui::FormatBytesWithUnits(kTestDataLen, amount_units, true));
532 EXPECT_EQ(download_item_model->GetStatusText(), 532 EXPECT_EQ(download_item_model->GetStatusText(),
533 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED, 533 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED,
534 simple_size, 534 simple_size,
535 simple_total)); 535 simple_total));
536 536
537 download->Cancel(true); 537 download->Cancel();
538 538
539 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); 539 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
540 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED)); 540 EXPECT_TRUE(observer->hit_state(DownloadItem::INTERRUPTED));
541 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); 541 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE));
542 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED)); 542 EXPECT_FALSE(observer->hit_state(DownloadItem::CANCELLED));
543 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 543 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
544 EXPECT_TRUE(observer->was_updated()); 544 EXPECT_TRUE(observer->was_updated());
545 EXPECT_FALSE(observer->was_opened()); 545 EXPECT_FALSE(observer->was_opened());
546 EXPECT_FALSE(download->file_externally_removed()); 546 EXPECT_FALSE(download->file_externally_removed());
547 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state()); 547 EXPECT_EQ(DownloadItem::INTERRUPTED, download->state());
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 string16 simple_size = 623 string16 simple_size =
624 ui::FormatBytesWithUnits(error_size, amount_units, false); 624 ui::FormatBytesWithUnits(error_size, amount_units, false);
625 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality( 625 string16 simple_total = base::i18n::GetDisplayStringInLTRDirectionality(
626 ui::FormatBytesWithUnits(error_size, amount_units, true)); 626 ui::FormatBytesWithUnits(error_size, amount_units, true));
627 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED, 627 EXPECT_EQ(l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_INTERRUPTED,
628 simple_size, 628 simple_size,
629 simple_total), 629 simple_total),
630 download_item_model->GetStatusText()); 630 download_item_model->GetStatusText());
631 631
632 // Clean up. 632 // Clean up.
633 download->Cancel(true); 633 download->Cancel();
634 message_loop_.RunAllPending(); 634 message_loop_.RunAllPending();
635 } 635 }
636 636
637 TEST_F(DownloadManagerTest, DownloadCancelTest) { 637 TEST_F(DownloadManagerTest, DownloadCancelTest) {
638 using ::testing::_; 638 using ::testing::_;
639 using ::testing::CreateFunctor; 639 using ::testing::CreateFunctor;
640 using ::testing::Invoke; 640 using ::testing::Invoke;
641 using ::testing::Return; 641 using ::testing::Return;
642 642
643 // Normally, the download system takes ownership of info, and is 643 // Normally, the download system takes ownership of info, and is
(...skipping 25 matching lines...) Expand all
669 669
670 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); 670 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state());
671 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); 671 scoped_ptr<ItemObserver> observer(new ItemObserver(download));
672 672
673 ContinueDownloadWithPath(download, new_path); 673 ContinueDownloadWithPath(download, new_path);
674 message_loop_.RunAllPending(); 674 message_loop_.RunAllPending();
675 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); 675 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL);
676 676
677 download_file->AppendDataToFile(kTestData, kTestDataLen); 677 download_file->AppendDataToFile(kTestData, kTestDataLen);
678 678
679 download->Cancel(false); 679 download->Cancel();
680 message_loop_.RunAllPending(); 680 message_loop_.RunAllPending();
681 681
682 EXPECT_TRUE(GetActiveDownloadItem(0) != NULL); 682 EXPECT_TRUE(GetActiveDownloadItem(0) == NULL);
683 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS)); 683 EXPECT_TRUE(observer->hit_state(DownloadItem::IN_PROGRESS));
684 EXPECT_TRUE(observer->hit_state(DownloadItem::CANCELLED)); 684 EXPECT_TRUE(observer->hit_state(DownloadItem::CANCELLED));
685 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED)); 685 EXPECT_FALSE(observer->hit_state(DownloadItem::INTERRUPTED));
686 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE)); 686 EXPECT_FALSE(observer->hit_state(DownloadItem::COMPLETE));
687 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 687 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
688 EXPECT_TRUE(observer->was_updated()); 688 EXPECT_TRUE(observer->was_updated());
689 EXPECT_FALSE(observer->was_opened()); 689 EXPECT_FALSE(observer->was_opened());
690 EXPECT_FALSE(download->file_externally_removed()); 690 EXPECT_FALSE(download->file_externally_removed());
691 EXPECT_EQ(DownloadItem::CANCELLED, download->state()); 691 EXPECT_EQ(DownloadItem::CANCELLED, download->state());
692 EXPECT_EQ(download_item_model->GetStatusText(), 692 EXPECT_EQ(download_item_model->GetStatusText(),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING)); 869 EXPECT_FALSE(observer->hit_state(DownloadItem::REMOVING));
870 EXPECT_TRUE(observer->was_updated()); 870 EXPECT_TRUE(observer->was_updated());
871 EXPECT_FALSE(observer->was_opened()); 871 EXPECT_FALSE(observer->was_opened());
872 EXPECT_TRUE(download->file_externally_removed()); 872 EXPECT_TRUE(download->file_externally_removed());
873 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); 873 EXPECT_EQ(DownloadItem::COMPLETE, download->state());
874 EXPECT_EQ(download_item_model->GetStatusText(), 874 EXPECT_EQ(download_item_model->GetStatusText(),
875 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED)); 875 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED));
876 876
877 EXPECT_FALSE(file_util::PathExists(new_path)); 877 EXPECT_FALSE(file_util::PathExists(new_path));
878 } 878 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/ui/cocoa/download/download_item_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698