Windows should animate when they are about to get docked at screen edges.
[chromium-blink-merge.git] / net / tools / quic / quic_client_session_test.cc
blob1b1ece6597e3b7e584ea3c4644eb0ec8cfcf991d
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_reliable_client_stream.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 using testing::_;
17 using net::test::CryptoTestUtils;
18 using net::test::PacketSavingConnection;
20 namespace net {
21 namespace tools {
22 namespace test {
23 namespace {
25 const char kServerHostname[] = "www.example.com";
27 class ToolsQuicClientSessionTest : public ::testing::Test {
28 protected:
29 ToolsQuicClientSessionTest()
30 : guid_(1),
31 connection_(new PacketSavingConnection(guid_, IPEndPoint(), false)) {
32 crypto_config_.SetDefaults();
33 session_.reset(new QuicClientSession(kServerHostname, QuicConfig(),
34 connection_, &crypto_config_));
35 session_->config()->SetDefaults();
38 void CompleteCryptoHandshake() {
39 ASSERT_TRUE(session_->CryptoConnect());
40 CryptoTestUtils::HandshakeWithFakeServer(
41 connection_, session_->GetCryptoStream());
44 QuicGuid guid_;
45 PacketSavingConnection* connection_;
46 scoped_ptr<QuicClientSession> session_;
47 QuicCryptoClientConfig crypto_config_;
50 TEST_F(ToolsQuicClientSessionTest, CryptoConnect) {
51 if (!Aes128Gcm12Encrypter::IsSupported()) {
52 LOG(INFO) << "AES GCM not supported. Test skipped.";
53 return;
55 CompleteCryptoHandshake();
58 TEST_F(ToolsQuicClientSessionTest, MaxNumStreams) {
59 session_->config()->set_max_streams_per_connection(1, 1);
60 if (!Aes128Gcm12Encrypter::IsSupported()) {
61 LOG(INFO) << "AES GCM not supported. Test skipped.";
62 return;
64 // FLAGS_max_streams_per_connection = 1;
65 // Initialize crypto before the client session will create a stream.
66 CompleteCryptoHandshake();
68 QuicReliableClientStream* stream =
69 session_->CreateOutgoingReliableStream();
70 ASSERT_TRUE(stream);
71 EXPECT_FALSE(session_->CreateOutgoingReliableStream());
73 // Close a stream and ensure I can now open a new one.
74 session_->CloseStream(stream->id());
75 stream = session_->CreateOutgoingReliableStream();
76 EXPECT_TRUE(stream);
79 TEST_F(ToolsQuicClientSessionTest, GoAwayReceived) {
80 if (!Aes128Gcm12Encrypter::IsSupported()) {
81 LOG(INFO) << "AES GCM not supported. Test skipped.";
82 return;
85 CompleteCryptoHandshake();
87 // After receiving a GoAway, I should no longer be able to create outgoing
88 // streams.
89 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
90 EXPECT_EQ(NULL, session_->CreateOutgoingReliableStream());
93 } // namespace
94 } // namespace test
95 } // namespace tools
96 } // namespace net