Commit c1e3d97f authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

Fix missing url_chain in DriverEntry

This fixes a regression introduced in
https://chromium-review.googlesource.com/c/chromium/src/+/636288

Also adds a unit test for DownloadDriverImpl::CreateDriverEntry.

Change-Id: Ic456b868f5c51cd87cf6534681708f8c252ab9db
Reviewed-on: https://chromium-review.googlesource.com/687055Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505108}
parent c91d4ca6
...@@ -91,6 +91,7 @@ DriverEntry DownloadDriverImpl::CreateDriverEntry( ...@@ -91,6 +91,7 @@ DriverEntry DownloadDriverImpl::CreateDriverEntry(
entry.response_headers->response_code() == net::HTTP_PARTIAL_CONTENT); entry.response_headers->response_code() == net::HTTP_PARTIAL_CONTENT);
entry.can_resume &= entry.response_headers->HasStrongValidators(); entry.can_resume &= entry.response_headers->HasStrongValidators();
} }
entry.url_chain = item->GetUrlChain();
return entry; return entry;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/public/test/fake_download_item.h" #include "content/public/test/fake_download_item.h"
#include "content/public/test/mock_download_manager.h" #include "content/public/test/mock_download_manager.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -189,4 +190,26 @@ TEST_F(DownloadDriverImplTest, TestGetActiveDownloadsCall) { ...@@ -189,4 +190,26 @@ TEST_F(DownloadDriverImplTest, TestGetActiveDownloadsCall) {
EXPECT_NE(guids.end(), guids.find(item1.GetGuid())); EXPECT_NE(guids.end(), guids.find(item1.GetGuid()));
} }
TEST_F(DownloadDriverImplTest, TestCreateDriverEntry) {
using DownloadState = content::DownloadItem::DownloadState;
content::FakeDownloadItem item;
const std::string kGuid("dummy guid");
const std::vector<GURL> kUrls = {GURL("http://www.example.com/foo.html"),
GURL("http://www.example.com/bar.html")};
scoped_refptr<net::HttpResponseHeaders> headers =
new net::HttpResponseHeaders("HTTP/1.1 201\n");
item.SetGuid(kGuid);
item.SetUrlChain(kUrls);
item.SetState(DownloadState::IN_PROGRESS);
item.SetResponseHeaders(headers);
DriverEntry entry = driver_->CreateDriverEntry(&item);
EXPECT_EQ(kGuid, entry.guid);
EXPECT_EQ(kUrls, entry.url_chain);
EXPECT_EQ(DriverEntry::State::IN_PROGRESS, entry.state);
EXPECT_EQ(headers, entry.response_headers);
}
} // namespace download } // namespace download
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment