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

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: Modified creation comment. 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
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 abe5c57165d581a26a99a62285b77c64b4f8ed57..448cdf0f549923347b6460269499c76355ed7b5a 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -550,6 +550,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 | « no previous file | content/browser/download/download_manager_impl.h » ('j') | content/browser/download/download_manager_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698