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

Unified Diff: content/browser/loader/mojo_async_resource_handler_unittest.cc

Issue 2743723003: Add buffering to MimeSniffingResourceHandler.
Patch Set: Remove unused 'first_call' variable. Created 3 years, 9 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/loader/mojo_async_resource_handler_unittest.cc
diff --git a/content/browser/loader/mojo_async_resource_handler_unittest.cc b/content/browser/loader/mojo_async_resource_handler_unittest.cc
index 46c4cf05e278d5d7288fccdd2830dcfc85d56581..7fe915780fbce0e5667bc8703159ee446640cfe8 100644
--- a/content/browser/loader/mojo_async_resource_handler_unittest.cc
+++ b/content/browser/loader/mojo_async_resource_handler_unittest.cc
@@ -554,41 +554,6 @@ TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) {
}
TEST_F(MojoAsyncResourceHandlerTest,
- OnWillReadAndOnReadCompletedWithInsufficientInitialCapacity) {
- MojoAsyncResourceHandler::SetAllocationSizeForTesting(2);
-
- ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
- ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
- // The buffer size that the mime sniffer requires implicitly.
- ASSERT_GE(mock_loader_->io_buffer_size(),
- kSizeMimeSnifferRequiresForFirstOnWillRead);
-
- const std::string data("abcdefgh");
- ASSERT_EQ(MockResourceLoader::Status::CALLBACK_PENDING,
- mock_loader_->OnReadCompleted(data));
-
- url_loader_client_.RunUntilResponseBodyArrived();
- ASSERT_TRUE(url_loader_client_.response_body().is_valid());
-
- std::string contents;
- while (contents.size() < data.size()) {
- // This is needed for Resume to be called.
- base::RunLoop().RunUntilIdle();
- char buffer[16];
- uint32_t read_size = sizeof(buffer);
- MojoResult result =
- mojo::ReadDataRaw(url_loader_client_.response_body(), buffer,
- &read_size, MOJO_READ_DATA_FLAG_NONE);
- if (result == MOJO_RESULT_SHOULD_WAIT)
- continue;
- ASSERT_EQ(MOJO_RESULT_OK, result);
- contents.append(buffer, read_size);
- }
- EXPECT_EQ(data, contents);
- EXPECT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->status());
-}
-
-TEST_F(MojoAsyncResourceHandlerTest,
IOBufferFromOnWillReadShouldRemainValidEvenIfHandlerIsGone) {
ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
@@ -883,14 +848,6 @@ TEST_F(MojoAsyncResourceHandlerTest,
EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
}
-TEST_F(MojoAsyncResourceHandlerTest,
- EndWriteFailsOnWillReadWithInsufficientInitialCapacity) {
- MojoAsyncResourceHandler::SetAllocationSizeForTesting(2);
- ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
- handler_->set_end_write_expectation(MOJO_RESULT_UNKNOWN);
- ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead());
-}
-
TEST_F(MojoAsyncResourceHandlerTest, EndWriteFailsOnReadCompleted) {
ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
@@ -901,55 +858,6 @@ TEST_F(MojoAsyncResourceHandlerTest, EndWriteFailsOnReadCompleted) {
std::string(mock_loader_->io_buffer_size(), 'w')));
}
-TEST_F(MojoAsyncResourceHandlerTest,
- EndWriteFailsOnReadCompletedWithInsufficientInitialCapacity) {
- MojoAsyncResourceHandler::SetAllocationSizeForTesting(2);
- ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
- ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
-
- handler_->set_end_write_expectation(MOJO_RESULT_SHOULD_WAIT);
- ASSERT_EQ(MockResourceLoader::Status::CANCELED,
- mock_loader_->OnReadCompleted(
- std::string(mock_loader_->io_buffer_size(), 'w')));
-}
-
-TEST_F(MojoAsyncResourceHandlerTest,
- EndWriteFailsOnResumeWithInsufficientInitialCapacity) {
- MojoAsyncResourceHandler::SetAllocationSizeForTesting(8);
- ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
- ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
-
- while (true) {
- MockResourceLoader::Status result = mock_loader_->OnReadCompleted(
- std::string(mock_loader_->io_buffer_size(), 'A'));
- if (result == MockResourceLoader::Status::CALLBACK_PENDING)
- break;
- ASSERT_EQ(MockResourceLoader::Status::IDLE, result);
-
- ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead());
- }
-
- url_loader_client_.RunUntilResponseBodyArrived();
- ASSERT_TRUE(url_loader_client_.response_body().is_valid());
-
- while (true) {
- char buf[16];
- uint32_t read_size = sizeof(buf);
- MojoResult result =
- mojo::ReadDataRaw(url_loader_client_.response_body(), buf, &read_size,
- MOJO_READ_DATA_FLAG_NONE);
- if (result == MOJO_RESULT_SHOULD_WAIT)
- break;
- ASSERT_EQ(MOJO_RESULT_OK, result);
- }
-
- handler_->set_end_write_expectation(MOJO_RESULT_SHOULD_WAIT);
- mock_loader_->WaitUntilIdleOrCanceled();
- EXPECT_FALSE(url_loader_client_.has_received_completion());
- EXPECT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->status());
- EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, mock_loader_->error_code());
-}
-
TEST_F(MojoAsyncResourceHandlerUploadTest, UploadProgressHandling) {
ASSERT_TRUE(CallOnWillStart());
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler.cc ('k') | content/browser/loader/redirect_to_file_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698