| OLD | NEW |
| 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/tools/quic/quic_reliable_server_stream.h" | 5 #include "net/tools/quic/quic_reliable_server_stream.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "net/quic/quic_spdy_compressor.h" |
| 8 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
| 9 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| 10 #include "net/tools/flip_server/epoll_server.h" | 11 #include "net/tools/flip_server/epoll_server.h" |
| 11 #include "net/tools/quic/quic_in_memory_cache.h" | 12 #include "net/tools/quic/quic_in_memory_cache.h" |
| 12 #include "net/tools/quic/quic_spdy_server_stream.h" | 13 #include "net/tools/quic/quic_spdy_server_stream.h" |
| 13 #include "net/tools/quic/spdy_utils.h" | 14 #include "net/tools/quic/spdy_utils.h" |
| 14 #include "net/tools/quic/test_tools/quic_test_utils.h" | 15 #include "net/tools/quic/test_tools/quic_test_utils.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 "POST", "https://www.google.com/", "HTTP/1.1"); | 54 "POST", "https://www.google.com/", "HTTP/1.1"); |
| 54 request_headers.ReplaceOrAppendHeader("content-length", "11"); | 55 request_headers.ReplaceOrAppendHeader("content-length", "11"); |
| 55 | 56 |
| 56 headers_string_ = SpdyUtils::SerializeRequestHeaders(request_headers); | 57 headers_string_ = SpdyUtils::SerializeRequestHeaders(request_headers); |
| 57 stream_.reset(new QuicSpdyServerStream(3, &session_)); | 58 stream_.reset(new QuicSpdyServerStream(3, &session_)); |
| 58 } | 59 } |
| 59 | 60 |
| 60 QuicConsumedData ValidateHeaders(StringPiece headers) { | 61 QuicConsumedData ValidateHeaders(StringPiece headers) { |
| 61 headers_string_ = SpdyUtils::SerializeResponseHeaders( | 62 headers_string_ = SpdyUtils::SerializeResponseHeaders( |
| 62 response_headers_); | 63 response_headers_); |
| 64 QuicSpdyDecompressor decompressor; |
| 65 TestDecompressorVisitor visitor; |
| 63 | 66 |
| 64 EXPECT_EQ(headers, headers_string_); | 67 // First the header id, then the compressed data. |
| 68 EXPECT_EQ(1, headers[0]); |
| 69 EXPECT_EQ(0, headers[1]); |
| 70 EXPECT_EQ(0, headers[2]); |
| 71 EXPECT_EQ(0, headers[3]); |
| 72 EXPECT_EQ(static_cast<size_t>(headers.length() - 4), |
| 73 decompressor.DecompressData(headers.substr(4), &visitor)); |
| 74 |
| 75 EXPECT_EQ(headers_string_, visitor.data()); |
| 65 | 76 |
| 66 return QuicConsumedData(headers.size(), false); | 77 return QuicConsumedData(headers.size(), false); |
| 67 } | 78 } |
| 68 | 79 |
| 69 static void SetUpTestCase() { | 80 static void SetUpTestCase() { |
| 70 QuicInMemoryCache::GetInstance()->ResetForTests(); | 81 QuicInMemoryCache::GetInstance()->ResetForTests(); |
| 71 } | 82 } |
| 72 | 83 |
| 73 virtual void SetUp() { | 84 virtual void SetUp() { |
| 74 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); | 85 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 210 |
| 200 stream_->SendErrorResponse(); | 211 stream_->SendErrorResponse(); |
| 201 EXPECT_TRUE(stream_->read_side_closed()); | 212 EXPECT_TRUE(stream_->read_side_closed()); |
| 202 EXPECT_TRUE(stream_->write_side_closed()); | 213 EXPECT_TRUE(stream_->write_side_closed()); |
| 203 } | 214 } |
| 204 | 215 |
| 205 } // namespace | 216 } // namespace |
| 206 } // namespace test | 217 } // namespace test |
| 207 } // namespace tools | 218 } // namespace tools |
| 208 } // namespace net | 219 } // namespace net |
| OLD | NEW |