1919
2020namespace livekit ::test {
2121
22- class RoomTest : public ::testing::Test {
23- protected:
24- void SetUp () override { livekit::initialize (livekit::LogLevel::Info, livekit::LogSink::kConsole ); }
25-
26- void TearDown () override { livekit::shutdown (); }
27- };
28-
29- TEST_F (RoomTest, CreateRoom) {
30- Room room;
31- // Room should be created without issues
32- EXPECT_EQ (room.localParticipant (), nullptr ) << " Local participant should be null before connect" ;
33- }
34-
35- TEST_F (RoomTest, RoomOptionsDefaults) {
36- RoomOptions options;
37-
38- EXPECT_TRUE (options.auto_subscribe ) << " auto_subscribe should default to true" ;
39- EXPECT_FALSE (options.dynacast ) << " dynacast should default to false" ;
40- EXPECT_FALSE (options.rtc_config .has_value ()) << " rtc_config should not have a value by default" ;
41- EXPECT_FALSE (options.encryption .has_value ()) << " encryption should not have a value by default" ;
42- }
43-
44- TEST_F (RoomTest, RtcConfigDefaults) {
45- RtcConfig config;
46-
47- EXPECT_EQ (config.ice_transport_type , 0 );
48- EXPECT_EQ (config.continual_gathering_policy , 0 );
49- EXPECT_TRUE (config.ice_servers .empty ());
50- }
51-
52- TEST_F (RoomTest, IceServerConfiguration) {
53- IceServer server;
54- server.url = " stun:stun.l.google.com:19302" ;
55- server.username = " user" ;
56- server.credential = " pass" ;
57-
58- EXPECT_EQ (server.url , " stun:stun.l.google.com:19302" );
59- EXPECT_EQ (server.username , " user" );
60- EXPECT_EQ (server.credential , " pass" );
61- }
62-
63- TEST_F (RoomTest, RoomWithCustomRtcConfig) {
64- RoomOptions options;
65- options.auto_subscribe = false ;
66- options.dynacast = true ;
67-
68- RtcConfig rtc_config;
69- rtc_config.ice_servers .push_back ({" stun:stun.l.google.com:19302" , " " , " " });
70- rtc_config.ice_servers .push_back ({" turn:turn.example.com:3478" , " user" , " pass" });
71-
72- options.rtc_config = rtc_config;
73-
74- EXPECT_FALSE (options.auto_subscribe );
75- EXPECT_TRUE (options.dynacast );
76- EXPECT_TRUE (options.rtc_config .has_value ());
77- EXPECT_EQ (options.rtc_config ->ice_servers .size (), 2 );
78- }
79-
80- TEST_F (RoomTest, RemoteParticipantsEmptyBeforeConnect) {
81- Room room;
82- auto participants = room.remoteParticipants ();
83- EXPECT_TRUE (participants.empty ()) << " Remote participants should be empty before connect" ;
84- }
85-
86- TEST_F (RoomTest, RemoteParticipantLookupBeforeConnect) {
87- Room room;
88- auto participant = room.remoteParticipant (" nonexistent" );
89- EXPECT_EQ (participant, nullptr ) << " Looking up participant before connect should return nullptr" ;
90- }
91-
9222// Server-dependent tests - require LIVEKIT_URL and LIVEKIT_TOKEN_A env vars
93- class RoomServerTest : public ::testing::Test {
23+ class RoomTest : public ::testing::Test {
9424protected:
9525 void SetUp () override {
9626 livekit::initialize (livekit::LogLevel::Info, livekit::LogSink::kConsole );
@@ -112,12 +42,7 @@ class RoomServerTest : public ::testing::Test {
11242 std::string token_;
11343};
11444
115- TEST_F (RoomServerTest, ConnectToServer) {
116- if (!server_available_) {
117- GTEST_SKIP () << " LIVEKIT_URL and LIVEKIT_TOKEN_A not set, skipping server "
118- " connection test" ;
119- }
120-
45+ TEST_F (RoomTest, ConnectToServer) {
12146 Room room;
12247 RoomOptions options;
12348
@@ -129,19 +54,15 @@ TEST_F(RoomServerTest, ConnectToServer) {
12954 }
13055}
13156
132- TEST_F (RoomServerTest, ConnectWithInvalidToken) {
133- if (!server_available_) {
134- GTEST_SKIP () << " LIVEKIT_URL not set, skipping invalid token test" ;
135- }
136-
57+ TEST_F (RoomTest, ConnectWithInvalidToken) {
13758 Room room;
13859 RoomOptions options;
13960
14061 bool connected = room.Connect (server_url_, " invalid_token" , options);
14162 EXPECT_FALSE (connected) << " Should fail to connect with invalid token" ;
14263}
14364
144- TEST_F (RoomServerTest , ConnectWithInvalidUrl) {
65+ TEST_F (RoomTest , ConnectWithInvalidUrl) {
14566 Room room;
14667 RoomOptions options;
14768
0 commit comments