Skip to content

Commit f1ff6e6

Browse files
more seperated test artifacts
1 parent a04dc57 commit f1ff6e6

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2026 LiveKit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <livekit/data_track_info.h>
20+
#include <livekit/remote_data_track.h>
21+
22+
#include <cstdint>
23+
#include <memory>
24+
#include <string>
25+
#include <utility>
26+
27+
#include "data_track.pb.h"
28+
29+
namespace livekit {
30+
31+
struct RemoteDataTrackTestAccess {
32+
static uintptr_t ffiHandleId(const RemoteDataTrack& track) noexcept { return track.ffiHandleId(); }
33+
34+
static std::shared_ptr<RemoteDataTrack> create(DataTrackInfo info, std::string publisher_identity) {
35+
proto::OwnedRemoteDataTrack owned;
36+
owned.mutable_handle()->set_id(0);
37+
auto* proto_info = owned.mutable_info();
38+
proto_info->set_name(std::move(info.name));
39+
proto_info->set_sid(std::move(info.sid));
40+
proto_info->set_uses_e2ee(info.uses_e2ee);
41+
owned.set_publisher_identity(std::move(publisher_identity));
42+
return std::shared_ptr<RemoteDataTrack>(new RemoteDataTrack(owned));
43+
}
44+
};
45+
46+
} // namespace livekit

src/tests/integration/test_data_track.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <exception>
3030
#include <future>
3131

32+
#include "../common/remote_data_track_test_access.h"
3233
#include "../common/test_common.h"
3334
#include "ffi_client.h"
3435

@@ -782,8 +783,8 @@ TEST_F(DataTrackE2ETest, FfiClientSubscribeDataTrackReturnsSyncResult) {
782783
EXPECT_EQ(remote_track->info().name, expected_name);
783784

784785
const auto subscribe_start = std::chrono::steady_clock::now();
785-
auto subscribe_result =
786-
FfiClient::instance().subscribeDataTrack(static_cast<std::uint64_t>(remote_track->testFfiHandleId()));
786+
auto subscribe_result = FfiClient::instance().subscribeDataTrack(
787+
static_cast<std::uint64_t>(RemoteDataTrackTestAccess::ffiHandleId(*remote_track)));
787788
const auto subscribe_elapsed = std::chrono::steady_clock::now() - subscribe_start;
788789
const auto subscribe_elapsed_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(subscribe_elapsed).count();
789790

src/tests/unit/test_subscription_thread_dispatcher.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <unordered_map>
3131
#include <vector>
3232

33+
#include "../common/remote_data_track_test_access.h"
34+
3335
namespace livekit {
3436

3537
namespace {
@@ -636,10 +638,10 @@ TEST_F(SubscriptionThreadDispatcherTest, DuplicateSubscribeWithSameVideoSidDoesN
636638
TEST_F(SubscriptionThreadDispatcherTest, DuplicateDataPublishWithSameSidDoesNotRestartReader) {
637639
SubscriptionThreadDispatcher dispatcher;
638640
auto reader = std::make_shared<ActiveDataReader>();
639-
reader->remote_track = RemoteDataTrack::createForTest({"foo", "TR_data_1", false}, "alice");
641+
reader->remote_track = RemoteDataTrackTestAccess::create({"foo", "TR_data_1", false}, "alice");
640642
activeDataReaders(dispatcher)[7] = reader;
641643

642-
auto incoming = RemoteDataTrack::createForTest({"foo", "TR_data_1", false}, "alice");
644+
auto incoming = RemoteDataTrackTestAccess::create({"foo", "TR_data_1", false}, "alice");
643645
auto old_thread = startDataReader(dispatcher, 7, DataCallbackKey{"alice", "foo"}, incoming);
644646

645647
EXPECT_FALSE(old_thread.joinable());
@@ -651,12 +653,12 @@ TEST_F(SubscriptionThreadDispatcherTest, DuplicateDataPublishWithSameSidDoesNotR
651653
TEST_F(SubscriptionThreadDispatcherTest, RepublishWithNewDataSidStopsPreviousReader) {
652654
SubscriptionThreadDispatcher dispatcher;
653655
auto previous = std::make_shared<ActiveDataReader>();
654-
previous->remote_track = RemoteDataTrack::createForTest({"foo", "TR_data_1", false}, "alice");
656+
previous->remote_track = RemoteDataTrackTestAccess::create({"foo", "TR_data_1", false}, "alice");
655657
activeDataReaders(dispatcher)[7] = previous;
656658

657659
// A republish under the same (participant, name) but a NEW SID must stop the
658660
// previous reader and start a fresh one.
659-
auto republished = RemoteDataTrack::createForTest({"foo", "TR_data_2", false}, "alice");
661+
auto republished = RemoteDataTrackTestAccess::create({"foo", "TR_data_2", false}, "alice");
660662
auto old_thread = startDataReader(dispatcher, 7, DataCallbackKey{"alice", "foo"}, republished);
661663
if (old_thread.joinable()) {
662664
old_thread.join();

0 commit comments

Comments
 (0)