| 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" | |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 15 | 14 |
| 16 namespace net { | 15 namespace net { |
| 17 | 16 |
| 18 namespace test { | 17 namespace test { |
| 19 | 18 |
| 20 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { | 19 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { |
| 21 public: | 20 public: |
| 22 MockSpdyFramerVisitor(); | 21 MockSpdyFramerVisitor(); |
| 23 virtual ~MockSpdyFramerVisitor(); | 22 virtual ~MockSpdyFramerVisitor(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void(SpdyStreamId stream_id, | 68 void(SpdyStreamId stream_id, |
| 70 base::StringPiece origin, | 69 base::StringPiece origin, |
| 71 const SpdyAltSvcWireFormat::AlternativeServiceVector& | 70 const SpdyAltSvcWireFormat::AlternativeServiceVector& |
| 72 altsvc_vector)); | 71 altsvc_vector)); |
| 73 MOCK_METHOD4(OnPriority, | 72 MOCK_METHOD4(OnPriority, |
| 74 void(SpdyStreamId stream_id, | 73 void(SpdyStreamId stream_id, |
| 75 SpdyStreamId parent_stream_id, | 74 SpdyStreamId parent_stream_id, |
| 76 uint8_t weight, | 75 uint8_t weight, |
| 77 bool exclusive)); | 76 bool exclusive)); |
| 78 MOCK_METHOD2(OnUnknownFrame, bool(SpdyStreamId stream_id, int frame_type)); | 77 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_; | |
| 104 }; | 78 }; |
| 105 | 79 |
| 106 } // namespace test | 80 } // namespace test |
| 107 | 81 |
| 108 } // namespace net | 82 } // namespace net |
| 109 | 83 |
| 110 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ | 84 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ |
| OLD | NEW |