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

Side by Side Diff: net/quic/quic_stream_factory_test.cc

Issue 1320423011: Implement SSLConfigService::Observer in QuicStreamFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | no next file » | 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/quic/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 EXPECT_EQ(OK, callback_.WaitForResult()); 1327 EXPECT_EQ(OK, callback_.WaitForResult());
1328 stream = request2.ReleaseStream(); 1328 stream = request2.ReleaseStream();
1329 stream.reset(); // Will reset stream 3. 1329 stream.reset(); // Will reset stream 3.
1330 1330
1331 EXPECT_TRUE(socket_data.AllReadDataConsumed()); 1331 EXPECT_TRUE(socket_data.AllReadDataConsumed());
1332 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); 1332 EXPECT_TRUE(socket_data.AllWriteDataConsumed());
1333 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 1333 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
1334 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 1334 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
1335 } 1335 }
1336 1336
1337 TEST_P(QuicStreamFactoryTest, OnSSLConfigChanged) {
1338 MockRead reads[] = {
1339 MockRead(ASYNC, 0, 0) // EOF
1340 };
1341 scoped_ptr<QuicEncryptedPacket> rst(ConstructRstPacket());
1342 std::vector<MockWrite> writes;
1343 writes.push_back(MockWrite(ASYNC, rst->data(), rst->length(), 1));
1344 DeterministicSocketData socket_data(reads, arraysize(reads),
1345 writes.empty() ? nullptr : &writes[0],
1346 writes.size());
1347 socket_factory_.AddSocketDataProvider(&socket_data);
1348 socket_data.StopAfter(1);
1349
1350 MockRead reads2[] = {
1351 MockRead(ASYNC, 0, 0) // EOF
1352 };
1353 DeterministicSocketData socket_data2(reads2, arraysize(reads2), nullptr, 0);
1354 socket_factory_.AddSocketDataProvider(&socket_data2);
1355 socket_data2.StopAfter(1);
1356
1357 QuicStreamRequest request(&factory_);
1358 EXPECT_EQ(ERR_IO_PENDING,
1359 request.Request(host_port_pair_, is_https_, privacy_mode_,
1360 /*cert_verify_flags=*/0, host_port_pair_.host(),
1361 "GET", net_log_, callback_.callback()));
1362
1363 EXPECT_EQ(OK, callback_.WaitForResult());
1364 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
1365 HttpRequestInfo request_info;
1366 EXPECT_EQ(OK, stream->InitializeStream(&request_info, DEFAULT_PRIORITY,
1367 net_log_, CompletionCallback()));
1368
1369 factory_.OnSSLConfigChanged();
1370 EXPECT_EQ(ERR_CERT_DATABASE_CHANGED,
1371 stream->ReadResponseHeaders(callback_.callback()));
1372 EXPECT_FALSE(factory_.require_confirmation());
1373
1374 // Now attempting to request a stream to the same origin should create
1375 // a new session.
1376
1377 QuicStreamRequest request2(&factory_);
1378 EXPECT_EQ(ERR_IO_PENDING,
1379 request2.Request(host_port_pair_, is_https_, privacy_mode_,
1380 /*cert_verify_flags=*/0, host_port_pair_.host(),
1381 "GET", net_log_, callback_.callback()));
1382
1383 EXPECT_EQ(OK, callback_.WaitForResult());
1384 stream = request2.ReleaseStream();
1385 stream.reset(); // Will reset stream 3.
1386
1387 EXPECT_TRUE(socket_data.AllReadDataConsumed());
1388 EXPECT_TRUE(socket_data.AllWriteDataConsumed());
1389 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
1390 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
1391 }
1392
1337 TEST_P(QuicStreamFactoryTest, OnCertAdded) { 1393 TEST_P(QuicStreamFactoryTest, OnCertAdded) {
1338 MockRead reads[] = { 1394 MockRead reads[] = {
1339 MockRead(ASYNC, 0, 0) // EOF 1395 MockRead(ASYNC, 0, 0) // EOF
1340 }; 1396 };
1341 scoped_ptr<QuicEncryptedPacket> rst(ConstructRstPacket()); 1397 scoped_ptr<QuicEncryptedPacket> rst(ConstructRstPacket());
1342 std::vector<MockWrite> writes; 1398 std::vector<MockWrite> writes;
1343 writes.push_back(MockWrite(ASYNC, rst->data(), rst->length(), 1)); 1399 writes.push_back(MockWrite(ASYNC, rst->data(), rst->length(), 1));
1344 DeterministicSocketData socket_data(reads, arraysize(reads), 1400 DeterministicSocketData socket_data(reads, arraysize(reads),
1345 writes.empty() ? nullptr : &writes[0], 1401 writes.empty() ? nullptr : &writes[0],
1346 writes.size()); 1402 writes.size());
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 2504 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
2449 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 2505 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
2450 EXPECT_TRUE(socket_data3.AllReadDataConsumed()); 2506 EXPECT_TRUE(socket_data3.AllReadDataConsumed());
2451 EXPECT_TRUE(socket_data3.AllWriteDataConsumed()); 2507 EXPECT_TRUE(socket_data3.AllWriteDataConsumed());
2452 EXPECT_TRUE(socket_data4.AllReadDataConsumed()); 2508 EXPECT_TRUE(socket_data4.AllReadDataConsumed());
2453 EXPECT_TRUE(socket_data4.AllWriteDataConsumed()); 2509 EXPECT_TRUE(socket_data4.AllWriteDataConsumed());
2454 } 2510 }
2455 2511
2456 } // namespace test 2512 } // namespace test
2457 } // namespace net 2513 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698