Harald Alvestrand | 4241cf5 | 2019-01-21 09:29:42 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 "pc/ice_transport.h" |
Harald Alvestrand | 4241cf5 | 2019-01-21 09:29:42 +0100 | [diff] [blame] | 12 | |
Harald Alvestrand | 9846262 | 2019-01-30 14:57:03 +0100 | [diff] [blame] | 13 | #include <memory> |
| 14 | #include <utility> |
| 15 | #include <vector> |
| 16 | |
Harald Alvestrand | 9846262 | 2019-01-30 14:57:03 +0100 | [diff] [blame] | 17 | #include "api/ice_transport_factory.h" |
| 18 | #include "p2p/base/fake_ice_transport.h" |
| 19 | #include "p2p/base/fake_port_allocator.h" |
| 20 | #include "rtc_base/gunit.h" |
| 21 | #include "test/gmock.h" |
Harald Alvestrand | 4241cf5 | 2019-01-21 09:29:42 +0100 | [diff] [blame] | 22 | #include "test/gtest.h" |
| 23 | |
| 24 | namespace webrtc { |
| 25 | |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 26 | class IceTransportTest : public ::testing::Test {}; |
Harald Alvestrand | 4241cf5 | 2019-01-21 09:29:42 +0100 | [diff] [blame] | 27 | |
Harald Alvestrand | 9846262 | 2019-01-30 14:57:03 +0100 | [diff] [blame] | 28 | TEST_F(IceTransportTest, CreateNonSelfDeletingTransport) { |
| 29 | auto cricket_transport = |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 30 | std::make_unique<cricket::FakeIceTransport>("name", 0, nullptr); |
Harald Alvestrand | 9846262 | 2019-01-30 14:57:03 +0100 | [diff] [blame] | 31 | rtc::scoped_refptr<IceTransportWithPointer> ice_transport = |
| 32 | new rtc::RefCountedObject<IceTransportWithPointer>( |
| 33 | cricket_transport.get()); |
| 34 | EXPECT_EQ(ice_transport->internal(), cricket_transport.get()); |
| 35 | ice_transport->Clear(); |
| 36 | EXPECT_NE(ice_transport->internal(), cricket_transport.get()); |
| 37 | } |
| 38 | |
| 39 | TEST_F(IceTransportTest, CreateSelfDeletingTransport) { |
| 40 | std::unique_ptr<cricket::FakePortAllocator> port_allocator( |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 41 | std::make_unique<cricket::FakePortAllocator>(nullptr, nullptr)); |
Steve Anton | 6fdfec1 | 2019-07-01 14:07:33 -0700 | [diff] [blame] | 42 | IceTransportInit init; |
| 43 | init.set_port_allocator(port_allocator.get()); |
| 44 | auto ice_transport = CreateIceTransport(std::move(init)); |
Harald Alvestrand | 9846262 | 2019-01-30 14:57:03 +0100 | [diff] [blame] | 45 | EXPECT_NE(nullptr, ice_transport->internal()); |
Harald Alvestrand | 4241cf5 | 2019-01-21 09:29:42 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | } // namespace webrtc |