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

Unified Diff: content/browser/fileapi/blob_url_request_job_unittest.cc

Issue 1337153002: [Blob] BlobReader class & tests, and removal of all redundant reading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed prod/debug flakiness Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/fileapi/blob_url_request_job_unittest.cc
diff --git a/content/browser/fileapi/blob_url_request_job_unittest.cc b/content/browser/fileapi/blob_url_request_job_unittest.cc
index 9debd4dc6715caf70b602336f2a6d713a3734665..96becf0de0935ae062abb6c67546b526fc088cd6 100644
--- a/content/browser/fileapi/blob_url_request_job_unittest.cc
+++ b/content/browser/fileapi/blob_url_request_job_unittest.cc
@@ -115,7 +115,7 @@ class BlobURLRequestJobTest : public testing::Test {
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override {
return new BlobURLRequestJob(request, network_delegate,
- test_->GetSnapshotFromBuilder(),
+ test_->GetHandleFromBuilder(),
test_->file_system_context_.get(),
base::ThreadTaskRunnerHandle::Get().get());
}
@@ -157,6 +157,7 @@ class BlobURLRequestJobTest : public testing::Test {
void TearDown() override {
blob_handle_.reset();
+ request_.reset();
// Clean up for ASAN
base::RunLoop run_loop;
run_loop.RunUntilIdle();
@@ -282,18 +283,19 @@ class BlobURLRequestJobTest : public testing::Test {
*expected_result += std::string(kTestFileSystemFileData2 + 6, 7);
}
- scoped_ptr<BlobDataSnapshot> GetSnapshotFromBuilder() {
+ storage::BlobDataHandle* GetHandleFromBuilder() {
if (!blob_handle_) {
blob_handle_ = blob_context_.AddFinishedBlob(blob_data_.get()).Pass();
}
- return blob_handle_->CreateSnapshot().Pass();
+ return blob_handle_.get();
}
// This only works if all the Blob items have a definite pre-computed length.
// Otherwise, this will fail a CHECK.
int64 GetTotalBlobLength() {
int64 total = 0;
- scoped_ptr<BlobDataSnapshot> data = GetSnapshotFromBuilder();
+ scoped_ptr<BlobDataSnapshot> data =
+ GetHandleFromBuilder()->CreateSnapshot();
const auto& items = data->items();
for (const auto& item : items) {
int64 length = base::checked_cast<int64>(item->length());
@@ -491,6 +493,27 @@ TEST_F(BlobURLRequestJobTest, TestGetRangeRequest2) {
EXPECT_EQ(total, length);
}
+TEST_F(BlobURLRequestJobTest, TestGetRangeRequest3) {
+ SetUpFileSystem();
+ std::string result;
+ BuildComplicatedData(&result);
+ net::HttpRequestHeaders extra_headers;
+ extra_headers.SetHeader(net::HttpRequestHeaders::kRange,
+ net::HttpByteRange::Bounded(0, 2).GetHeaderValue());
+ expected_status_code_ = 206;
+ expected_response_ = result.substr(0, 3);
+ TestRequest("GET", extra_headers);
+
+ EXPECT_EQ(3, request_->response_headers()->GetContentLength());
+
+ int64 first = 0, last = 0, length = 0;
+ EXPECT_TRUE(
+ request_->response_headers()->GetContentRange(&first, &last, &length));
+ EXPECT_EQ(0, first);
+ EXPECT_EQ(2, last);
+ EXPECT_EQ(GetTotalBlobLength(), length);
+}
+
TEST_F(BlobURLRequestJobTest, TestExtraHeaders) {
blob_data_->set_content_type(kTestContentType);
blob_data_->set_content_disposition(kTestContentDisposition);
« no previous file with comments | « content/browser/fileapi/blob_reader_unittest.cc ('k') | content/browser/loader/upload_data_stream_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698