2 * Copyright 2014 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <folly/experimental/wangle/channel/ChannelHandler.h>
20 #include <gmock/gmock.h>
22 namespace folly { namespace wangle {
24 template <class Rin, class Rout = Rin, class Win = Rout, class Wout = Rin>
25 class MockChannelHandler : public ChannelHandler<Rin, Rout, Win, Wout> {
27 typedef typename ChannelHandler<Rin, Rout, Win, Wout>::Context Context;
29 MockChannelHandler() = default;
30 MockChannelHandler(MockChannelHandler&&) = default;
32 MOCK_METHOD2_T(read_, void(Context*, Rin&));
33 MOCK_METHOD1_T(readEOF, void(Context*));
34 MOCK_METHOD2_T(readException, void(Context*, exception_wrapper));
36 MOCK_METHOD2_T(write_, void(Context*, Win&));
37 MOCK_METHOD1_T(close_, void(Context*));
39 MOCK_METHOD1_T(attachPipeline, void(Context*));
40 MOCK_METHOD1_T(attachTransport, void(Context*));
41 MOCK_METHOD1_T(detachPipeline, void(Context*));
42 MOCK_METHOD1_T(detachTransport, void(Context*));
44 void read(Context* ctx, Rin msg) {
48 Future<void> write(Context* ctx, Win msg) override {
49 return makeFutureTry([&](){
54 Future<void> close(Context* ctx) override {
55 return makeFutureTry([&](){
61 template <class R, class W = R>
62 using MockChannelHandlerAdapter = MockChannelHandler<R, R, W, W>;