• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "p2p/base/basic_async_resolver_factory.h"
12 
13 #include "rtc_base/gunit.h"
14 #include "rtc_base/socket_address.h"
15 #include "rtc_base/third_party/sigslot/sigslot.h"
16 #include "test/gtest.h"
17 
18 namespace webrtc {
19 
20 class BasicAsyncResolverFactoryTest : public ::testing::Test,
21                                       public sigslot::has_slots<> {
22  public:
TestCreate()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     resolver->Destroy(false);
34   }
35 
SetAddressResolved(rtc::AsyncResolverInterface * resolver)36   void SetAddressResolved(rtc::AsyncResolverInterface* resolver) {
37     address_resolved_ = true;
38   }
39 
40  private:
41   bool address_resolved_ = false;
42 };
43 
44 // This test is primarily intended to let tools check that the created resolver
45 // doesn't leak.
TEST_F(BasicAsyncResolverFactoryTest,TestCreate)46 TEST_F(BasicAsyncResolverFactoryTest, TestCreate) {
47   TestCreate();
48 }
49 
50 }  // namespace webrtc
51