blob: 0c21c682fbee531e133c5680f8215204af17f3df [file] [log] [blame]
Zach Steine20867f2018-08-02 13:20:15 -07001/*
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 Anton10542f22019-01-11 09:11:00 -080011#include "p2p/base/basic_async_resolver_factory.h"
Yves Gerey3e707812018-11-28 16:47:49 +010012
Zach Steine20867f2018-08-02 13:20:15 -070013#include "rtc_base/gunit.h"
Steve Anton10542f22019-01-11 09:11:00 -080014#include "rtc_base/socket_address.h"
Yves Gerey3e707812018-11-28 16:47:49 +010015#include "rtc_base/third_party/sigslot/sigslot.h"
16#include "test/gtest.h"
Zach Steine20867f2018-08-02 13:20:15 -070017
18namespace webrtc {
19
Mirko Bonadei6a489f22019-04-09 15:11:12 +020020class BasicAsyncResolverFactoryTest : public ::testing::Test,
Zach Steine20867f2018-08-02 13:20:15 -070021 public sigslot::has_slots<> {
22 public:
23 void TestCreate() {
24 BasicAsyncResolverFactory factory;
25 rtc::AsyncResolverInterface* resolver = factory.Create();
26 ASSERT_TRUE(resolver);
27 resolver->SignalDone.connect(
28 this, &BasicAsyncResolverFactoryTest::SetAddressResolved);
29
30 rtc::SocketAddress address("", 0);
31 resolver->Start(address);
32 ASSERT_TRUE_WAIT(address_resolved_, 10000 /*ms*/);
33 }
34
35 void SetAddressResolved(rtc::AsyncResolverInterface* resolver) {
36 address_resolved_ = true;
37 }
38
39 private:
40 bool address_resolved_ = false;
41};
42
43// This test is primarily intended to let tools check that the created resolver
44// doesn't leak.
45TEST_F(BasicAsyncResolverFactoryTest, TestCreate) {
46 TestCreate();
47}
48
49} // namespace webrtc