blob: 28625995fec5304d3b9999da36b48e95fadcc0c9 [file] [log] [blame]
Harald Alvestrand4241cf52019-01-21 08:29:421/*
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 Alvestrand4241cf52019-01-21 08:29:4212
Harald Alvestrand98462622019-01-30 13:57:0313#include <memory>
14#include <utility>
Harald Alvestrand98462622019-01-30 13:57:0315
Harald Alvestrand98462622019-01-30 13:57:0316#include "api/ice_transport_factory.h"
Harald Alvestrandc24a2182022-02-23 13:44:5917#include "api/scoped_refptr.h"
Harald Alvestrand98462622019-01-30 13:57:0318#include "p2p/base/fake_ice_transport.h"
19#include "p2p/base/fake_port_allocator.h"
Harald Alvestrandc24a2182022-02-23 13:44:5920#include "rtc_base/ref_counted_object.h"
Harald Alvestrand4241cf52019-01-21 08:29:4221#include "test/gtest.h"
22
23namespace webrtc {
24
Niels Möller83830f32022-05-20 07:12:5725class IceTransportTest : public ::testing::Test {
26 private:
27 rtc::AutoThread main_thread_;
28};
Harald Alvestrand4241cf52019-01-21 08:29:4229
Harald Alvestrand98462622019-01-30 13:57:0330TEST_F(IceTransportTest, CreateNonSelfDeletingTransport) {
31 auto cricket_transport =
Mirko Bonadei317a1f02019-09-17 15:06:1832 std::make_unique<cricket::FakeIceTransport>("name", 0, nullptr);
Tommi87f70902021-04-27 12:43:0833 auto ice_transport =
34 rtc::make_ref_counted<IceTransportWithPointer>(cricket_transport.get());
Harald Alvestrand98462622019-01-30 13:57:0335 EXPECT_EQ(ice_transport->internal(), cricket_transport.get());
36 ice_transport->Clear();
37 EXPECT_NE(ice_transport->internal(), cricket_transport.get());
38}
39
40TEST_F(IceTransportTest, CreateSelfDeletingTransport) {
41 std::unique_ptr<cricket::FakePortAllocator> port_allocator(
Mirko Bonadei317a1f02019-09-17 15:06:1842 std::make_unique<cricket::FakePortAllocator>(nullptr, nullptr));
Steve Anton6fdfec12019-07-01 21:07:3343 IceTransportInit init;
44 init.set_port_allocator(port_allocator.get());
45 auto ice_transport = CreateIceTransport(std::move(init));
Harald Alvestrand98462622019-01-30 13:57:0346 EXPECT_NE(nullptr, ice_transport->internal());
Harald Alvestrand4241cf52019-01-21 08:29:4247}
48
49} // namespace webrtc