blob: a801bbae35af3ccc1da2b3038315bc3e8c1632f6 [file] [log] [blame]
Harald Alvestrand4241cf52019-01-21 09:29:42 +01001/*
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 09:29:42 +010012
Harald Alvestrand98462622019-01-30 14:57:03 +010013#include <memory>
14#include <utility>
15#include <vector>
16
17#include "absl/memory/memory.h"
18#include "api/ice_transport_factory.h"
19#include "p2p/base/fake_ice_transport.h"
20#include "p2p/base/fake_port_allocator.h"
21#include "rtc_base/gunit.h"
22#include "test/gmock.h"
Harald Alvestrand4241cf52019-01-21 09:29:42 +010023#include "test/gtest.h"
24
25namespace webrtc {
26
Mirko Bonadei6a489f22019-04-09 15:11:12 +020027class IceTransportTest : public ::testing::Test {};
Harald Alvestrand4241cf52019-01-21 09:29:42 +010028
Harald Alvestrand98462622019-01-30 14:57:03 +010029TEST_F(IceTransportTest, CreateNonSelfDeletingTransport) {
30 auto cricket_transport =
31 absl::make_unique<cricket::FakeIceTransport>("name", 0, nullptr);
32 rtc::scoped_refptr<IceTransportWithPointer> ice_transport =
33 new rtc::RefCountedObject<IceTransportWithPointer>(
34 cricket_transport.get());
35 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(
42 absl::make_unique<cricket::FakePortAllocator>(nullptr, nullptr));
Steve Anton6fdfec12019-07-01 14:07:33 -070043 IceTransportInit init;
44 init.set_port_allocator(port_allocator.get());
45 auto ice_transport = CreateIceTransport(std::move(init));
Harald Alvestrand98462622019-01-30 14:57:03 +010046 EXPECT_NE(nullptr, ice_transport->internal());
Harald Alvestrand4241cf52019-01-21 09:29:42 +010047}
48
49} // namespace webrtc