MockAsyncUDPSocket.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #include <folly/io/async/AsyncUDPSocket.h>
  18. #include <folly/portability/GMock.h>
  19. namespace folly {
  20. namespace test {
  21. struct MockAsyncUDPSocket : public AsyncUDPSocket {
  22. explicit MockAsyncUDPSocket(EventBase* evb) : AsyncUDPSocket(evb) {}
  23. ~MockAsyncUDPSocket() override {}
  24. MOCK_CONST_METHOD0(address, const SocketAddress&());
  25. MOCK_METHOD1(bind, void(const SocketAddress&));
  26. MOCK_METHOD2(setFD, void(int, AsyncUDPSocket::FDOwnership));
  27. MOCK_METHOD2(
  28. write,
  29. ssize_t(const SocketAddress&, const std::unique_ptr<IOBuf>&));
  30. MOCK_METHOD3(
  31. writeGSO,
  32. ssize_t(
  33. const folly::SocketAddress&,
  34. const std::unique_ptr<folly::IOBuf>&,
  35. int));
  36. MOCK_METHOD3(
  37. writev,
  38. ssize_t(const SocketAddress&, const struct iovec*, size_t));
  39. MOCK_METHOD1(resumeRead, void(ReadCallback*));
  40. MOCK_METHOD0(pauseRead, void());
  41. MOCK_METHOD0(close, void());
  42. MOCK_CONST_METHOD0(getFD, int());
  43. MOCK_METHOD1(setReusePort, void(bool));
  44. MOCK_METHOD1(setReuseAddr, void(bool));
  45. MOCK_METHOD1(dontFragment, void(bool));
  46. MOCK_METHOD1(setErrMessageCallback, void(ErrMessageCallback*));
  47. MOCK_METHOD1(connect, int(const SocketAddress&));
  48. MOCK_CONST_METHOD0(isBound, bool());
  49. MOCK_METHOD0(getGSO, int());
  50. MOCK_METHOD1(setGSO, bool(int));
  51. };
  52. } // namespace test
  53. } // namespace folly