mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00

Already implemented for STUN hostname resolution, but TURN port resolves hostnames separately. Reusing the field trial key reserved in bugs.webrtc.org/14334 but with a new parameter so as to not affect ongoing rollouts. Bug: webrtc:14319, webrtc:14131 Change-Id: Idf771fb2f0de7849f8b701be8ee05a98b8d242f3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285981 Reviewed-by: Jonas Oreland <jonaso@webrtc.org> Commit-Queue: Sameer Vijaykar <samvi@google.com> Cr-Commit-Position: refs/heads/main@{#38811}
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef P2P_BASE_MOCK_DNS_RESOLVING_PACKET_SOCKET_FACTORY_H_
|
|
#define P2P_BASE_MOCK_DNS_RESOLVING_PACKET_SOCKET_FACTORY_H_
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
#include "api/test/mock_async_dns_resolver.h"
|
|
#include "p2p/base/basic_packet_socket_factory.h"
|
|
|
|
namespace rtc {
|
|
|
|
// A PacketSocketFactory implementation for tests that uses a mock DnsResolver
|
|
// and allows setting expectations on the resolver and results.
|
|
class MockDnsResolvingPacketSocketFactory : public BasicPacketSocketFactory {
|
|
public:
|
|
using Expectations = std::function<void(webrtc::MockAsyncDnsResolver*,
|
|
webrtc::MockAsyncDnsResolverResult*)>;
|
|
|
|
explicit MockDnsResolvingPacketSocketFactory(SocketFactory* socket_factory)
|
|
: BasicPacketSocketFactory(socket_factory) {}
|
|
|
|
std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAsyncDnsResolver()
|
|
override {
|
|
std::unique_ptr<webrtc::MockAsyncDnsResolver> resolver =
|
|
std::make_unique<webrtc::MockAsyncDnsResolver>();
|
|
if (expectations_) {
|
|
expectations_(resolver.get(), &resolver_result_);
|
|
}
|
|
return resolver;
|
|
}
|
|
|
|
void SetExpectations(Expectations expectations) {
|
|
expectations_ = expectations;
|
|
}
|
|
|
|
private:
|
|
webrtc::MockAsyncDnsResolverResult resolver_result_;
|
|
Expectations expectations_;
|
|
};
|
|
|
|
} // namespace rtc
|
|
|
|
#endif // P2P_BASE_MOCK_DNS_RESOLVING_PACKET_SOCKET_FACTORY_H_
|