-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from ant-media/release-1.4.0
Increase test code coverage
- Loading branch information
Showing
5 changed files
with
197 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/java/io/antmedia/test/webrtc/adaptor/WebRTCClientStatsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.antmedia.test.webrtc.adaptor; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
import io.antmedia.rest.WebRTCClientStats; | ||
|
||
public class WebRTCClientStatsTest { | ||
|
||
@Test | ||
public void testStatsClass() { | ||
int measuredBitrate = (int)(Math.random() * 999999); | ||
int sendBitrate = (int)(Math.random() * 999999); | ||
double videoFrameSendPeriod = (Math.random() * 9999); | ||
double audioFrameSendPeriod = (Math.random() * 999999); | ||
double videoThreadCheckInterval = (Math.random() * 9999); | ||
double audioThreadCheckInterval = (Math.random() * 9999); | ||
WebRTCClientStats clientStats = new WebRTCClientStats(measuredBitrate, sendBitrate, videoFrameSendPeriod, audioFrameSendPeriod, videoThreadCheckInterval, audioThreadCheckInterval); | ||
|
||
assertEquals(measuredBitrate, clientStats.getMeasuredBitrate()); | ||
assertEquals(sendBitrate, clientStats.getSendBitrate()); | ||
assertEquals(videoFrameSendPeriod, clientStats.getVideoFrameSendPeriod(), 0.02); | ||
assertEquals(audioFrameSendPeriod, clientStats.getAudioFrameSendPeriod(), 0.02); | ||
assertEquals(videoThreadCheckInterval, clientStats.getVideoThreadCheckInterval(), 0.02); | ||
assertEquals(audioThreadCheckInterval, clientStats.getAudioThreadCheckInterval(), 0.02); | ||
|
||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/test/java/io/antmedia/test/webrtc/adaptor/WebSocketClientConnectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.antmedia.test.webrtc.adaptor; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.red5.net.websocket.WebSocketConnection; | ||
|
||
import io.antmedia.webrtc.WebSocketClientConnection; | ||
|
||
public class WebSocketClientConnectionTest { | ||
|
||
|
||
@Test | ||
public void testWebSocketClientConnection() { | ||
WebSocketConnection wsConnection = Mockito.mock(WebSocketConnection.class); | ||
|
||
long value = (int)(Math.random() * 1000); | ||
|
||
Mockito.when(wsConnection.getId()).thenReturn(value); | ||
|
||
WebSocketClientConnection connection = new WebSocketClientConnection(wsConnection); | ||
|
||
String data = "any data"; | ||
connection.send(data); | ||
|
||
try { | ||
Mockito.verify(wsConnection).send(data); | ||
} catch (UnsupportedEncodingException e) { | ||
e.printStackTrace(); | ||
fail(e.getMessage()); | ||
} | ||
|
||
assertEquals(String.valueOf(value), connection.getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,4 +191,5 @@ public void testPublishAndStopCommand() { | |
|
||
verify(rtmpAdaptor).stop(); | ||
} | ||
|
||
} |