2 * Copyright 2015 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/wangle/channel/Handler.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 MockHandler : public Handler<Rin, Rout, Win, Wout> {
27 typedef typename Handler<Rin, Rout, Win, Wout>::Context Context;
29 MockHandler() = default;
30 MockHandler(MockHandler&&) = 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) override {
48 Future<void> write(Context* ctx, Win msg) override {
49 return makeFutureWith([&](){
54 Future<void> close(Context* ctx) override {
55 return makeFutureWith([&](){
61 template <class R, class W = R>
62 using MockHandlerAdapter = MockHandler<R, R, W, W>;