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;
33 # pragma clang diagnostic push
34 # if __clang_major__ > 3 || __clang_minor__ >= 6
35 # pragma clang diagnostic ignored "-Winconsistent-missing-override"
39 MOCK_METHOD2_T(read_, void(Context*, Rin&));
40 MOCK_METHOD1_T(readEOF, void(Context*));
41 MOCK_METHOD2_T(readException, void(Context*, exception_wrapper));
43 MOCK_METHOD2_T(write_, void(Context*, Win&));
44 MOCK_METHOD1_T(close_, void(Context*));
46 MOCK_METHOD1_T(attachPipeline, void(Context*));
47 MOCK_METHOD1_T(attachTransport, void(Context*));
48 MOCK_METHOD1_T(detachPipeline, void(Context*));
49 MOCK_METHOD1_T(detachTransport, void(Context*));
52 #pragma clang diagnostic pop
55 void read(Context* ctx, Rin msg) override {
59 Future<void> write(Context* ctx, Win msg) override {
60 return makeFutureWith([&](){
65 Future<void> close(Context* ctx) override {
66 return makeFutureWith([&](){
72 template <class R, class W = R>
73 using MockHandlerAdapter = MockHandler<R, R, W, W>;