Skip to content

Commit

Permalink
Add basic unit test that we get ConnectionInformation in callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Moberg committed May 10, 2024
1 parent 37ef9ba commit 012277e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/TestSrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ class TestSRTFixture : public ::testing::Test {
// notice when client connects to server
mServer.clientConnected = [&](struct sockaddr& sin, SRTSOCKET newSocket,
std::shared_ptr<SRTNet::NetworkConnection>& ctx,
const SRTNet::ConnectionInformation&) {
const SRTNet::ConnectionInformation& connectionInformation) {
{
std::lock_guard<std::mutex> lock(mConnectedMutex);
mConnected = true;
}
mConnectedCondition.notify_one();
EXPECT_NE(connectionInformation.mPeerSrtVersion, SRTNet::ConnectionInformation().mPeerSrtVersion);
EXPECT_NE(connectionInformation.mNegotiatedLatency, SRTNet::ConnectionInformation().mNegotiatedLatency);
return mConnectionCtx;
};

Expand All @@ -98,6 +100,12 @@ class TestSRTFixture : public ::testing::Test {
EXPECT_EQ(ctx, mConnectionCtx);
};

mClient.connectedToServer = [&](std::shared_ptr<SRTNet::NetworkConnection>& ctx,
SRTSOCKET newSocket,
const SRTNet::ConnectionInformation& connectionInformation) {
EXPECT_NE(connectionInformation.mPeerSrtVersion, SRTNet::ConnectionInformation().mPeerSrtVersion);
EXPECT_NE(connectionInformation.mNegotiatedLatency, SRTNet::ConnectionInformation().mNegotiatedLatency);
};
}

bool waitForClientToConnect(std::chrono::seconds timeout) {
Expand Down

0 comments on commit 012277e

Please sign in to comment.