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

Side by Side Diff: content/browser/loader/mojo_async_resource_handler_unittest.cc

Issue 2526983002: Refactor ResourceHandler API. (Closed)
Patch Set: Fix merge Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/loader/mojo_async_resource_handler.h" 5 #include "content/browser/loader/mojo_async_resource_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 437 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
438 handler_ = nullptr; 438 handler_ = nullptr;
439 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 439 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
440 } 440 }
441 441
442 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) { 442 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadWithInsufficientResource) {
443 rdh_.set_max_num_in_flight_requests_per_process(0); 443 rdh_.set_max_num_in_flight_requests_per_process(0);
444 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 444 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
445 445
446 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead(-1)); 446 ASSERT_EQ(MockResourceLoader::Status::CANCELED, mock_loader_->OnWillRead(-1));
447 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, mock_loader_->error_code()); 447 // TODO(mmenke): Make this fail with net::ERR_INSUFFICIENT_RESOURCES.
448 EXPECT_EQ(net::ERR_ABORTED, mock_loader_->error_code());
448 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing()); 449 EXPECT_EQ(1, rdh_.num_in_flight_requests_for_testing());
449 handler_ = nullptr; 450 handler_ = nullptr;
450 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing()); 451 EXPECT_EQ(0, rdh_.num_in_flight_requests_for_testing());
451 } 452 }
452 453
453 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) { 454 TEST_F(MojoAsyncResourceHandlerTest, OnWillReadAndOnReadCompleted) {
454 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted()); 455 ASSERT_TRUE(CallOnWillStartAndOnResponseStarted());
455 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead(-1)); 456 ASSERT_EQ(MockResourceLoader::Status::IDLE, mock_loader_->OnWillRead(-1));
456 // The buffer size that the mime sniffer requires implicitly. 457 // The buffer size that the mime sniffer requires implicitly.
457 ASSERT_GE(mock_loader_->io_buffer_size(), 458 ASSERT_GE(mock_loader_->io_buffer_size(),
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 } 1138 }
1138 } 1139 }
1139 EXPECT_EQ("B", body); 1140 EXPECT_EQ("B", body);
1140 } 1141 }
1141 1142
1142 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest, 1143 INSTANTIATE_TEST_CASE_P(MojoAsyncResourceHandlerWithAllocationSizeTest,
1143 MojoAsyncResourceHandlerWithAllocationSizeTest, 1144 MojoAsyncResourceHandlerWithAllocationSizeTest,
1144 ::testing::Values(8, 32 * 2014)); 1145 ::testing::Values(8, 32 * 2014));
1145 } // namespace 1146 } // namespace
1146 } // namespace content 1147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698