xref: /aosp_15_r20/external/webrtc/api/test/mock_async_dns_resolver.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2021 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 
11 #ifndef API_TEST_MOCK_ASYNC_DNS_RESOLVER_H_
12 #define API_TEST_MOCK_ASYNC_DNS_RESOLVER_H_
13 
14 #include <functional>
15 #include <memory>
16 
17 #include "api/async_dns_resolver.h"
18 #include "test/gmock.h"
19 
20 namespace webrtc {
21 
22 class MockAsyncDnsResolverResult : public AsyncDnsResolverResult {
23  public:
24   MOCK_METHOD(bool,
25               GetResolvedAddress,
26               (int, rtc::SocketAddress*),
27               (const, override));
28   MOCK_METHOD(int, GetError, (), (const, override));
29 };
30 
31 class MockAsyncDnsResolver : public AsyncDnsResolverInterface {
32  public:
33   MOCK_METHOD(void,
34               Start,
35               (const rtc::SocketAddress&, std::function<void()>),
36               (override));
37   MOCK_METHOD(void,
38               Start,
39               (const rtc::SocketAddress&, int family, std::function<void()>),
40               (override));
41   MOCK_METHOD(AsyncDnsResolverResult&, result, (), (const, override));
42 };
43 
44 class MockAsyncDnsResolverFactory : public AsyncDnsResolverFactoryInterface {
45  public:
46   MOCK_METHOD(std::unique_ptr<webrtc::AsyncDnsResolverInterface>,
47               CreateAndResolve,
48               (const rtc::SocketAddress&, std::function<void()>),
49               (override));
50   MOCK_METHOD(std::unique_ptr<webrtc::AsyncDnsResolverInterface>,
51               CreateAndResolve,
52               (const rtc::SocketAddress&, int, std::function<void()>),
53               (override));
54   MOCK_METHOD(std::unique_ptr<webrtc::AsyncDnsResolverInterface>,
55               Create,
56               (),
57               (override));
58 };
59 
60 }  // namespace webrtc
61 
62 #endif  // API_TEST_MOCK_ASYNC_DNS_RESOLVER_H_
63