| Index: content/child/resource_dispatcher_unittest.cc
|
| diff --git a/content/child/resource_dispatcher_unittest.cc b/content/child/resource_dispatcher_unittest.cc
|
| index 07fbecfbb4d8108ebffd283dc04265f4245e3464..51a5b1aea8563cfa0dfa286ae5b67993bebe0367 100644
|
| --- a/content/child/resource_dispatcher_unittest.cc
|
| +++ b/content/child/resource_dispatcher_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include <utility>
|
| #include <vector>
|
|
|
| +#include "base/feature_list.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/memory/shared_memory.h"
|
| @@ -30,6 +31,7 @@
|
| #include "content/public/child/fixed_received_data.h"
|
| #include "content/public/child/request_peer.h"
|
| #include "content/public/child/resource_dispatcher_delegate.h"
|
| +#include "content/public/common/content_features.cc"
|
| #include "content/public/common/resource_response.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/http/http_response_headers.h"
|
| @@ -275,11 +277,19 @@ class ResourceDispatcherTest : public testing::Test, public IPC::Sender {
|
| memcpy(shared_memory_map_[request_id]->memory(), data.c_str(),
|
| data.length());
|
|
|
| + EXPECT_TRUE(dispatcher_->OnMessageReceived(ResourceMsg_DataReceived(
|
| + request_id, 0, data.length(), data.length(), data.length())));
|
| + }
|
| +
|
| + void NotifyInlinedDataChunkReceived(int request_id,
|
| + const std::vector<char>& data) {
|
| + auto size = data.size();
|
| EXPECT_TRUE(dispatcher_->OnMessageReceived(
|
| - ResourceMsg_DataReceived(request_id, 0, data.length(), data.length())));
|
| + ResourceMsg_InlinedDataChunkReceived(request_id, data, size, size)));
|
| }
|
|
|
| - void NotifyDataDownloaded(int request_id, int decoded_length,
|
| + void NotifyDataDownloaded(int request_id,
|
| + int decoded_length,
|
| int encoded_length) {
|
| EXPECT_TRUE(dispatcher_->OnMessageReceived(ResourceMsg_DataDownloaded(
|
| request_id, decoded_length, encoded_length)));
|
| @@ -369,6 +379,34 @@ TEST_F(ResourceDispatcherTest, RoundTrip) {
|
| EXPECT_EQ(0u, queued_messages());
|
| }
|
|
|
| +// A simple request with an inline data response.
|
| +TEST_F(ResourceDispatcherTest, ResponseWithInlinedData) {
|
| + auto feature_list = base::MakeUnique<base::FeatureList>();
|
| + feature_list->InitializeFromCommandLine(
|
| + features::kOptimizeLoadingIPCForSmallResources.name, std::string());
|
| + base::FeatureList::SetInstance(std::move(feature_list));
|
| + std::unique_ptr<RequestInfo> request_info(CreateRequestInfo(false));
|
| + TestRequestPeer::Context peer_context;
|
| + StartAsync(*request_info.get(), NULL, &peer_context);
|
| +
|
| + int id = ConsumeRequestResource();
|
| + EXPECT_EQ(0u, queued_messages());
|
| +
|
| + NotifyReceivedResponse(id);
|
| + EXPECT_EQ(0u, queued_messages());
|
| + EXPECT_TRUE(peer_context.received_response);
|
| +
|
| + std::vector<char> data(kTestPageContents,
|
| + kTestPageContents + strlen(kTestPageContents));
|
| + NotifyInlinedDataChunkReceived(id, data);
|
| + EXPECT_EQ(0u, queued_messages());
|
| +
|
| + NotifyRequestComplete(id, strlen(kTestPageContents));
|
| + EXPECT_EQ(kTestPageContents, peer_context.data);
|
| + EXPECT_TRUE(peer_context.complete);
|
| + EXPECT_EQ(0u, queued_messages());
|
| +}
|
| +
|
| // Tests that the request IDs are straight when there are two interleaving
|
| // requests.
|
| TEST_F(ResourceDispatcherTest, MultipleRequests) {
|
|
|