-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathtest_room.cpp
More file actions
101 lines (81 loc) · 3.24 KB
/
Copy pathtest_room.cpp
File metadata and controls
101 lines (81 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright 2025 LiveKit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include <livekit/livekit.h>
namespace livekit::test {
class RoomTest : public ::testing::Test {
protected:
void SetUp() override { livekit::initialize(livekit::LogLevel::Info); }
void TearDown() override { livekit::shutdown(); }
};
TEST_F(RoomTest, ConnectWithoutInitialize) {
// Test fixture initializes by default, do this to emulate lack of initialization
livekit::shutdown();
Room room;
bool result = room.connect("wss://localhost:7880", "test", livekit::RoomOptions());
EXPECT_FALSE(result) << "Connecting without initializing should return false";
}
TEST_F(RoomTest, CreateRoom) {
Room room;
// Room should be created without issues
EXPECT_EQ(room.localParticipant(), nullptr) << "Local participant should be null before connect";
}
TEST_F(RoomTest, RoomOptionsDefaults) {
RoomOptions options;
EXPECT_TRUE(options.auto_subscribe) << "auto_subscribe should default to true";
EXPECT_FALSE(options.dynacast) << "dynacast should default to false";
EXPECT_FALSE(options.rtc_config.has_value()) << "rtc_config should not have a value by default";
EXPECT_FALSE(options.encryption.has_value()) << "encryption should not have a value by default";
}
TEST_F(RoomTest, RtcConfigDefaults) {
RtcConfig config;
EXPECT_EQ(config.ice_transport_type, 0);
EXPECT_EQ(config.continual_gathering_policy, 0);
EXPECT_TRUE(config.ice_servers.empty());
}
TEST_F(RoomTest, IceServerConfiguration) {
IceServer server;
server.url = "stun:stun.l.google.com:19302";
server.username = "user";
server.credential = "pass";
EXPECT_EQ(server.url, "stun:stun.l.google.com:19302");
EXPECT_EQ(server.username, "user");
EXPECT_EQ(server.credential, "pass");
}
TEST_F(RoomTest, RoomWithCustomRtcConfig) {
RoomOptions options;
options.auto_subscribe = false;
options.dynacast = true;
RtcConfig rtc_config;
rtc_config.ice_servers.push_back({"stun:stun.l.google.com:19302", "", ""});
rtc_config.ice_servers.push_back({"turn:turn.example.com:3478", "user", "pass"});
options.rtc_config = rtc_config;
EXPECT_FALSE(options.auto_subscribe);
EXPECT_TRUE(options.dynacast);
EXPECT_TRUE(options.rtc_config.has_value());
EXPECT_EQ(options.rtc_config->ice_servers.size(), 2);
}
TEST_F(RoomTest, RemoteParticipantsEmptyBeforeConnect) {
Room room;
auto participants = room.remoteParticipants();
EXPECT_TRUE(participants.empty()) << "Remote participants should be empty before connect";
}
TEST_F(RoomTest, RemoteParticipantLookupBeforeConnect) {
Room room;
auto participant = room.remoteParticipant("nonexistent");
EXPECT_EQ(participant, nullptr) << "Looking up participant before connect should return nullptr";
}
} // namespace livekit::test