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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 years, 5 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
« no previous file with comments | « net/spdy/spdy_session_pool_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 17 matching lines...) Expand all
28 #include "net/socket/next_proto.h" 28 #include "net/socket/next_proto.h"
29 #include "net/socket/socket_test_util.h" 29 #include "net/socket/socket_test_util.h"
30 #include "net/spdy/spdy_http_utils.h" 30 #include "net/spdy/spdy_http_utils.h"
31 #include "net/spdy/spdy_session_pool.h" 31 #include "net/spdy/spdy_session_pool.h"
32 #include "net/spdy/spdy_session_test_util.h" 32 #include "net/spdy/spdy_session_test_util.h"
33 #include "net/spdy/spdy_stream.h" 33 #include "net/spdy/spdy_stream.h"
34 #include "net/spdy/spdy_stream_test_util.h" 34 #include "net/spdy/spdy_stream_test_util.h"
35 #include "net/spdy/spdy_test_util_common.h" 35 #include "net/spdy/spdy_test_util_common.h"
36 #include "net/spdy/spdy_test_utils.h" 36 #include "net/spdy/spdy_test_utils.h"
37 #include "net/test/cert_test_util.h" 37 #include "net/test/cert_test_util.h"
38 #include "net/test/gtest_util.h"
38 #include "net/test/test_data_directory.h" 39 #include "net/test/test_data_directory.h"
39 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
40 #include "testing/platform_test.h" 41 #include "testing/platform_test.h"
41 42
43 using net::test::IsError;
44 using net::test::IsOk;
45
42 namespace net { 46 namespace net {
43 47
44 namespace { 48 namespace {
45 49
46 enum TestCase { 50 enum TestCase {
47 // Test using the SPDY/3.1 protocol. 51 // Test using the SPDY/3.1 protocol.
48 kTestCaseSPDY31, 52 kTestCaseSPDY31,
49 53
50 // Test using the HTTP/2 protocol, without specifying a stream 54 // Test using the HTTP/2 protocol, without specifying a stream
51 // dependency based on the RequestPriority. 55 // dependency based on the RequestPriority.
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // |callback2| is never called. 316 // |callback2| is never called.
313 TestCompletionCallback callback2; 317 TestCompletionCallback callback2;
314 ASSERT_EQ(ERR_IO_PENDING, request2->StartRequest( 318 ASSERT_EQ(ERR_IO_PENDING, request2->StartRequest(
315 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 319 SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
316 MEDIUM, BoundNetLog(), callback2.callback())); 320 MEDIUM, BoundNetLog(), callback2.callback()));
317 321
318 callback1.SetRequestToDestroy(std::move(request2)); 322 callback1.SetRequestToDestroy(std::move(request2));
319 323
320 session_->CloseSessionOnError(ERR_ABORTED, "Aborting session"); 324 session_->CloseSessionOnError(ERR_ABORTED, "Aborting session");
321 325
322 EXPECT_EQ(ERR_ABORTED, callback1.WaitForResult()); 326 EXPECT_THAT(callback1.WaitForResult(), IsError(ERR_ABORTED));
323 } 327 }
324 328
325 // A session receiving a GOAWAY frame with no active streams should close. 329 // A session receiving a GOAWAY frame with no active streams should close.
326 TEST_P(SpdySessionTest, GoAwayWithNoActiveStreams) { 330 TEST_P(SpdySessionTest, GoAwayWithNoActiveStreams) {
327 session_deps_.host_resolver->set_synchronous_mode(true); 331 session_deps_.host_resolver->set_synchronous_mode(true);
328 332
329 std::unique_ptr<SpdySerializedFrame> goaway( 333 std::unique_ptr<SpdySerializedFrame> goaway(
330 spdy_util_.ConstructSpdyGoAway(1)); 334 spdy_util_.ConstructSpdyGoAway(1));
331 MockRead reads[] = { 335 MockRead reads[] = {
332 CreateMockRead(*goaway, 0), 336 CreateMockRead(*goaway, 0),
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 717
714 std::unique_ptr<SpdyHeaderBlock> headers( 718 std::unique_ptr<SpdyHeaderBlock> headers(
715 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl))); 719 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)));
716 spdy_stream->SendRequestHeaders(std::move(headers), NO_MORE_DATA_TO_SEND); 720 spdy_stream->SendRequestHeaders(std::move(headers), NO_MORE_DATA_TO_SEND);
717 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders()); 721 EXPECT_TRUE(spdy_stream->HasUrlFromHeaders());
718 722
719 base::RunLoop().RunUntilIdle(); 723 base::RunLoop().RunUntilIdle();
720 724
721 // Stream and session closed gracefully. 725 // Stream and session closed gracefully.
722 EXPECT_TRUE(delegate.StreamIsClosed()); 726 EXPECT_TRUE(delegate.StreamIsClosed());
723 EXPECT_EQ(OK, delegate.WaitForClose()); 727 EXPECT_THAT(delegate.WaitForClose(), IsOk());
724 EXPECT_EQ(kUploadData, delegate.TakeReceivedData()); 728 EXPECT_EQ(kUploadData, delegate.TakeReceivedData());
725 EXPECT_FALSE(session_); 729 EXPECT_FALSE(session_);
726 } 730 }
727 731
728 // Try to create a stream after receiving a GOAWAY frame. It should 732 // Try to create a stream after receiving a GOAWAY frame. It should
729 // fail. 733 // fail.
730 TEST_P(SpdySessionTest, CreateStreamAfterGoAway) { 734 TEST_P(SpdySessionTest, CreateStreamAfterGoAway) {
731 session_deps_.host_resolver->set_synchronous_mode(true); 735 session_deps_.host_resolver->set_synchronous_mode(true);
732 736
733 std::unique_ptr<SpdySerializedFrame> goaway( 737 std::unique_ptr<SpdySerializedFrame> goaway(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 data.Resume(); 775 data.Resume();
772 base::RunLoop().RunUntilIdle(); 776 base::RunLoop().RunUntilIdle();
773 777
774 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 778 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
775 EXPECT_TRUE(session_->IsStreamActive(1)); 779 EXPECT_TRUE(session_->IsStreamActive(1));
776 780
777 SpdyStreamRequest stream_request; 781 SpdyStreamRequest stream_request;
778 int rv = stream_request.StartRequest(SPDY_REQUEST_RESPONSE_STREAM, session_, 782 int rv = stream_request.StartRequest(SPDY_REQUEST_RESPONSE_STREAM, session_,
779 test_url_, MEDIUM, BoundNetLog(), 783 test_url_, MEDIUM, BoundNetLog(),
780 CompletionCallback()); 784 CompletionCallback());
781 EXPECT_EQ(ERR_FAILED, rv); 785 EXPECT_THAT(rv, IsError(ERR_FAILED));
782 786
783 EXPECT_TRUE(session_); 787 EXPECT_TRUE(session_);
784 data.Resume(); 788 data.Resume();
785 base::RunLoop().RunUntilIdle(); 789 base::RunLoop().RunUntilIdle();
786 EXPECT_FALSE(session_); 790 EXPECT_FALSE(session_);
787 } 791 }
788 792
789 // Receiving a SYN_STREAM frame after a GOAWAY frame should result in 793 // Receiving a SYN_STREAM frame after a GOAWAY frame should result in
790 // the stream being refused. 794 // the stream being refused.
791 TEST_P(SpdySessionTest, SynStreamAfterGoAway) { 795 TEST_P(SpdySessionTest, SynStreamAfterGoAway) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 session_->CheckPingStatus(before_ping_time); 953 session_->CheckPingStatus(before_ping_time);
950 954
951 EXPECT_EQ(0, session_->pings_in_flight()); 955 EXPECT_EQ(0, session_->pings_in_flight());
952 EXPECT_GE(session_->next_ping_id(), 1U); 956 EXPECT_GE(session_->next_ping_id(), 1U);
953 EXPECT_FALSE(session_->check_ping_status_pending()); 957 EXPECT_FALSE(session_->check_ping_status_pending());
954 EXPECT_GE(session_->last_activity_time(), before_ping_time); 958 EXPECT_GE(session_->last_activity_time(), before_ping_time);
955 959
956 data.Resume(); 960 data.Resume();
957 base::RunLoop().RunUntilIdle(); 961 base::RunLoop().RunUntilIdle();
958 962
959 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); 963 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
960 964
961 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 965 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
962 EXPECT_FALSE(session_); 966 EXPECT_FALSE(session_);
963 } 967 }
964 968
965 TEST_P(SpdySessionTest, ServerPing) { 969 TEST_P(SpdySessionTest, ServerPing) {
966 session_deps_.host_resolver->set_synchronous_mode(true); 970 session_deps_.host_resolver->set_synchronous_mode(true);
967 971
968 std::unique_ptr<SpdySerializedFrame> read_ping( 972 std::unique_ptr<SpdySerializedFrame> read_ping(
969 spdy_util_.ConstructSpdyPing(2, false)); 973 spdy_util_.ConstructSpdyPing(2, false));
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl))), 1147 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl))),
1144 NO_MORE_DATA_TO_SEND); 1148 NO_MORE_DATA_TO_SEND);
1145 base::RunLoop().RunUntilIdle(); 1149 base::RunLoop().RunUntilIdle();
1146 1150
1147 // Active streams remain active. 1151 // Active streams remain active.
1148 EXPECT_EQ(kLastStreamId, stream2->stream_id()); 1152 EXPECT_EQ(kLastStreamId, stream2->stream_id());
1149 EXPECT_EQ(2u, session_->num_active_streams()); 1153 EXPECT_EQ(2u, session_->num_active_streams());
1150 1154
1151 // Session is going away. Created and stalled streams were aborted. 1155 // Session is going away. Created and stalled streams were aborted.
1152 EXPECT_EQ(SpdySession::STATE_GOING_AWAY, session_->availability_state_); 1156 EXPECT_EQ(SpdySession::STATE_GOING_AWAY, session_->availability_state_);
1153 EXPECT_EQ(ERR_ABORTED, delegate3.WaitForClose()); 1157 EXPECT_THAT(delegate3.WaitForClose(), IsError(ERR_ABORTED));
1154 EXPECT_EQ(ERR_ABORTED, callback4.WaitForResult()); 1158 EXPECT_THAT(callback4.WaitForResult(), IsError(ERR_ABORTED));
1155 EXPECT_EQ(0u, session_->num_created_streams()); 1159 EXPECT_EQ(0u, session_->num_created_streams());
1156 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM)); 1160 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM));
1157 1161
1158 // Read responses on remaining active streams. 1162 // Read responses on remaining active streams.
1159 data.Resume(); 1163 data.Resume();
1160 base::RunLoop().RunUntilIdle(); 1164 base::RunLoop().RunUntilIdle();
1161 EXPECT_EQ(OK, delegate1.WaitForClose()); 1165 EXPECT_THAT(delegate1.WaitForClose(), IsOk());
1162 EXPECT_EQ(kUploadData, delegate1.TakeReceivedData()); 1166 EXPECT_EQ(kUploadData, delegate1.TakeReceivedData());
1163 EXPECT_EQ(OK, delegate2.WaitForClose()); 1167 EXPECT_THAT(delegate2.WaitForClose(), IsOk());
1164 EXPECT_EQ(kUploadData, delegate2.TakeReceivedData()); 1168 EXPECT_EQ(kUploadData, delegate2.TakeReceivedData());
1165 1169
1166 // Session was destroyed. 1170 // Session was destroyed.
1167 EXPECT_FALSE(session_); 1171 EXPECT_FALSE(session_);
1168 } 1172 }
1169 1173
1170 // Regression test for https://crbug.com/481009. 1174 // Regression test for https://crbug.com/481009.
1171 TEST_P(SpdySessionTest, MaxConcurrentStreamsZero) { 1175 TEST_P(SpdySessionTest, MaxConcurrentStreamsZero) {
1172 session_deps_.host_resolver->set_synchronous_mode(true); 1176 session_deps_.host_resolver->set_synchronous_mode(true);
1173 1177
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 // Receive SETTINGS frame that sets max_concurrent_streams to zero. 1238 // Receive SETTINGS frame that sets max_concurrent_streams to zero.
1235 base::RunLoop().RunUntilIdle(); 1239 base::RunLoop().RunUntilIdle();
1236 EXPECT_EQ(0u, session_->max_concurrent_streams_); 1240 EXPECT_EQ(0u, session_->max_concurrent_streams_);
1237 1241
1238 // Start request. 1242 // Start request.
1239 SpdyStreamRequest request; 1243 SpdyStreamRequest request;
1240 TestCompletionCallback callback; 1244 TestCompletionCallback callback;
1241 int rv = 1245 int rv =
1242 request.StartRequest(SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_, 1246 request.StartRequest(SPDY_REQUEST_RESPONSE_STREAM, session_, test_url_,
1243 MEDIUM, BoundNetLog(), callback.callback()); 1247 MEDIUM, BoundNetLog(), callback.callback());
1244 EXPECT_EQ(ERR_IO_PENDING, rv); 1248 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
1245 1249
1246 // Stream is stalled. 1250 // Stream is stalled.
1247 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(MEDIUM)); 1251 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(MEDIUM));
1248 EXPECT_EQ(0u, session_->num_created_streams()); 1252 EXPECT_EQ(0u, session_->num_created_streams());
1249 1253
1250 // Receive SETTINGS frame that sets max_concurrent_streams to one. 1254 // Receive SETTINGS frame that sets max_concurrent_streams to one.
1251 data.Resume(); 1255 data.Resume();
1252 base::RunLoop().RunUntilIdle(); 1256 base::RunLoop().RunUntilIdle();
1253 EXPECT_EQ(1u, session_->max_concurrent_streams_); 1257 EXPECT_EQ(1u, session_->max_concurrent_streams_);
1254 1258
1255 // Stream is created. 1259 // Stream is created.
1256 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM)); 1260 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM));
1257 EXPECT_EQ(1u, session_->num_created_streams()); 1261 EXPECT_EQ(1u, session_->num_created_streams());
1258 1262
1259 EXPECT_EQ(OK, callback.WaitForResult()); 1263 EXPECT_THAT(callback.WaitForResult(), IsOk());
1260 1264
1261 // Send request. 1265 // Send request.
1262 base::WeakPtr<SpdyStream> stream = request.ReleaseStream(); 1266 base::WeakPtr<SpdyStream> stream = request.ReleaseStream();
1263 test::StreamDelegateDoNothing delegate(stream); 1267 test::StreamDelegateDoNothing delegate(stream);
1264 stream->SetDelegate(&delegate); 1268 stream->SetDelegate(&delegate);
1265 std::unique_ptr<SpdyHeaderBlock> headers( 1269 std::unique_ptr<SpdyHeaderBlock> headers(
1266 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl))); 1270 new SpdyHeaderBlock(spdy_util_.ConstructGetHeaderBlock(kDefaultUrl)));
1267 stream->SendRequestHeaders(std::move(headers), NO_MORE_DATA_TO_SEND); 1271 stream->SendRequestHeaders(std::move(headers), NO_MORE_DATA_TO_SEND);
1268 EXPECT_TRUE(stream->HasUrlFromHeaders()); 1272 EXPECT_TRUE(stream->HasUrlFromHeaders());
1269 1273
1270 EXPECT_EQ(OK, delegate.WaitForClose()); 1274 EXPECT_THAT(delegate.WaitForClose(), IsOk());
1271 EXPECT_EQ("hello!", delegate.TakeReceivedData()); 1275 EXPECT_EQ("hello!", delegate.TakeReceivedData());
1272 1276
1273 // Session is destroyed. 1277 // Session is destroyed.
1274 EXPECT_FALSE(session_); 1278 EXPECT_FALSE(session_);
1275 } 1279 }
1276 1280
1277 // Verifies that an unstalled pending stream creation racing with a new stream 1281 // Verifies that an unstalled pending stream creation racing with a new stream
1278 // creation doesn't violate the maximum stream concurrency. Regression test for 1282 // creation doesn't violate the maximum stream concurrency. Regression test for
1279 // crbug.com/373858. 1283 // crbug.com/373858.
1280 TEST_P(SpdySessionTest, UnstallRacesWithStreamCreation) { 1284 TEST_P(SpdySessionTest, UnstallRacesWithStreamCreation) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 EXPECT_EQ(1u, session_->num_created_streams()); 1330 EXPECT_EQ(1u, session_->num_created_streams());
1327 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(MEDIUM)); 1331 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(MEDIUM));
1328 1332
1329 // Cancel the third stream and run the message loop. Verify that the second 1333 // Cancel the third stream and run the message loop. Verify that the second
1330 // stream creation now completes. 1334 // stream creation now completes.
1331 stream3->Cancel(); 1335 stream3->Cancel();
1332 base::RunLoop().RunUntilIdle(); 1336 base::RunLoop().RunUntilIdle();
1333 1337
1334 EXPECT_EQ(1u, session_->num_created_streams()); 1338 EXPECT_EQ(1u, session_->num_created_streams());
1335 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM)); 1339 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(MEDIUM));
1336 EXPECT_EQ(OK, callback2.WaitForResult()); 1340 EXPECT_THAT(callback2.WaitForResult(), IsOk());
1337 } 1341 }
1338 1342
1339 TEST_P(SpdySessionTest, DeleteExpiredPushStreams) { 1343 TEST_P(SpdySessionTest, DeleteExpiredPushStreams) {
1340 session_deps_.host_resolver->set_synchronous_mode(true); 1344 session_deps_.host_resolver->set_synchronous_mode(true);
1341 session_deps_.time_func = TheNearFuture; 1345 session_deps_.time_func = TheNearFuture;
1342 1346
1343 std::unique_ptr<SpdySerializedFrame> req( 1347 std::unique_ptr<SpdySerializedFrame> req(
1344 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); 1348 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true));
1345 std::unique_ptr<SpdySerializedFrame> rst( 1349 std::unique_ptr<SpdySerializedFrame> rst(
1346 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM)); 1350 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_REFUSED_STREAM));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 1517
1514 StreamReleaserCallback stream_releaser; 1518 StreamReleaserCallback stream_releaser;
1515 SpdyStreamRequest request; 1519 SpdyStreamRequest request;
1516 ASSERT_EQ(ERR_IO_PENDING, 1520 ASSERT_EQ(ERR_IO_PENDING,
1517 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1521 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1518 MEDIUM, BoundNetLog(), 1522 MEDIUM, BoundNetLog(),
1519 stream_releaser.MakeCallback(&request))); 1523 stream_releaser.MakeCallback(&request)));
1520 1524
1521 base::RunLoop().RunUntilIdle(); 1525 base::RunLoop().RunUntilIdle();
1522 1526
1523 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1527 EXPECT_THAT(stream_releaser.WaitForResult(), IsOk());
1524 1528
1525 data.Resume(); 1529 data.Resume();
1526 base::RunLoop().RunUntilIdle(); 1530 base::RunLoop().RunUntilIdle();
1527 EXPECT_FALSE(session_); 1531 EXPECT_FALSE(session_);
1528 1532
1529 EXPECT_TRUE(data.AllWriteDataConsumed()); 1533 EXPECT_TRUE(data.AllWriteDataConsumed());
1530 EXPECT_TRUE(data.AllReadDataConsumed()); 1534 EXPECT_TRUE(data.AllReadDataConsumed());
1531 } 1535 }
1532 1536
1533 // Start with a persisted value for max concurrent streams. Receive a 1537 // Start with a persisted value for max concurrent streams. Receive a
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 StreamReleaserCallback stream_releaser; 1599 StreamReleaserCallback stream_releaser;
1596 1600
1597 SpdyStreamRequest request; 1601 SpdyStreamRequest request;
1598 ASSERT_EQ(ERR_IO_PENDING, 1602 ASSERT_EQ(ERR_IO_PENDING,
1599 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_, 1603 request.StartRequest(SPDY_BIDIRECTIONAL_STREAM, session_, test_url_,
1600 MEDIUM, BoundNetLog(), 1604 MEDIUM, BoundNetLog(),
1601 stream_releaser.MakeCallback(&request))); 1605 stream_releaser.MakeCallback(&request)));
1602 1606
1603 base::RunLoop().RunUntilIdle(); 1607 base::RunLoop().RunUntilIdle();
1604 1608
1605 EXPECT_EQ(OK, stream_releaser.WaitForResult()); 1609 EXPECT_THAT(stream_releaser.WaitForResult(), IsOk());
1606 1610
1607 // Make sure that persisted data is cleared. 1611 // Make sure that persisted data is cleared.
1608 EXPECT_TRUE(spdy_session_pool_->http_server_properties() 1612 EXPECT_TRUE(spdy_session_pool_->http_server_properties()
1609 ->GetSpdySettings(test_server_) 1613 ->GetSpdySettings(test_server_)
1610 .empty()); 1614 .empty());
1611 1615
1612 // Make sure session's max_concurrent_streams is correct. 1616 // Make sure session's max_concurrent_streams is correct.
1613 EXPECT_EQ(kInitialMaxConcurrentStreams + 1, 1617 EXPECT_EQ(kInitialMaxConcurrentStreams + 1,
1614 session_->max_concurrent_streams_); 1618 session_->max_concurrent_streams_);
1615 1619
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 ASSERT_TRUE(entry.GetStringValue("debug_data", &debug_data)); 1841 ASSERT_TRUE(entry.GetStringValue("debug_data", &debug_data));
1838 EXPECT_EQ("foo", debug_data); 1842 EXPECT_EQ("foo", debug_data);
1839 } 1843 }
1840 1844
1841 // Check that we logged SPDY_SESSION_CLOSE correctly. 1845 // Check that we logged SPDY_SESSION_CLOSE correctly.
1842 int pos = ExpectLogContainsSomewhere( 1846 int pos = ExpectLogContainsSomewhere(
1843 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); 1847 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE);
1844 TestNetLogEntry entry = entries[pos]; 1848 TestNetLogEntry entry = entries[pos];
1845 int error_code = 0; 1849 int error_code = 0;
1846 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1850 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1847 EXPECT_EQ(OK, error_code); 1851 EXPECT_THAT(error_code, IsOk());
1848 } 1852 }
1849 1853
1850 TEST_P(SpdySessionTest, NetLogOnSessionEOF) { 1854 TEST_P(SpdySessionTest, NetLogOnSessionEOF) {
1851 session_deps_.host_resolver->set_synchronous_mode(true); 1855 session_deps_.host_resolver->set_synchronous_mode(true);
1852 1856
1853 MockRead reads[] = { 1857 MockRead reads[] = {
1854 MockRead(SYNCHRONOUS, 0, 0) // EOF 1858 MockRead(SYNCHRONOUS, 0, 0) // EOF
1855 }; 1859 };
1856 1860
1857 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0); 1861 StaticSocketDataProvider data(reads, arraysize(reads), nullptr, 0);
(...skipping 15 matching lines...) Expand all
1873 EXPECT_LT(0u, entries.size()); 1877 EXPECT_LT(0u, entries.size());
1874 1878
1875 // Check that we logged SPDY_SESSION_CLOSE correctly. 1879 // Check that we logged SPDY_SESSION_CLOSE correctly.
1876 int pos = ExpectLogContainsSomewhere( 1880 int pos = ExpectLogContainsSomewhere(
1877 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE); 1881 entries, 0, NetLog::TYPE_HTTP2_SESSION_CLOSE, NetLog::PHASE_NONE);
1878 1882
1879 if (pos < static_cast<int>(entries.size())) { 1883 if (pos < static_cast<int>(entries.size())) {
1880 TestNetLogEntry entry = entries[pos]; 1884 TestNetLogEntry entry = entries[pos];
1881 int error_code = 0; 1885 int error_code = 0;
1882 ASSERT_TRUE(entry.GetNetErrorCode(&error_code)); 1886 ASSERT_TRUE(entry.GetNetErrorCode(&error_code));
1883 EXPECT_EQ(ERR_CONNECTION_CLOSED, error_code); 1887 EXPECT_THAT(error_code, IsError(ERR_CONNECTION_CLOSED));
1884 } else { 1888 } else {
1885 ADD_FAILURE(); 1889 ADD_FAILURE();
1886 } 1890 }
1887 } 1891 }
1888 1892
1889 TEST_P(SpdySessionTest, SynCompressionHistograms) { 1893 TEST_P(SpdySessionTest, SynCompressionHistograms) {
1890 std::unique_ptr<SpdySerializedFrame> req( 1894 std::unique_ptr<SpdySerializedFrame> req(
1891 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); 1895 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true));
1892 MockWrite writes[] = { 1896 MockWrite writes[] = {
1893 CreateMockWrite(*req, 0), 1897 CreateMockWrite(*req, 0),
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 2694
2691 EXPECT_EQ(0u, session_->num_active_streams()); 2695 EXPECT_EQ(0u, session_->num_active_streams());
2692 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams()); 2696 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams());
2693 EXPECT_EQ(2u, session_->pending_create_stream_queue_size(LOWEST)); 2697 EXPECT_EQ(2u, session_->pending_create_stream_queue_size(LOWEST));
2694 2698
2695 // Cancel the first stream; this will allow the second stream to be created. 2699 // Cancel the first stream; this will allow the second stream to be created.
2696 EXPECT_TRUE(spdy_stream1); 2700 EXPECT_TRUE(spdy_stream1);
2697 spdy_stream1->Cancel(); 2701 spdy_stream1->Cancel();
2698 EXPECT_FALSE(spdy_stream1); 2702 EXPECT_FALSE(spdy_stream1);
2699 2703
2700 EXPECT_EQ(OK, callback2.WaitForResult()); 2704 EXPECT_THAT(callback2.WaitForResult(), IsOk());
2701 EXPECT_EQ(0u, session_->num_active_streams()); 2705 EXPECT_EQ(0u, session_->num_active_streams());
2702 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams()); 2706 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams());
2703 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(LOWEST)); 2707 EXPECT_EQ(1u, session_->pending_create_stream_queue_size(LOWEST));
2704 2708
2705 // Cancel the second stream; this will allow the third stream to be created. 2709 // Cancel the second stream; this will allow the third stream to be created.
2706 base::WeakPtr<SpdyStream> spdy_stream2 = request2.ReleaseStream(); 2710 base::WeakPtr<SpdyStream> spdy_stream2 = request2.ReleaseStream();
2707 spdy_stream2->Cancel(); 2711 spdy_stream2->Cancel();
2708 EXPECT_FALSE(spdy_stream2); 2712 EXPECT_FALSE(spdy_stream2);
2709 2713
2710 EXPECT_EQ(OK, callback3.WaitForResult()); 2714 EXPECT_THAT(callback3.WaitForResult(), IsOk());
2711 EXPECT_EQ(0u, session_->num_active_streams()); 2715 EXPECT_EQ(0u, session_->num_active_streams());
2712 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams()); 2716 EXPECT_EQ(kInitialMaxConcurrentStreams, session_->num_created_streams());
2713 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(LOWEST)); 2717 EXPECT_EQ(0u, session_->pending_create_stream_queue_size(LOWEST));
2714 2718
2715 // Cancel the third stream. 2719 // Cancel the third stream.
2716 base::WeakPtr<SpdyStream> spdy_stream3 = request3.ReleaseStream(); 2720 base::WeakPtr<SpdyStream> spdy_stream3 = request3.ReleaseStream();
2717 spdy_stream3->Cancel(); 2721 spdy_stream3->Cancel();
2718 EXPECT_FALSE(spdy_stream3); 2722 EXPECT_FALSE(spdy_stream3);
2719 EXPECT_EQ(0u, session_->num_active_streams()); 2723 EXPECT_EQ(0u, session_->num_active_streams());
2720 EXPECT_EQ(kInitialMaxConcurrentStreams - 1, session_->num_created_streams()); 2724 EXPECT_EQ(kInitialMaxConcurrentStreams - 1, session_->num_created_streams());
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); 3255 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT));
3252 std::unique_ptr<ClientSocketHandle> connection2(new ClientSocketHandle); 3256 std::unique_ptr<ClientSocketHandle> connection2(new ClientSocketHandle);
3253 EXPECT_EQ(ERR_IO_PENDING, 3257 EXPECT_EQ(ERR_IO_PENDING,
3254 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY, 3258 connection2->Init(host_port2.ToString(), params2, DEFAULT_PRIORITY,
3255 ClientSocketPool::RespectLimits::ENABLED, 3259 ClientSocketPool::RespectLimits::ENABLED,
3256 callback2.callback(), pool, BoundNetLog())); 3260 callback2.callback(), pool, BoundNetLog()));
3257 EXPECT_TRUE(pool->IsStalled()); 3261 EXPECT_TRUE(pool->IsStalled());
3258 3262
3259 // The socket pool should close the connection asynchronously and establish a 3263 // The socket pool should close the connection asynchronously and establish a
3260 // new connection. 3264 // new connection.
3261 EXPECT_EQ(OK, callback2.WaitForResult()); 3265 EXPECT_THAT(callback2.WaitForResult(), IsOk());
3262 EXPECT_FALSE(pool->IsStalled()); 3266 EXPECT_FALSE(pool->IsStalled());
3263 EXPECT_FALSE(session_); 3267 EXPECT_FALSE(session_);
3264 } 3268 }
3265 3269
3266 // Tests the case of a non-SPDY request closing an idle SPDY session when no 3270 // Tests the case of a non-SPDY request closing an idle SPDY session when no
3267 // pointers to the idle session are currently held, in the case the SPDY session 3271 // pointers to the idle session are currently held, in the case the SPDY session
3268 // has an alias. 3272 // has an alias.
3269 TEST_P(SpdySessionTest, CloseOneIdleConnectionWithAlias) { 3273 TEST_P(SpdySessionTest, CloseOneIdleConnectionWithAlias) {
3270 ClientSocketPoolManager::set_max_sockets_per_group( 3274 ClientSocketPoolManager::set_max_sockets_per_group(
3271 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); 3275 HttpNetworkSession::NORMAL_SOCKET_POOL, 1);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); 3330 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT));
3327 std::unique_ptr<ClientSocketHandle> connection3(new ClientSocketHandle); 3331 std::unique_ptr<ClientSocketHandle> connection3(new ClientSocketHandle);
3328 EXPECT_EQ(ERR_IO_PENDING, 3332 EXPECT_EQ(ERR_IO_PENDING,
3329 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY, 3333 connection3->Init(host_port3.ToString(), params3, DEFAULT_PRIORITY,
3330 ClientSocketPool::RespectLimits::ENABLED, 3334 ClientSocketPool::RespectLimits::ENABLED,
3331 callback3.callback(), pool, BoundNetLog())); 3335 callback3.callback(), pool, BoundNetLog()));
3332 EXPECT_TRUE(pool->IsStalled()); 3336 EXPECT_TRUE(pool->IsStalled());
3333 3337
3334 // The socket pool should close the connection asynchronously and establish a 3338 // The socket pool should close the connection asynchronously and establish a
3335 // new connection. 3339 // new connection.
3336 EXPECT_EQ(OK, callback3.WaitForResult()); 3340 EXPECT_THAT(callback3.WaitForResult(), IsOk());
3337 EXPECT_FALSE(pool->IsStalled()); 3341 EXPECT_FALSE(pool->IsStalled());
3338 EXPECT_FALSE(session1); 3342 EXPECT_FALSE(session1);
3339 EXPECT_FALSE(session2); 3343 EXPECT_FALSE(session2);
3340 } 3344 }
3341 3345
3342 // Tests that when a SPDY session becomes idle, it closes itself if there is 3346 // Tests that when a SPDY session becomes idle, it closes itself if there is
3343 // a lower layer pool stalled on the per-pool socket limit. 3347 // a lower layer pool stalled on the per-pool socket limit.
3344 TEST_P(SpdySessionTest, CloseSessionOnIdleWhenPoolStalled) { 3348 TEST_P(SpdySessionTest, CloseSessionOnIdleWhenPoolStalled) {
3345 ClientSocketPoolManager::set_max_sockets_per_group( 3349 ClientSocketPoolManager::set_max_sockets_per_group(
3346 HttpNetworkSession::NORMAL_SOCKET_POOL, 1); 3350 HttpNetworkSession::NORMAL_SOCKET_POOL, 1);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 base::RunLoop().RunUntilIdle(); 3422 base::RunLoop().RunUntilIdle();
3419 EXPECT_TRUE(pool->IsStalled()); 3423 EXPECT_TRUE(pool->IsStalled());
3420 EXPECT_FALSE(callback2.have_result()); 3424 EXPECT_FALSE(callback2.have_result());
3421 3425
3422 // Cancelling the request should result in the session's socket being 3426 // Cancelling the request should result in the session's socket being
3423 // closed, since the pool is stalled. 3427 // closed, since the pool is stalled.
3424 ASSERT_TRUE(spdy_stream1.get()); 3428 ASSERT_TRUE(spdy_stream1.get());
3425 spdy_stream1->Cancel(); 3429 spdy_stream1->Cancel();
3426 base::RunLoop().RunUntilIdle(); 3430 base::RunLoop().RunUntilIdle();
3427 ASSERT_FALSE(pool->IsStalled()); 3431 ASSERT_FALSE(pool->IsStalled());
3428 EXPECT_EQ(OK, callback2.WaitForResult()); 3432 EXPECT_THAT(callback2.WaitForResult(), IsOk());
3429 } 3433 }
3430 3434
3431 // Verify that SpdySessionKey and therefore SpdySession is different when 3435 // Verify that SpdySessionKey and therefore SpdySession is different when
3432 // privacy mode is enabled or disabled. 3436 // privacy mode is enabled or disabled.
3433 TEST_P(SpdySessionTest, SpdySessionKeyPrivacyMode) { 3437 TEST_P(SpdySessionTest, SpdySessionKeyPrivacyMode) {
3434 CreateNetworkSession(); 3438 CreateNetworkSession();
3435 3439
3436 HostPortPair host_port_pair("www.example.org", 443); 3440 HostPortPair host_port_pair("www.example.org", 443);
3437 SpdySessionKey key_privacy_enabled(host_port_pair, ProxyServer::Direct(), 3441 SpdySessionKey key_privacy_enabled(host_port_pair, ProxyServer::Direct(),
3438 PRIVACY_MODE_ENABLED); 3442 PRIVACY_MODE_ENABLED);
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
4050 EXPECT_EQ(0, session_->session_unacked_recv_window_bytes_); 4054 EXPECT_EQ(0, session_->session_unacked_recv_window_bytes_);
4051 4055
4052 base::RunLoop().RunUntilIdle(); 4056 base::RunLoop().RunUntilIdle();
4053 4057
4054 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_); 4058 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_);
4055 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_); 4059 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_);
4056 4060
4057 stream->Close(); 4061 stream->Close();
4058 EXPECT_FALSE(stream); 4062 EXPECT_FALSE(stream);
4059 4063
4060 EXPECT_EQ(OK, delegate.WaitForClose()); 4064 EXPECT_THAT(delegate.WaitForClose(), IsOk());
4061 4065
4062 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_); 4066 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_);
4063 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_); 4067 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_);
4064 4068
4065 data.Resume(); 4069 data.Resume();
4066 base::RunLoop().RunUntilIdle(); 4070 base::RunLoop().RunUntilIdle();
4067 EXPECT_FALSE(session_); 4071 EXPECT_FALSE(session_);
4068 } 4072 }
4069 4073
4070 // Send data back and forth but close the stream before its data frame 4074 // Send data back and forth but close the stream before its data frame
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 4129
4126 EXPECT_EQ(initial_window_size - kMsgDataSize, 4130 EXPECT_EQ(initial_window_size - kMsgDataSize,
4127 session_->session_send_window_size_); 4131 session_->session_send_window_size_);
4128 4132
4129 // Closing the stream should increase the session's send window. 4133 // Closing the stream should increase the session's send window.
4130 stream->Close(); 4134 stream->Close();
4131 EXPECT_FALSE(stream); 4135 EXPECT_FALSE(stream);
4132 4136
4133 EXPECT_EQ(initial_window_size, session_->session_send_window_size_); 4137 EXPECT_EQ(initial_window_size, session_->session_send_window_size_);
4134 4138
4135 EXPECT_EQ(OK, delegate.WaitForClose()); 4139 EXPECT_THAT(delegate.WaitForClose(), IsOk());
4136 4140
4137 base::RunLoop().RunUntilIdle(); 4141 base::RunLoop().RunUntilIdle();
4138 EXPECT_FALSE(session_); 4142 EXPECT_FALSE(session_);
4139 4143
4140 EXPECT_TRUE(data.AllWriteDataConsumed()); 4144 EXPECT_TRUE(data.AllWriteDataConsumed());
4141 EXPECT_TRUE(data.AllReadDataConsumed()); 4145 EXPECT_TRUE(data.AllReadDataConsumed());
4142 } 4146 }
4143 4147
4144 // Send data back and forth; the send and receive windows should 4148 // Send data back and forth; the send and receive windows should
4145 // change appropriately. 4149 // change appropriately.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
4232 4236
4233 // Draining the delegate's read queue should increase the session's 4237 // Draining the delegate's read queue should increase the session's
4234 // receive window. 4238 // receive window.
4235 EXPECT_EQ(initial_window_size, session_->session_send_window_size_); 4239 EXPECT_EQ(initial_window_size, session_->session_send_window_size_);
4236 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_); 4240 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_);
4237 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_); 4241 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_);
4238 4242
4239 stream->Close(); 4243 stream->Close();
4240 EXPECT_FALSE(stream); 4244 EXPECT_FALSE(stream);
4241 4245
4242 EXPECT_EQ(OK, delegate.WaitForClose()); 4246 EXPECT_THAT(delegate.WaitForClose(), IsOk());
4243 4247
4244 EXPECT_EQ(initial_window_size, session_->session_send_window_size_); 4248 EXPECT_EQ(initial_window_size, session_->session_send_window_size_);
4245 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_); 4249 EXPECT_EQ(initial_window_size, session_->session_recv_window_size_);
4246 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_); 4250 EXPECT_EQ(kMsgDataSize, session_->session_unacked_recv_window_bytes_);
4247 4251
4248 data.Resume(); 4252 data.Resume();
4249 base::RunLoop().RunUntilIdle(); 4253 base::RunLoop().RunUntilIdle();
4250 EXPECT_FALSE(session_); 4254 EXPECT_FALSE(session_);
4251 } 4255 }
4252 4256
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 stall_function.Run(stream.get()); 4304 stall_function.Run(stream.get());
4301 4305
4302 base::RunLoop().RunUntilIdle(); 4306 base::RunLoop().RunUntilIdle();
4303 4307
4304 EXPECT_TRUE(stream->send_stalled_by_flow_control()); 4308 EXPECT_TRUE(stream->send_stalled_by_flow_control());
4305 4309
4306 unstall_function.Run(stream.get(), kBodyDataSize); 4310 unstall_function.Run(stream.get(), kBodyDataSize);
4307 4311
4308 EXPECT_FALSE(stream->send_stalled_by_flow_control()); 4312 EXPECT_FALSE(stream->send_stalled_by_flow_control());
4309 4313
4310 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate.WaitForClose()); 4314 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4311 4315
4312 EXPECT_TRUE(delegate.send_headers_completed()); 4316 EXPECT_TRUE(delegate.send_headers_completed());
4313 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status")); 4317 EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status"));
4314 EXPECT_EQ(std::string(), delegate.TakeReceivedData()); 4318 EXPECT_EQ(std::string(), delegate.TakeReceivedData());
4315 EXPECT_FALSE(session_); 4319 EXPECT_FALSE(session_);
4316 EXPECT_TRUE(data.AllWriteDataConsumed()); 4320 EXPECT_TRUE(data.AllWriteDataConsumed());
4317 } 4321 }
4318 4322
4319 // Run the resume-after-unstall test with all possible stall and 4323 // Run the resume-after-unstall test with all possible stall and
4320 // unstall sequences. 4324 // unstall sequences.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4463 EXPECT_FALSE(stream2->send_stalled_by_flow_control()); 4467 EXPECT_FALSE(stream2->send_stalled_by_flow_control());
4464 4468
4465 // This should then unstall stream1. 4469 // This should then unstall stream1.
4466 UnstallSessionSend(kBodyDataSize); 4470 UnstallSessionSend(kBodyDataSize);
4467 4471
4468 EXPECT_FALSE(stream1->send_stalled_by_flow_control()); 4472 EXPECT_FALSE(stream1->send_stalled_by_flow_control());
4469 EXPECT_FALSE(stream2->send_stalled_by_flow_control()); 4473 EXPECT_FALSE(stream2->send_stalled_by_flow_control());
4470 4474
4471 base::RunLoop().RunUntilIdle(); 4475 base::RunLoop().RunUntilIdle();
4472 4476
4473 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate1.WaitForClose()); 4477 EXPECT_THAT(delegate1.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4474 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate2.WaitForClose()); 4478 EXPECT_THAT(delegate2.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4475 4479
4476 EXPECT_TRUE(delegate1.send_headers_completed()); 4480 EXPECT_TRUE(delegate1.send_headers_completed());
4477 EXPECT_EQ("200", delegate1.GetResponseHeaderValue(":status")); 4481 EXPECT_EQ("200", delegate1.GetResponseHeaderValue(":status"));
4478 EXPECT_EQ(std::string(), delegate1.TakeReceivedData()); 4482 EXPECT_EQ(std::string(), delegate1.TakeReceivedData());
4479 4483
4480 EXPECT_TRUE(delegate2.send_headers_completed()); 4484 EXPECT_TRUE(delegate2.send_headers_completed());
4481 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); 4485 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status"));
4482 EXPECT_EQ(std::string(), delegate2.TakeReceivedData()); 4486 EXPECT_EQ(std::string(), delegate2.TakeReceivedData());
4483 4487
4484 EXPECT_FALSE(session_); 4488 EXPECT_FALSE(session_);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 EXPECT_FALSE(stream2->send_stalled_by_flow_control()); 4637 EXPECT_FALSE(stream2->send_stalled_by_flow_control());
4634 EXPECT_FALSE(session_->IsStreamActive(stream_id1)); 4638 EXPECT_FALSE(session_->IsStreamActive(stream_id1));
4635 EXPECT_TRUE(session_->IsStreamActive(stream_id2)); 4639 EXPECT_TRUE(session_->IsStreamActive(stream_id2));
4636 EXPECT_FALSE(session_->IsStreamActive(stream_id3)); 4640 EXPECT_FALSE(session_->IsStreamActive(stream_id3));
4637 4641
4638 data.Resume(); 4642 data.Resume();
4639 base::RunLoop().RunUntilIdle(); 4643 base::RunLoop().RunUntilIdle();
4640 EXPECT_FALSE(stream2); 4644 EXPECT_FALSE(stream2);
4641 EXPECT_FALSE(session_); 4645 EXPECT_FALSE(session_);
4642 4646
4643 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate1.WaitForClose()); 4647 EXPECT_THAT(delegate1.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4644 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate2.WaitForClose()); 4648 EXPECT_THAT(delegate2.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4645 EXPECT_EQ(OK, delegate3.WaitForClose()); 4649 EXPECT_THAT(delegate3.WaitForClose(), IsOk());
4646 4650
4647 EXPECT_TRUE(delegate1.send_headers_completed()); 4651 EXPECT_TRUE(delegate1.send_headers_completed());
4648 EXPECT_EQ(std::string(), delegate1.TakeReceivedData()); 4652 EXPECT_EQ(std::string(), delegate1.TakeReceivedData());
4649 4653
4650 EXPECT_TRUE(delegate2.send_headers_completed()); 4654 EXPECT_TRUE(delegate2.send_headers_completed());
4651 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status")); 4655 EXPECT_EQ("200", delegate2.GetResponseHeaderValue(":status"));
4652 EXPECT_EQ(std::string(), delegate2.TakeReceivedData()); 4656 EXPECT_EQ(std::string(), delegate2.TakeReceivedData());
4653 4657
4654 EXPECT_TRUE(delegate3.send_headers_completed()); 4658 EXPECT_TRUE(delegate3.send_headers_completed());
4655 EXPECT_EQ(std::string(), delegate3.TakeReceivedData()); 4659 EXPECT_EQ(std::string(), delegate3.TakeReceivedData());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 4740
4737 // Close the session (since we can't do it from within the delegate 4741 // Close the session (since we can't do it from within the delegate
4738 // method, since it's in the stream's loop). 4742 // method, since it's in the stream's loop).
4739 session_->CloseSessionOnError(ERR_CONNECTION_CLOSED, "Closing session"); 4743 session_->CloseSessionOnError(ERR_CONNECTION_CLOSED, "Closing session");
4740 data.Resume(); 4744 data.Resume();
4741 base::RunLoop().RunUntilIdle(); 4745 base::RunLoop().RunUntilIdle();
4742 EXPECT_FALSE(session_); 4746 EXPECT_FALSE(session_);
4743 4747
4744 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_)); 4748 EXPECT_FALSE(HasSpdySession(spdy_session_pool_, key_));
4745 4749
4746 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate1.WaitForClose()); 4750 EXPECT_THAT(delegate1.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4747 EXPECT_EQ(ERR_CONNECTION_CLOSED, delegate2.WaitForClose()); 4751 EXPECT_THAT(delegate2.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
4748 4752
4749 EXPECT_TRUE(delegate1.send_headers_completed()); 4753 EXPECT_TRUE(delegate1.send_headers_completed());
4750 EXPECT_EQ(std::string(), delegate1.TakeReceivedData()); 4754 EXPECT_EQ(std::string(), delegate1.TakeReceivedData());
4751 4755
4752 EXPECT_TRUE(delegate2.send_headers_completed()); 4756 EXPECT_TRUE(delegate2.send_headers_completed());
4753 EXPECT_EQ(std::string(), delegate2.TakeReceivedData()); 4757 EXPECT_EQ(std::string(), delegate2.TakeReceivedData());
4754 4758
4755 EXPECT_TRUE(data.AllWriteDataConsumed()); 4759 EXPECT_TRUE(data.AllWriteDataConsumed());
4756 } 4760 }
4757 4761
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 base::RunLoop().RunUntilIdle(); 4800 base::RunLoop().RunUntilIdle();
4797 4801
4798 // Put session on the edge of overflowing it's recv window. 4802 // Put session on the edge of overflowing it's recv window.
4799 session_->session_recv_window_size_ = 1; 4803 session_->session_recv_window_size_ = 1;
4800 4804
4801 // Read response headers & body. Body overflows the session window, and a 4805 // Read response headers & body. Body overflows the session window, and a
4802 // goaway is written. 4806 // goaway is written.
4803 data.Resume(); 4807 data.Resume();
4804 base::RunLoop().RunUntilIdle(); 4808 base::RunLoop().RunUntilIdle();
4805 4809
4806 EXPECT_EQ(ERR_SPDY_FLOW_CONTROL_ERROR, delegate.WaitForClose()); 4810 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_SPDY_FLOW_CONTROL_ERROR));
4807 EXPECT_FALSE(session_); 4811 EXPECT_FALSE(session_);
4808 } 4812 }
4809 4813
4810 TEST_P(SpdySessionTest, SplitHeaders) { 4814 TEST_P(SpdySessionTest, SplitHeaders) {
4811 GURL kStreamUrl("https://www.example.org/foo.dat"); 4815 GURL kStreamUrl("https://www.example.org/foo.dat");
4812 SpdyHeaderBlock headers; 4816 SpdyHeaderBlock headers;
4813 spdy_util_.AddUrlToHeaderBlock(kStreamUrl.spec(), &headers); 4817 spdy_util_.AddUrlToHeaderBlock(kStreamUrl.spec(), &headers);
4814 headers["alpha"] = "beta"; 4818 headers["alpha"] = "beta";
4815 4819
4816 SpdyHeaderBlock request_headers; 4820 SpdyHeaderBlock request_headers;
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
5337 data.Resume(); 5341 data.Resume();
5338 base::RunLoop().RunUntilIdle(); 5342 base::RunLoop().RunUntilIdle();
5339 EXPECT_EQ(2u, session_->num_active_streams()); 5343 EXPECT_EQ(2u, session_->num_active_streams());
5340 EXPECT_EQ(0u, session_->num_created_streams()); 5344 EXPECT_EQ(0u, session_->num_created_streams());
5341 EXPECT_EQ(1u, session_->num_pushed_streams()); 5345 EXPECT_EQ(1u, session_->num_pushed_streams());
5342 EXPECT_EQ(0u, session_->num_active_pushed_streams()); 5346 EXPECT_EQ(0u, session_->num_active_pushed_streams());
5343 5347
5344 base::WeakPtr<SpdyStream> pushed_stream; 5348 base::WeakPtr<SpdyStream> pushed_stream;
5345 int rv = 5349 int rv =
5346 session_->GetPushStream(GURL(kPushedUrl), &pushed_stream, BoundNetLog()); 5350 session_->GetPushStream(GURL(kPushedUrl), &pushed_stream, BoundNetLog());
5347 ASSERT_EQ(OK, rv); 5351 ASSERT_THAT(rv, IsOk());
5348 ASSERT_TRUE(pushed_stream); 5352 ASSERT_TRUE(pushed_stream);
5349 test::StreamDelegateCloseOnHeaders delegate2(pushed_stream); 5353 test::StreamDelegateCloseOnHeaders delegate2(pushed_stream);
5350 pushed_stream->SetDelegate(&delegate2); 5354 pushed_stream->SetDelegate(&delegate2);
5351 5355
5352 // Receive headers for pushed stream. Delegate will cancel the stream, ensure 5356 // Receive headers for pushed stream. Delegate will cancel the stream, ensure
5353 // that all our counters are in consistent state. 5357 // that all our counters are in consistent state.
5354 data.Resume(); 5358 data.Resume();
5355 base::RunLoop().RunUntilIdle(); 5359 base::RunLoop().RunUntilIdle();
5356 EXPECT_EQ(1u, session_->num_active_streams()); 5360 EXPECT_EQ(1u, session_->num_active_streams());
5357 EXPECT_EQ(0u, session_->num_created_streams()); 5361 EXPECT_EQ(0u, session_->num_created_streams());
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
5896 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), 5900 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(),
5897 "spdy_pooling.pem"); 5901 "spdy_pooling.pem");
5898 ssl_info.is_issued_by_known_root = true; 5902 ssl_info.is_issued_by_known_root = true;
5899 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); 5903 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin));
5900 5904
5901 EXPECT_TRUE(SpdySession::CanPool( 5905 EXPECT_TRUE(SpdySession::CanPool(
5902 &tss, ssl_info, "www.example.org", "mail.example.org")); 5906 &tss, ssl_info, "www.example.org", "mail.example.org"));
5903 } 5907 }
5904 5908
5905 } // namespace net 5909 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_pool_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698