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 <cstdint> | 11 #include <cstdint> |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "net/spdy/core/spdy_framer.h" | 14 #include "net/spdy/core/spdy_framer.h" |
15 #include "net/spdy/core/spdy_test_utils.h" | 15 #include "net/spdy/core/spdy_test_utils.h" |
| 16 #include "net/spdy/platform/api/spdy_ptr_util.h" |
16 #include "net/spdy/platform/api/spdy_string_piece.h" | 17 #include "net/spdy/platform/api/spdy_string_piece.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 namespace test { | 22 namespace test { |
22 | 23 |
23 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { | 24 class MockSpdyFramerVisitor : public SpdyFramerVisitorInterface { |
24 public: | 25 public: |
25 MockSpdyFramerVisitor(); | 26 MockSpdyFramerVisitor(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 .WillByDefault(testing::Invoke( | 77 .WillByDefault(testing::Invoke( |
77 this, &MockSpdyFramerVisitor::ReturnTestHeadersHandler)); | 78 this, &MockSpdyFramerVisitor::ReturnTestHeadersHandler)); |
78 ON_CALL(*this, OnHeaderFrameEnd(testing::_, testing::_)) | 79 ON_CALL(*this, OnHeaderFrameEnd(testing::_, testing::_)) |
79 .WillByDefault(testing::Invoke( | 80 .WillByDefault(testing::Invoke( |
80 this, &MockSpdyFramerVisitor::ResetTestHeadersHandler)); | 81 this, &MockSpdyFramerVisitor::ResetTestHeadersHandler)); |
81 } | 82 } |
82 | 83 |
83 SpdyHeadersHandlerInterface* ReturnTestHeadersHandler( | 84 SpdyHeadersHandlerInterface* ReturnTestHeadersHandler( |
84 SpdyStreamId /* stream_id */) { | 85 SpdyStreamId /* stream_id */) { |
85 if (headers_handler_ == nullptr) { | 86 if (headers_handler_ == nullptr) { |
86 headers_handler_.reset(new TestHeadersHandler); | 87 headers_handler_ = SpdyMakeUnique<TestHeadersHandler>(); |
87 } | 88 } |
88 return headers_handler_.get(); | 89 return headers_handler_.get(); |
89 } | 90 } |
90 | 91 |
91 void ResetTestHeadersHandler(SpdyStreamId /* stream_id */, bool end) { | 92 void ResetTestHeadersHandler(SpdyStreamId /* stream_id */, bool end) { |
92 if (end) { | 93 if (end) { |
93 headers_handler_.reset(); | 94 headers_handler_.reset(); |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 std::unique_ptr<SpdyHeadersHandlerInterface> headers_handler_; | 98 std::unique_ptr<SpdyHeadersHandlerInterface> headers_handler_; |
98 }; | 99 }; |
99 | 100 |
100 } // namespace test | 101 } // namespace test |
101 | 102 |
102 } // namespace net | 103 } // namespace net |
103 | 104 |
104 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ | 105 #endif // NET_SPDY_MOCK_SPDY_FRAMER_VISITOR_H_ |
OLD | NEW |