Split unit tests out of end-to-end PeerConnection test.
Splits PeerConnectionTest.java into 4 files: - PeerConnectionEndToEndTest.java - PeerConnectionTest.java - RtpTranceiverTest.java - VideoTrackTest.java Also deletes some dead code. Bug: None Change-Id: I9b81fec042bc6be261e3010ec5a30baf6d7211bf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161680 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30056}
This commit is contained in:
parent
a3ecb7a656
commit
947a380b81
@ -1380,16 +1380,19 @@ if (is_android) {
|
||||
"instrumentationtests/src/org/webrtc/LoggableTest.java",
|
||||
"instrumentationtests/src/org/webrtc/MediaCodecVideoEncoderTest.java",
|
||||
"instrumentationtests/src/org/webrtc/NetworkMonitorTest.java",
|
||||
"instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java",
|
||||
"instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java",
|
||||
"instrumentationtests/src/org/webrtc/PeerConnectionTest.java",
|
||||
"instrumentationtests/src/org/webrtc/RendererCommonTest.java",
|
||||
"instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java",
|
||||
"instrumentationtests/src/org/webrtc/RtpTranceiverTest.java",
|
||||
"instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java",
|
||||
"instrumentationtests/src/org/webrtc/SurfaceViewRendererOnMeasureTest.java",
|
||||
"instrumentationtests/src/org/webrtc/TestConstants.java",
|
||||
"instrumentationtests/src/org/webrtc/TimestampAlignerTest.java",
|
||||
"instrumentationtests/src/org/webrtc/VideoFileRendererTest.java",
|
||||
"instrumentationtests/src/org/webrtc/VideoFrameBufferTest.java",
|
||||
"instrumentationtests/src/org/webrtc/TimestampAlignerTest.java",
|
||||
"instrumentationtests/src/org/webrtc/VideoTrackTest.java",
|
||||
"instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java",
|
||||
"instrumentationtests/src/org/webrtc/YuvHelperTest.java",
|
||||
]
|
||||
@ -1411,6 +1414,7 @@ if (is_android) {
|
||||
"//third_party/android_support_test_runner:runner_java",
|
||||
"//third_party/google-truth:google_truth_java",
|
||||
"//third_party/junit",
|
||||
"//third_party/mockito:mockito_java",
|
||||
]
|
||||
|
||||
shared_libraries = [
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.webrtc.RtpParameters.Encoding;
|
||||
import org.webrtc.RtpTransceiver.RtpTransceiverInit;
|
||||
|
||||
/** Unit-tests for {@link RtpTransceiver}. */
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class RtpTranceiverTest {
|
||||
private PeerConnectionFactory factory;
|
||||
private PeerConnection pc;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
|
||||
.builder(InstrumentationRegistry.getTargetContext())
|
||||
.setNativeLibraryName(TestConstants.NATIVE_LIBRARY)
|
||||
.createInitializationOptions());
|
||||
|
||||
factory = PeerConnectionFactory.builder().createPeerConnectionFactory();
|
||||
|
||||
PeerConnection.RTCConfiguration config = new PeerConnection.RTCConfiguration(Arrays.asList());
|
||||
// RtpTranceiver is part of new unified plan semantics.
|
||||
config.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
||||
pc = factory.createPeerConnection(config, mock(PeerConnection.Observer.class));
|
||||
}
|
||||
|
||||
/** Test that RIDs get set in the RTP sender when passed in through an RtpTransceiverInit. */
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testSetRidInSimulcast() throws Exception {
|
||||
List<Encoding> encodings = new ArrayList<Encoding>();
|
||||
encodings.add(new Encoding("F", true, null));
|
||||
encodings.add(new Encoding("H", true, null));
|
||||
|
||||
RtpTransceiverInit init = new RtpTransceiverInit(
|
||||
RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, Collections.emptyList(), encodings);
|
||||
RtpTransceiver transceiver =
|
||||
pc.addTransceiver(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO, init);
|
||||
|
||||
RtpSender sender = transceiver.getSender();
|
||||
RtpParameters parameters = sender.getParameters();
|
||||
List<Encoding> sendEncodings = parameters.getEncodings();
|
||||
assertEquals(2, sendEncodings.size());
|
||||
assertEquals("F", sendEncodings.get(0).getRid());
|
||||
assertEquals("H", sendEncodings.get(1).getRid());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
package org.webrtc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit tests for {@link VideoTrack}. */
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
public class VideoTrackTest {
|
||||
private PeerConnectionFactory factory;
|
||||
private VideoSource videoSource;
|
||||
private VideoTrack videoTrack;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PeerConnectionFactory.initialize(PeerConnectionFactory.InitializationOptions
|
||||
.builder(InstrumentationRegistry.getTargetContext())
|
||||
.setNativeLibraryName(TestConstants.NATIVE_LIBRARY)
|
||||
.createInitializationOptions());
|
||||
|
||||
factory = PeerConnectionFactory.builder().createPeerConnectionFactory();
|
||||
videoSource = factory.createVideoSource(/* isScreencast= */ false);
|
||||
videoTrack = factory.createVideoTrack("video", videoSource);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddingNullVideoSink() {
|
||||
try {
|
||||
videoTrack.addSink(/* sink= */ null);
|
||||
fail("Should have thrown an IllegalArgumentException.");
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Expected path.
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRemovingNullVideoSink() {
|
||||
videoTrack.removeSink(/* sink= */ null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testRemovingNonExistantVideoSink() {
|
||||
final VideoSink videoSink = new VideoSink() {
|
||||
@Override
|
||||
public void onFrame(VideoFrame frame) {}
|
||||
};
|
||||
videoTrack.removeSink(videoSink);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddingSameVideoSinkMultipleTimes() {
|
||||
class FrameCounter implements VideoSink {
|
||||
private int count;
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFrame(VideoFrame frame) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
final FrameCounter frameCounter = new FrameCounter();
|
||||
|
||||
final VideoFrame videoFrame = new VideoFrame(
|
||||
JavaI420Buffer.allocate(/* width= */ 32, /* height= */ 32), /* rotation= */ 0,
|
||||
/* timestampNs= */ 0);
|
||||
|
||||
videoTrack.addSink(frameCounter);
|
||||
videoTrack.addSink(frameCounter);
|
||||
videoSource.getCapturerObserver().onFrameCaptured(videoFrame);
|
||||
|
||||
// Even though we called addSink() multiple times, we should only get one frame out.
|
||||
assertEquals(1, frameCounter.count);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
public void testAddingAndRemovingVideoSink() {
|
||||
final VideoFrame videoFrame = new VideoFrame(
|
||||
JavaI420Buffer.allocate(/* width= */ 32, /* height= */ 32), /* rotation= */ 0,
|
||||
/* timestampNs= */ 0);
|
||||
|
||||
final VideoSink failSink = new VideoSink() {
|
||||
@Override
|
||||
public void onFrame(VideoFrame frame) {
|
||||
fail("onFrame() should not be called on removed sink");
|
||||
}
|
||||
};
|
||||
videoTrack.addSink(failSink);
|
||||
videoTrack.removeSink(failSink);
|
||||
videoSource.getCapturerObserver().onFrameCaptured(videoFrame);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user