Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef P2P_BASE_MOCK_ASYNC_RESOLVER_H_ |
| 12 | #define P2P_BASE_MOCK_ASYNC_RESOLVER_H_ |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 13 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 14 | #include "api/async_resolver_factory.h" |
| 15 | #include "rtc_base/async_resolver_interface.h" |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 16 | #include "test/gmock.h" |
| 17 | |
| 18 | namespace rtc { |
| 19 | |
Qingsi Wang | 0961933 | 2018-09-12 22:51:55 -0700 | [diff] [blame] | 20 | using ::testing::_; |
| 21 | using ::testing::InvokeWithoutArgs; |
| 22 | |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 23 | class MockAsyncResolver : public AsyncResolverInterface { |
| 24 | public: |
Qingsi Wang | 0961933 | 2018-09-12 22:51:55 -0700 | [diff] [blame] | 25 | MockAsyncResolver() { |
| 26 | ON_CALL(*this, Start(_)).WillByDefault(InvokeWithoutArgs([this] { |
| 27 | SignalDone(this); |
| 28 | })); |
| 29 | } |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 30 | ~MockAsyncResolver() = default; |
| 31 | |
Danil Chapovalov | b85889d | 2020-05-25 09:36:40 +0200 | [diff] [blame] | 32 | MOCK_METHOD(void, Start, (const rtc::SocketAddress&), (override)); |
Sameer Vijaykar | b787e26 | 2022-08-11 11:52:57 +0200 | [diff] [blame] | 33 | MOCK_METHOD(void, Start, (const rtc::SocketAddress&, int family), (override)); |
Danil Chapovalov | b85889d | 2020-05-25 09:36:40 +0200 | [diff] [blame] | 34 | MOCK_METHOD(bool, |
| 35 | GetResolvedAddress, |
| 36 | (int family, SocketAddress* addr), |
| 37 | (const, override)); |
| 38 | MOCK_METHOD(int, GetError, (), (const, override)); |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 39 | |
| 40 | // Note that this won't delete the object like AsyncResolverInterface says in |
| 41 | // order to avoid sanitizer failures caused by this being a synchronous |
| 42 | // implementation. The test code should delete the object instead. |
Danil Chapovalov | b85889d | 2020-05-25 09:36:40 +0200 | [diff] [blame] | 43 | MOCK_METHOD(void, Destroy, (bool), (override)); |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | } // namespace rtc |
| 47 | |
| 48 | namespace webrtc { |
| 49 | |
| 50 | class MockAsyncResolverFactory : public AsyncResolverFactory { |
| 51 | public: |
Danil Chapovalov | b85889d | 2020-05-25 09:36:40 +0200 | [diff] [blame] | 52 | MOCK_METHOD(rtc::AsyncResolverInterface*, Create, (), (override)); |
Zach Stein | 6fcdc2f | 2018-08-23 16:25:55 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace webrtc |
| 56 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 57 | #endif // P2P_BASE_MOCK_ASYNC_RESOLVER_H_ |