proxygen
MockAsyncTransport.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-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 <folly/Memory.h>
21 
22 namespace folly {
23 namespace test {
24 
26  public:
29  MOCK_CONST_METHOD0(getReadCB, ReadCallback*());
30  MOCK_METHOD4(write, void(WriteCallback*, const void*, size_t, WriteFlags));
31  MOCK_METHOD4(writev, void(WriteCallback*, const iovec*, size_t, WriteFlags));
33  writeChain,
34  void(WriteCallback*, std::shared_ptr<folly::IOBuf>, WriteFlags));
35 
36  void writeChain(
37  WriteCallback* callback,
38  std::unique_ptr<folly::IOBuf>&& iob,
39  WriteFlags flags = WriteFlags::NONE) override {
40  writeChain(callback, std::shared_ptr<folly::IOBuf>(iob.release()), flags);
41  }
42 
43  MOCK_METHOD0(close, void());
44  MOCK_METHOD0(closeNow, void());
46  MOCK_METHOD0(shutdownWrite, void());
48  MOCK_CONST_METHOD0(good, bool());
51  MOCK_CONST_METHOD0(error, bool());
65  MOCK_METHOD1(setEorTracking, void(bool));
72 };
73 
75  public:
76  MOCK_METHOD0(onReplaySafe_, void());
77  void onReplaySafe() noexcept override {
78  onReplaySafe_();
79  }
80 };
81 
83  public:
84  MOCK_METHOD2(getReadBuffer, void(void**, size_t*));
85 
86  MOCK_METHOD1(readDataAvailable_, void(size_t));
87  void readDataAvailable(size_t size) noexcept override {
88  readDataAvailable_(size);
89  }
90 
91  MOCK_METHOD0(isBufferMovable_, bool());
92  bool isBufferMovable() noexcept override {
93  return isBufferMovable_();
94  }
95 
96  MOCK_METHOD1(readBufferAvailable_, void(std::unique_ptr<folly::IOBuf>&));
98  std::unique_ptr<folly::IOBuf> readBuf) noexcept override {
99  readBufferAvailable_(readBuf);
100  }
101 
102  MOCK_METHOD0(readEOF_, void());
103  void readEOF() noexcept override {
104  readEOF_();
105  }
106 
107  MOCK_METHOD1(readErr_, void(const AsyncSocketException&));
108  void readErr(const AsyncSocketException& ex) noexcept override {
109  readErr_(ex);
110  }
111 };
112 
114  public:
115  MOCK_METHOD0(writeSuccess_, void());
116  void writeSuccess() noexcept override {
117  writeSuccess_();
118  }
119 
120  MOCK_METHOD2(writeErr_, void(size_t, const AsyncSocketException&));
121  void writeErr(size_t size, const AsyncSocketException& ex) noexcept override {
122  writeErr_(size, ex);
123  }
124 };
125 
126 } // namespace test
127 } // namespace folly
MOCK_METHOD3(writeChain, void(WriteCallback *, std::shared_ptr< folly::IOBuf >, WriteFlags))
flags
Definition: http_parser.h:127
void readBufferAvailable(std::unique_ptr< folly::IOBuf > readBuf) noexceptoverride
virtual const AsyncTransportWrapper * getWrappedTransport() const
virtual size_t getAppBytesReceived() const =0
size_t readBuf(Buf &buf, folly::io::Cursor &cursor)
Definition: Types-inl.h:220
void writeChain(WriteCallback *callback, std::unique_ptr< folly::IOBuf > &&iob, WriteFlags flags=WriteFlags::NONE) override
ReadCallback * getReadCallback() const override=0
void writeSuccess() noexceptoverride
virtual std::string getSecurityProtocol() const
MOCK_METHOD1(setReadCB, void(ReadCallback *))
virtual size_t getRawBytesWritten() const =0
virtual bool isEorTrackingEnabled() const =0
bool isBufferMovable() noexceptoverride
virtual void shutdownWrite()=0
virtual void close()=0
void readDataAvailable(size_t size) noexceptoverride
virtual uint32_t getSendTimeout() const =0
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
MOCK_CONST_METHOD1(getLocalAddress, void(folly::SocketAddress *))
virtual void setSendTimeout(uint32_t milliseconds)=0
virtual void closeNow()=0
virtual void shutdownWriteNow()=0
virtual bool good() const =0
virtual size_t getRawBytesReceived() const =0
virtual EventBase * getEventBase() const =0
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
virtual void detachEventBase()=0
void setReadCB(ReadCallback *callback) override=0
virtual bool readable() const =0
SocketAddress getPeerAddress() const
void writeErr(size_t size, const AsyncSocketException &ex) noexceptoverride
virtual bool isDetachable() const =0
virtual bool connecting() const =0
void readEOF() noexceptoverride
MOCK_CONST_METHOD0(getReadCallback, ReadCallback *())
virtual void setEorTracking(bool track)=0
SocketAddress getLocalAddress() const
virtual void closeWithReset()
const char * string
Definition: Conv.cpp:212
void writev(WriteCallback *callback, const iovec *vec, size_t count, WriteFlags flags=WriteFlags::NONE) override=0
virtual void setReplaySafetyCallback(ReplaySafetyCallback *callback)
virtual void attachEventBase(EventBase *eventBase)=0
void readErr(const AsyncSocketException &ex) noexceptoverride
#define MOCK_METHOD2(m,...)
virtual bool isReplaySafe() const
virtual bool error() const =0
void write(WriteCallback *callback, const void *buf, size_t bytes, WriteFlags flags=WriteFlags::NONE) override=0
virtual size_t getAppBytesWritten() const =0
MOCK_METHOD4(write, void(WriteCallback *, const void *, size_t, WriteFlags))