Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test
Browse files Browse the repository at this point in the history
disa6302 committed Mar 8, 2024
1 parent 507fe0d commit a99d8ab
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tst/MetricsApiTest.cpp
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ TEST_F(MetricsApiTest, webRtcIceServerGetMetrics)
STRNCPY(configuration.iceServers[1].urls, (PCHAR) "turns:54.202.170.151:443?transport=tcp", MAX_ICE_CONFIG_URI_LEN);
STRNCPY(configuration.iceServers[1].credential, (PCHAR) "username", MAX_ICE_CONFIG_CREDENTIAL_LEN);
STRNCPY(configuration.iceServers[1].username, (PCHAR) "password", MAX_ICE_CONFIG_USER_NAME_LEN);

configuration.kvsRtcConfiguration.enableIceStats = TRUE;
ASSERT_EQ(STATUS_SUCCESS, createPeerConnection(&configuration, &pRtcPeerConnection));

EXPECT_EQ(STATUS_ICE_SERVER_INDEX_INVALID, rtcPeerConnectionGetMetrics(pRtcPeerConnection, NULL, &rtcIceMetrics));
@@ -89,7 +89,7 @@ TEST_F(MetricsApiTest, webRtcIceCandidateGetMetrics)
STRNCPY(configuration.iceServers[0].urls, (PCHAR) "stun:stun.kinesisvideo.us-west-2.amazonaws.com:443", MAX_ICE_CONFIG_URI_LEN);
STRNCPY(configuration.iceServers[0].credential, (PCHAR) "", MAX_ICE_CONFIG_CREDENTIAL_LEN);
STRNCPY(configuration.iceServers[0].username, (PCHAR) "", MAX_ICE_CONFIG_USER_NAME_LEN);

configuration.kvsRtcConfiguration.enableIceStats = TRUE;
ASSERT_EQ(STATUS_SUCCESS, createPeerConnection(&configuration, &pRtcPeerConnection));

pIceAgent = ((PKvsPeerConnection) pRtcPeerConnection)->pIceAgent;
@@ -156,6 +156,36 @@ TEST_F(MetricsApiTest, webRtcIceCandidateGetMetrics)
EXPECT_EQ(STATUS_SUCCESS, freePeerConnection(&pRtcPeerConnection));
}

TEST_F(MetricsApiTest, webRtcIceServerGetMetrics_IceStatsDisabled)
{
RtcConfiguration configuration;
PRtcPeerConnection pRtcPeerConnection;
RtcStats rtcIceMetrics;
rtcIceMetrics.requestedTypeOfStats = RTC_STATS_TYPE_ICE_SERVER; // Supplying a type that is unavailable
rtcIceMetrics.rtcStatsObject.iceServerStats.iceServerIndex = 5;

MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration));
MEMSET(&rtcIceMetrics.rtcStatsObject.iceServerStats, 0x00, SIZEOF(RtcIceServerStats));
STRNCPY(configuration.iceServers[0].urls, (PCHAR) "stun:stun.kinesisvideo.us-west-2.amazonaws.com:443", MAX_ICE_CONFIG_URI_LEN);
STRNCPY(configuration.iceServers[0].credential, (PCHAR) "", MAX_ICE_CONFIG_CREDENTIAL_LEN);
STRNCPY(configuration.iceServers[0].username, (PCHAR) "", MAX_ICE_CONFIG_USER_NAME_LEN);

STRNCPY(configuration.iceServers[1].urls, (PCHAR) "turns:54.202.170.151:443?transport=tcp", MAX_ICE_CONFIG_URI_LEN);
STRNCPY(configuration.iceServers[1].credential, (PCHAR) "username", MAX_ICE_CONFIG_CREDENTIAL_LEN);
STRNCPY(configuration.iceServers[1].username, (PCHAR) "password", MAX_ICE_CONFIG_USER_NAME_LEN);
configuration.kvsRtcConfiguration.enableIceStats = FALSE;
ASSERT_EQ(STATUS_SUCCESS, createPeerConnection(&configuration, &pRtcPeerConnection));

rtcIceMetrics.rtcStatsObject.iceServerStats.iceServerIndex = 1;
EXPECT_EQ(STATUS_SUCCESS, rtcPeerConnectionGetMetrics(pRtcPeerConnection, NULL, &rtcIceMetrics));
EXPECT_EQ(0, rtcIceMetrics.rtcStatsObject.iceServerStats.port);
EXPECT_EQ('\0', rtcIceMetrics.rtcStatsObject.iceServerStats.url[0]);
EXPECT_EQ('\0', rtcIceMetrics.rtcStatsObject.iceServerStats.protocol[0]);

EXPECT_EQ(STATUS_SUCCESS, closePeerConnection(pRtcPeerConnection));
EXPECT_EQ(STATUS_SUCCESS, freePeerConnection(&pRtcPeerConnection));
}

} // namespace webrtcclient
} // namespace video
} // namespace kinesis

0 comments on commit a99d8ab

Please sign in to comment.