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

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

Issue 2809953002: Make the download's response headers available in the DownloadItem (Closed)
Patch Set: Created 3 years, 8 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 e16e03803567d3ddec44608d201afa7a68eb8145..5377bcd91a01935827dd7edfd666abed7e1e32d8 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -816,11 +816,13 @@ TEST_F(DownloadItemTest, AutomaticResumption_AttemptLimit) {
// subsequent Start() call shouldn't update the origin state (URL redirect
// chains, Content-Disposition, download URL, etc..)
TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
+ constexpr int kFirstResponseCode = 200;
const char kContentDisposition[] = "attachment; filename=foo";
const char kFirstETag[] = "ABC";
const char kFirstLastModified[] = "Yesterday";
const char kFirstURL[] = "http://www.example.com/download";
const char kMimeType[] = "text/css";
+ create_info()->response_code = kFirstResponseCode;
create_info()->content_disposition = kContentDisposition;
create_info()->etag = kFirstETag;
create_info()->last_modified = kFirstLastModified;
@@ -830,6 +832,7 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
DownloadItemImpl* item = CreateDownloadItem();
MockDownloadFile* download_file =
DoIntermediateRename(item, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS);
+ EXPECT_EQ(kFirstResponseCode, item->GetResponseCode());
EXPECT_EQ(kContentDisposition, item->GetContentDisposition());
EXPECT_EQ(kFirstETag, item->GetETag());
EXPECT_EQ(kFirstLastModified, item->GetLastModifiedTime());
@@ -852,11 +855,13 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
// Now change the create info. The changes should not cause the DownloadItem
// to be updated.
+ constexpr int kSecondResponseCode = 418;
const char kSecondContentDisposition[] = "attachment; filename=bar";
const char kSecondETag[] = "123";
const char kSecondLastModified[] = "Today";
const char kSecondURL[] = "http://example.com/another-download";
const char kSecondMimeType[] = "text/html";
+ create_info()->response_code = kSecondResponseCode;
create_info()->content_disposition = kSecondContentDisposition;
create_info()->etag = kSecondETag;
create_info()->last_modified = kSecondLastModified;
@@ -879,6 +884,7 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
DOWNLOAD_INTERRUPT_REASON_NONE);
RunAllPendingInMessageLoops();
+ EXPECT_EQ(kFirstResponseCode, item->GetResponseCode());
EXPECT_EQ(kContentDisposition, item->GetContentDisposition());
EXPECT_EQ(kFirstETag, item->GetETag());
EXPECT_EQ(kFirstLastModified, item->GetLastModifiedTime());
@@ -893,11 +899,13 @@ TEST_F(DownloadItemTest, FailedResumptionDoesntUpdateOriginState) {
// If the download resumption request succeeds, the origin state should be
// updated.
TEST_F(DownloadItemTest, SucceededResumptionUpdatesOriginState) {
+ constexpr int kFirstResponseCode = 200;
const char kContentDisposition[] = "attachment; filename=foo";
const char kFirstETag[] = "ABC";
const char kFirstLastModified[] = "Yesterday";
const char kFirstURL[] = "http://www.example.com/download";
const char kMimeType[] = "text/css";
+ create_info()->response_code = kFirstResponseCode;
create_info()->content_disposition = kContentDisposition;
create_info()->etag = kFirstETag;
create_info()->last_modified = kFirstLastModified;
@@ -917,11 +925,13 @@ TEST_F(DownloadItemTest, SucceededResumptionUpdatesOriginState) {
// Now change the create info. The changes should not cause the DownloadItem
// to be updated.
+ constexpr int kSecondResponseCode = 201;
const char kSecondContentDisposition[] = "attachment; filename=bar";
const char kSecondETag[] = "123";
const char kSecondLastModified[] = "Today";
const char kSecondURL[] = "http://example.com/another-download";
const char kSecondMimeType[] = "text/html";
+ create_info()->response_code = kSecondResponseCode;
create_info()->content_disposition = kSecondContentDisposition;
create_info()->etag = kSecondETag;
create_info()->last_modified = kSecondLastModified;
@@ -932,6 +942,7 @@ TEST_F(DownloadItemTest, SucceededResumptionUpdatesOriginState) {
DownloadTargetCallback target_callback;
download_file = CallDownloadItemStart(item, &target_callback);
+ EXPECT_EQ(kSecondResponseCode, item->GetResponseCode());
EXPECT_EQ(kSecondContentDisposition, item->GetContentDisposition());
EXPECT_EQ(kSecondETag, item->GetETag());
EXPECT_EQ(kSecondLastModified, item->GetLastModifiedTime());

Powered by Google App Engine
This is Rietveld 408576698