OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/flip_server/spdy_interface.h" | 5 #include "net/tools/flip_server/spdy_interface.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
| 8 #include <memory> |
8 | 9 |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "net/spdy/buffered_spdy_framer.h" | 11 #include "net/spdy/buffered_spdy_framer.h" |
12 #include "net/tools/balsa/balsa_enums.h" | 12 #include "net/tools/balsa/balsa_enums.h" |
13 #include "net/tools/balsa/balsa_headers.h" | 13 #include "net/tools/balsa/balsa_headers.h" |
14 #include "net/tools/flip_server/flip_config.h" | 14 #include "net/tools/flip_server/flip_config.h" |
15 #include "net/tools/flip_server/flip_test_utils.h" | 15 #include "net/tools/flip_server/flip_test_utils.h" |
16 #include "net/tools/flip_server/mem_cache.h" | 16 #include "net/tools/flip_server/mem_cache.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 delete *i; | 187 delete *i; |
188 } | 188 } |
189 output_list.clear(); | 189 output_list.clear(); |
190 } | 190 } |
191 | 191 |
192 bool HasStream(uint32_t stream_id) { | 192 bool HasStream(uint32_t stream_id) { |
193 return interface_->output_ordering().ExistsInPriorityMaps(stream_id); | 193 return interface_->output_ordering().ExistsInPriorityMaps(stream_id); |
194 } | 194 } |
195 | 195 |
196 protected: | 196 protected: |
197 scoped_ptr<MockSMInterface> mock_another_interface_; | 197 std::unique_ptr<MockSMInterface> mock_another_interface_; |
198 scoped_ptr<MemoryCache> memory_cache_; | 198 std::unique_ptr<MemoryCache> memory_cache_; |
199 scoped_ptr<FlipAcceptor> acceptor_; | 199 std::unique_ptr<FlipAcceptor> acceptor_; |
200 scoped_ptr<EpollServer> epoll_server_; | 200 std::unique_ptr<EpollServer> epoll_server_; |
201 scoped_ptr<FakeSMConnection> connection_; | 201 std::unique_ptr<FakeSMConnection> connection_; |
202 scoped_ptr<TestSpdySM> interface_; | 202 std::unique_ptr<TestSpdySM> interface_; |
203 scoped_ptr<BufferedSpdyFramer> spdy_framer_; | 203 std::unique_ptr<BufferedSpdyFramer> spdy_framer_; |
204 scoped_ptr<SpdyFramerVisitor> spdy_framer_visitor_; | 204 std::unique_ptr<SpdyFramerVisitor> spdy_framer_visitor_; |
205 }; | 205 }; |
206 | 206 |
207 class SpdySMProxyTest : public SpdySMTestBase { | 207 class SpdySMProxyTest : public SpdySMTestBase { |
208 public: | 208 public: |
209 SpdySMProxyTest() : SpdySMTestBase(FLIP_HANDLER_PROXY) {} | 209 SpdySMProxyTest() : SpdySMTestBase(FLIP_HANDLER_PROXY) {} |
210 virtual ~SpdySMProxyTest() {} | 210 virtual ~SpdySMProxyTest() {} |
211 }; | 211 }; |
212 | 212 |
213 class SpdySMServerTest : public SpdySMTestBase { | 213 class SpdySMServerTest : public SpdySMTestBase { |
214 public: | 214 public: |
215 SpdySMServerTest() : SpdySMTestBase(FLIP_HANDLER_SPDY_SERVER) {} | 215 SpdySMServerTest() : SpdySMTestBase(FLIP_HANDLER_SPDY_SERVER) {} |
216 virtual ~SpdySMServerTest() {} | 216 virtual ~SpdySMServerTest() {} |
217 }; | 217 }; |
218 | 218 |
219 INSTANTIATE_TEST_CASE_P(SpdySMProxyTest, SpdySMProxyTest, Values(SPDY3, HTTP2)); | 219 INSTANTIATE_TEST_CASE_P(SpdySMProxyTest, SpdySMProxyTest, Values(SPDY3, HTTP2)); |
220 INSTANTIATE_TEST_CASE_P(SpdySMServerTest, SpdySMServerTest, Values(HTTP2)); | 220 INSTANTIATE_TEST_CASE_P(SpdySMServerTest, SpdySMServerTest, Values(HTTP2)); |
221 | 221 |
222 TEST_P(SpdySMProxyTest, InitSMConnection) { | 222 TEST_P(SpdySMProxyTest, InitSMConnection) { |
223 { | 223 { |
224 InSequence s; | 224 InSequence s; |
225 EXPECT_CALL(*connection_, InitSMConnection(_, _, _, _, _, _, _, _)); | 225 EXPECT_CALL(*connection_, InitSMConnection(_, _, _, _, _, _, _, _)); |
226 } | 226 } |
227 interface_->InitSMConnection( | 227 interface_->InitSMConnection( |
228 NULL, NULL, epoll_server_.get(), -1, "", "", "", false); | 228 NULL, NULL, epoll_server_.get(), -1, "", "", "", false); |
229 } | 229 } |
230 | 230 |
231 TEST_P(SpdySMProxyTest, OnStreamFrameData) { | 231 TEST_P(SpdySMProxyTest, OnStreamFrameData) { |
232 BufferedSpdyFramerVisitorInterface* visitor = interface_.get(); | 232 BufferedSpdyFramerVisitorInterface* visitor = interface_.get(); |
233 scoped_ptr<MockSMInterface> mock_interface(new MockSMInterface); | 233 std::unique_ptr<MockSMInterface> mock_interface(new MockSMInterface); |
234 uint32_t stream_id = 92; | 234 uint32_t stream_id = 92; |
235 uint32_t associated_id = 43; | 235 uint32_t associated_id = 43; |
236 SpdyHeaderBlock block; | 236 SpdyHeaderBlock block; |
237 testing::MockFunction<void(int)> checkpoint; // NOLINT | 237 testing::MockFunction<void(int)> checkpoint; // NOLINT |
238 | 238 |
239 scoped_ptr<SpdySerializedFrame> frame( | 239 std::unique_ptr<SpdySerializedFrame> frame( |
240 spdy_framer_->CreatePingFrame(12, false)); | 240 spdy_framer_->CreatePingFrame(12, false)); |
241 block[":method"] = "GET"; | 241 block[":method"] = "GET"; |
242 block[":host"] = "www.example.com"; | 242 block[":host"] = "www.example.com"; |
243 block[":path"] = "/path"; | 243 block[":path"] = "/path"; |
244 block[":scheme"] = "http"; | 244 block[":scheme"] = "http"; |
245 block["foo"] = "bar"; | 245 block["foo"] = "bar"; |
246 { | 246 { |
247 InSequence s; | 247 InSequence s; |
248 EXPECT_CALL(*interface_, | 248 EXPECT_CALL(*interface_, |
249 FindOrMakeNewSMConnectionInterface(_, _)) | 249 FindOrMakeNewSMConnectionInterface(_, _)) |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 ASSERT_EQ(2, spdy_framer_->frames_received()); | 613 ASSERT_EQ(2, spdy_framer_->frames_received()); |
614 ASSERT_EQ(2u, actual_header_block.size()); | 614 ASSERT_EQ(2u, actual_header_block.size()); |
615 ASSERT_EQ("404 Not Found", actual_header_block["status"]); | 615 ASSERT_EQ("404 Not Found", actual_header_block["status"]); |
616 ASSERT_EQ("HTTP/1.1", actual_header_block["version"]); | 616 ASSERT_EQ("HTTP/1.1", actual_header_block["version"]); |
617 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); | 617 ASSERT_EQ("wtf?", StringPiece(actual_data, actual_size)); |
618 } | 618 } |
619 | 619 |
620 } // namespace | 620 } // namespace |
621 | 621 |
622 } // namespace net | 622 } // namespace net |
OLD | NEW |