You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2018 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef P2P_BASE_MOCK_ASYNC_RESOLVER_H_
  11. #define P2P_BASE_MOCK_ASYNC_RESOLVER_H_
  12. #include "api/async_resolver_factory.h"
  13. #include "rtc_base/async_resolver_interface.h"
  14. #include "test/gmock.h"
  15. namespace rtc {
  16. using ::testing::_;
  17. using ::testing::InvokeWithoutArgs;
  18. class MockAsyncResolver : public AsyncResolverInterface {
  19. public:
  20. MockAsyncResolver() {
  21. ON_CALL(*this, Start(_)).WillByDefault(InvokeWithoutArgs([this] {
  22. SignalDone(this);
  23. }));
  24. }
  25. ~MockAsyncResolver() = default;
  26. MOCK_METHOD1(Start, void(const rtc::SocketAddress&));
  27. MOCK_CONST_METHOD2(GetResolvedAddress, bool(int family, SocketAddress* addr));
  28. MOCK_CONST_METHOD0(GetError, int());
  29. // Note that this won't delete the object like AsyncResolverInterface says in
  30. // order to avoid sanitizer failures caused by this being a synchronous
  31. // implementation. The test code should delete the object instead.
  32. MOCK_METHOD1(Destroy, void(bool));
  33. };
  34. } // namespace rtc
  35. namespace webrtc {
  36. class MockAsyncResolverFactory : public AsyncResolverFactory {
  37. public:
  38. MOCK_METHOD0(Create, rtc::AsyncResolverInterface*());
  39. };
  40. } // namespace webrtc
  41. #endif // P2P_BASE_MOCK_ASYNC_RESOLVER_H_