proxygen
AcceptorHelperMocks.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #pragma once
17 
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20 #include <thread>
21 
23 
24 template <class T>
26 
27 template <class T>
29 
30 template <
31  template <class> class UniquePtrTranslationPolicy = UseSharedPtrPolicy>
34  public UniquePtrTranslationPolicy<
35  MockHandshakeHelperCallback<UniquePtrTranslationPolicy>> {
36  public:
38  connectionError_,
39  void(
47  connectionError_(transport, ex, sslErr);
48  }
49 
52  std::string nextProtocol,
53  SecureTransportType secureTransportType,
55  MockHandshakeHelperCallback::dispatchConnectionReady(
56  std::move(transport),
57  std::move(nextProtocol),
58  secureTransportType,
59  std::move(sslErr));
60  }
61 };
62 
63 template <
64  template <class> class UniquePtrTranslationPolicy = UseSharedPtrPolicy>
67  public UniquePtrTranslationPolicy<
68  MockHandshakeHelper<UniquePtrTranslationPolicy>> {
69  public:
70  void start(
72  AcceptorHandshakeHelper::Callback* callback) noexcept override {
73  MockHandshakeHelper::dispatchStart(std::move(sock), callback);
74  }
75 
76  MOCK_METHOD1(dropConnection, void(wangle::SSLErrorEnum reason));
77 };
78 
79 template <template <class> class P>
81  public:
83  startInternal,
84  void(
85  std::shared_ptr<folly::AsyncSSLSocket>,
87 
91  startInternal(
92  std::shared_ptr<folly::AsyncSSLSocket>(std::move(sock)), callback);
93  }
94 };
95 
96 template <template <class> class P>
98  public:
100  startInternal,
102 
106  startInternal(sock.release(), callback);
107  }
108 };
109 
110 template <template <class> class P>
112  MOCK_METHOD4(
113  connectionReadyInternal,
114  void(
115  std::shared_ptr<folly::AsyncTransportWrapper>,
116  std::string,
119 
122  std::string nextProtocol,
123  SecureTransportType secureTransportType,
125  connectionReadyInternal(
126  std::move(transport),
127  std::move(nextProtocol),
128  secureTransportType,
129  std::move(sslErr));
130  }
131 };
132 
133 template <template <class> class P>
135  MOCK_METHOD4(
136  connectionReadyInternalRaw,
137  void(
139  std::string,
142 
145  std::string nextProtocol,
146  SecureTransportType secureTransportType,
148  connectionReadyInternalRaw(
149  transport.release(),
150  std::move(nextProtocol),
151  secureTransportType,
152  std::move(sslErr));
153  }
154 };
#define MOCK_METHOD4(m,...)
void start(folly::AsyncSSLSocket::UniquePtr sock, AcceptorHandshakeHelper::Callback *callback) noexceptoverride
SSLErrorEnum
Definition: SSLUtil.h:42
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void dispatchStart(folly::AsyncSSLSocket::UniquePtr sock, wangle::AcceptorHandshakeHelper::Callback *callback) noexcept
void connectionReady(folly::AsyncTransportWrapper::UniquePtr transport, std::string nextProtocol, SecureTransportType secureTransportType, folly::Optional< wangle::SSLErrorEnum > sslErr) noexceptoverride
requires E e noexcept(noexcept(s.error(std::move(e))))
MOCK_METHOD3(connectionError_, void(folly::AsyncTransportWrapper *, folly::exception_wrapper, folly::Optional< wangle::SSLErrorEnum >))
void dispatchConnectionReady(folly::AsyncTransportWrapper::UniquePtr transport, std::string nextProtocol, SecureTransportType secureTransportType, folly::Optional< wangle::SSLErrorEnum > sslErr)
std::unique_ptr< AsyncSSLSocket, Destructor > UniquePtr
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
void dispatchStart(folly::AsyncSSLSocket::UniquePtr sock, wangle::AcceptorHandshakeHelper::Callback *callback) noexcept
void connectionError(folly::AsyncTransportWrapper *transport, folly::exception_wrapper ex, folly::Optional< wangle::SSLErrorEnum > sslErr) noexceptoverride
#define MOCK_METHOD1(m,...)
const char * string
Definition: Conv.cpp:212
void dispatchConnectionReady(folly::AsyncTransportWrapper::UniquePtr transport, std::string nextProtocol, SecureTransportType secureTransportType, folly::Optional< wangle::SSLErrorEnum > sslErr)
#define MOCK_METHOD2(m,...)