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

Unified Diff: content/browser/download/download_item_impl_unittest.cc

Issue 10344024: Rewrite download manager unit to be actual unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/download_item_factory.h ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl_unittest.cc
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index ed97630654b4572258b24daf76615bf7c52c91a1..d81d3d1a1e745d732a6ceca9607a1d4df4f6f8ba 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -551,6 +551,47 @@ TEST_F(DownloadItemTest, CallbackAfterRenameToIntermediateName) {
::testing::Mock::VerifyAndClearExpectations(mock_delegate());
}
+TEST_F(DownloadItemTest, Interrupted) {
+ DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
+
+ int64 size = 1022;
+ const std::string hash_state("Live beef");
+ const content::DownloadInterruptReason reason(
+ content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
+
+ // Confirm interrupt sets state properly.
+ item->Interrupted(size, hash_state, reason);
+ EXPECT_EQ(size, item->GetReceivedBytes());
+ EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
+ EXPECT_EQ(hash_state, item->GetHashState());
+ EXPECT_EQ(reason, item->GetLastReason());
+
+ // Cancel should result in no change.
+ item->Cancel(true);
+ EXPECT_EQ(size, item->GetReceivedBytes());
+ EXPECT_EQ(DownloadItem::INTERRUPTED, item->GetState());
+ EXPECT_EQ(hash_state, item->GetHashState());
+ EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED,
+ item->GetLastReason());
+}
+
+TEST_F(DownloadItemTest, Canceled) {
+ DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
+
+ // Confirm cancel sets state properly.
+ EXPECT_CALL(*mock_delegate(), DownloadCancelled(item));
+ item->Cancel(true);
+ EXPECT_EQ(DownloadItem::CANCELLED, item->GetState());
+}
+
+TEST_F(DownloadItemTest, FileRemoved) {
+ DownloadItem* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
+
+ EXPECT_EQ(false, item->GetFileExternallyRemoved());
+ item->OnDownloadedFileRemoved();
+ EXPECT_EQ(true, item->GetFileExternallyRemoved());
+}
+
TEST(MockDownloadItem, Compiles) {
MockDownloadItem mock_item;
}
« no previous file with comments | « content/browser/download/download_item_factory.h ('k') | content/browser/download/download_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698