| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ | 5 #ifndef NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ |
| 6 #define NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ | 6 #define NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
| 12 #include "net/spdy/spdy_framer.h" | 12 #include "net/spdy/spdy_framer.h" |
| 13 #include "net/spdy/spdy_test_utils.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 namespace test { | 18 namespace test { |
| 18 | 19 |
| 19 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { | 20 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { |
| 20 public: | 21 public: |
| 21 MockSpdyFramerVisitor(); | 22 MockSpdyFramerVisitor(); |
| 22 virtual ~MockSpdyFramerVisitor(); | 23 virtual ~MockSpdyFramerVisitor(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 void(SpdyStreamId stream_id, | 69 void(SpdyStreamId stream_id, |
| 69 base::StringPiece origin, | 70 base::StringPiece origin, |
| 70 const SpdyAltSvcWireFormat::AlternativeServiceVector& | 71 const SpdyAltSvcWireFormat::AlternativeServiceVector& |
| 71 altsvc_vector)); | 72 altsvc_vector)); |
| 72 MOCK_METHOD4(OnPriority, | 73 MOCK_METHOD4(OnPriority, |
| 73 void(SpdyStreamId stream_id, | 74 void(SpdyStreamId stream_id, |
| 74 SpdyStreamId parent_stream_id, | 75 SpdyStreamId parent_stream_id, |
| 75 uint8_t weight, | 76 uint8_t weight, |
| 76 bool exclusive)); | 77 bool exclusive)); |
| 77 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); | 78 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); |
| 79 |
| 80 void DelegateNewHeaderHandling() { |
| 81 ON_CALL(*this, OnHeaderFrameStart(testing::_)) |
| 82 .WillByDefault(testing::Invoke( |
| 83 this, &MockSpdyFramerVisitor::ReturnTestHeadersHandler)); |
| 84 ON_CALL(*this, OnHeaderFrameEnd(testing::_, testing::_)) |
| 85 .WillByDefault(testing::Invoke( |
| 86 this, &MockSpdyFramerVisitor::ResetTestHeadersHandler)); |
| 87 } |
| 88 |
| 89 SpdyHeadersHandlerInterface* ReturnTestHeadersHandler( |
| 90 SpdyStreamId /* stream_id */) { |
| 91 if (headers_handler_ == nullptr) { |
| 92 headers_handler_.reset(new TestHeadersHandler); |
| 93 } |
| 94 return headers_handler_.get(); |
| 95 } |
| 96 |
| 97 void ResetTestHeadersHandler(SpdyStreamId /* stream_id */, bool end) { |
| 98 if (end) { |
| 99 headers_handler_.reset(); |
| 100 } |
| 101 } |
| 102 |
| 103 std::unique_ptr<SpdyHeadersHandlerInterface> headers_handler_; |
| 78 }; | 104 }; |
| 79 | 105 |
| 80 } // namespace test | 106 } // namespace test |
| 81 | 107 |
| 82 } // namespace net | 108 } // namespace net |
| 83 | 109 |
| 84 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ | 110 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ |
| OLD | NEW |