Connect PPAPI IPC channels for non-SFI mode.
[chromium-blink-merge.git] / net / tools / quic / quic_client_session_test.cc
blob23d79a774f2ca016af5f9ab0e5cb86c3a07aa9c8
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
3 // found in the LICENSE file.
5 #include "net/tools/quic/quic_client_session.h"
7 #include <vector>
9 #include "net/base/ip_endpoint.h"
10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
11 #include "net/quic/test_tools/crypto_test_utils.h"
12 #include "net/quic/test_tools/quic_test_utils.h"
13 #include "net/tools/quic/quic_spdy_client_stream.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 using net::test::CryptoTestUtils;
17 using net::test::DefaultQuicConfig;
18 using net::test::PacketSavingConnection;
19 using net::test::SupportedVersions;
20 using testing::_;
22 namespace net {
23 namespace tools {
24 namespace test {
25 namespace {
27 const char kServerHostname[] = "www.example.com";
29 class ToolsQuicClientSessionTest
30 : public ::testing::TestWithParam<QuicVersion> {
31 protected:
32 ToolsQuicClientSessionTest()
33 : connection_(new PacketSavingConnection(false,
34 SupportedVersions(GetParam()))) {
35 crypto_config_.SetDefaults();
36 session_.reset(new QuicClientSession(kServerHostname, DefaultQuicConfig(),
37 connection_, &crypto_config_));
38 session_->config()->SetDefaults();
41 void CompleteCryptoHandshake() {
42 ASSERT_TRUE(session_->CryptoConnect());
43 CryptoTestUtils::HandshakeWithFakeServer(
44 connection_, session_->GetCryptoStream());
47 PacketSavingConnection* connection_;
48 scoped_ptr<QuicClientSession> session_;
49 QuicCryptoClientConfig crypto_config_;
52 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest,
53 ::testing::ValuesIn(QuicSupportedVersions()));
55 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) {
56 CompleteCryptoHandshake();
59 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) {
60 session_->config()->set_max_streams_per_connection(1, 1);
61 // FLAGS_max_streams_per_connection = 1;
62 // Initialize crypto before the client session will create a stream.
63 CompleteCryptoHandshake();
65 QuicSpdyClientStream* stream =
66 session_->CreateOutgoingDataStream();
67 ASSERT_TRUE(stream);
68 EXPECT_FALSE(session_->CreateOutgoingDataStream());
70 // Close a stream and ensure I can now open a new one.
71 session_->CloseStream(stream->id());
72 stream = session_->CreateOutgoingDataStream();
73 EXPECT_TRUE(stream);
76 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) {
77 CompleteCryptoHandshake();
79 // After receiving a GoAway, I should no longer be able to create outgoing
80 // streams.
81 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
82 EXPECT_EQ(NULL, session_->CreateOutgoingDataStream());
85 } // namespace
86 } // namespace test
87 } // namespace tools
88 } // namespace net