Zach Stein | e20867f | 2018-08-02 13:20:15 -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 | #include "p2p/base/basic_async_resolver_factory.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 12 | |
Zach Stein | e20867f | 2018-08-02 13:20:15 -0700 | [diff] [blame] | 13 | #include "rtc_base/gunit.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 14 | #include "rtc_base/socket_address.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 15 | #include "rtc_base/third_party/sigslot/sigslot.h" |
| 16 | #include "test/gtest.h" |
Zach Stein | e20867f | 2018-08-02 13:20:15 -0700 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 20 | class BasicAsyncResolverFactoryTest : public ::testing::Test, |
Zach Stein | e20867f | 2018-08-02 13:20:15 -0700 | [diff] [blame] | 21 | 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. |
| 45 | TEST_F(BasicAsyncResolverFactoryTest, TestCreate) { |
| 46 | TestCreate(); |
| 47 | } |
| 48 | |
| 49 | } // namespace webrtc |