Index: webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java |
diff --git a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java |
index 5b60e71307c21cc5843ca1f8442cadb0b3c1f9dd..aef9b57c391a0fdbf6acf444d565a5a84e59d20d 100644 |
--- a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java |
+++ b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java |
@@ -37,8 +37,8 @@ import java.util.concurrent.ExecutorService; |
import java.util.concurrent.Executors; |
import java.util.concurrent.TimeUnit; |
-public class PeerConnectionClientTest extends InstrumentationTestCase |
- implements PeerConnectionEvents { |
+public class PeerConnectionClientTest |
+ extends InstrumentationTestCase implements PeerConnectionEvents { |
private static final String TAG = "RTCClientTest"; |
private static final int ICE_CONNECTION_WAIT_TIMEOUT = 10000; |
private static final int WAIT_TIMEOUT = 7000; |
@@ -103,8 +103,8 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
public synchronized void renderFrame(VideoRenderer.I420Frame frame) { |
if (!renderFrameCalled) { |
if (rendererName != null) { |
- Log.d(TAG, rendererName + " render frame: " |
- + frame.rotatedWidth() + " x " + frame.rotatedHeight()); |
+ Log.d(TAG, rendererName + " render frame: " + frame.rotatedWidth() + " x " |
+ + frame.rotatedHeight()); |
} else { |
Log.d(TAG, "Render frame: " + frame.rotatedWidth() + " x " + frame.rotatedHeight()); |
} |
@@ -114,11 +114,9 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
doneRendering.countDown(); |
} |
- |
// This method shouldn't hold any locks or touch member variables since it |
// blocks. |
- public boolean waitForFramesRendered(int timeoutMs) |
- throws InterruptedException { |
+ public boolean waitForFramesRendered(int timeoutMs) throws InterruptedException { |
doneRendering.await(timeoutMs, TimeUnit.MILLISECONDS); |
return (doneRendering.getCount() <= 0); |
} |
@@ -136,7 +134,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
@Override |
public void onIceCandidate(final IceCandidate candidate) { |
- synchronized(iceCandidateEvent) { |
+ synchronized (iceCandidateEvent) { |
Log.d(TAG, "IceCandidate #" + iceCandidates.size() + " : " + candidate.toString()); |
if (loopback) { |
// Loopback local ICE candidate in a separate thread to avoid adding |
@@ -161,7 +159,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
@Override |
public void onIceConnected() { |
Log.d(TAG, "ICE Connected"); |
- synchronized(iceConnectedEvent) { |
+ synchronized (iceConnectedEvent) { |
isIceConnected = true; |
iceConnectedEvent.notifyAll(); |
} |
@@ -170,7 +168,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
@Override |
public void onIceDisconnected() { |
Log.d(TAG, "ICE Disconnected"); |
- synchronized(iceConnectedEvent) { |
+ synchronized (iceConnectedEvent) { |
isIceConnected = false; |
iceConnectedEvent.notifyAll(); |
} |
@@ -179,7 +177,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
@Override |
public void onPeerConnectionClosed() { |
Log.d(TAG, "PeerConnection closed"); |
- synchronized(closeEvent) { |
+ synchronized (closeEvent) { |
isClosed = true; |
closeEvent.notifyAll(); |
} |
@@ -191,13 +189,11 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
@Override |
- public void onPeerConnectionStatsReady(StatsReport[] reports) { |
- } |
+ public void onPeerConnectionStatsReady(StatsReport[] reports) {} |
// Helper wait functions. |
- private boolean waitForLocalSDP(int timeoutMs) |
- throws InterruptedException { |
- synchronized(localSdpEvent) { |
+ private boolean waitForLocalSDP(int timeoutMs) throws InterruptedException { |
+ synchronized (localSdpEvent) { |
if (localSdp == null) { |
localSdpEvent.wait(timeoutMs); |
} |
@@ -205,9 +201,8 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
} |
- private boolean waitForIceCandidates(int timeoutMs) |
- throws InterruptedException { |
- synchronized(iceCandidateEvent) { |
+ private boolean waitForIceCandidates(int timeoutMs) throws InterruptedException { |
+ synchronized (iceCandidateEvent) { |
if (iceCandidates.size() == 0) { |
iceCandidateEvent.wait(timeoutMs); |
} |
@@ -215,9 +210,8 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
} |
- private boolean waitForIceConnected(int timeoutMs) |
- throws InterruptedException { |
- synchronized(iceConnectedEvent) { |
+ private boolean waitForIceConnected(int timeoutMs) throws InterruptedException { |
+ synchronized (iceConnectedEvent) { |
if (!isIceConnected) { |
iceConnectedEvent.wait(timeoutMs); |
} |
@@ -229,9 +223,8 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
} |
- private boolean waitForPeerConnectionClosed(int timeoutMs) |
- throws InterruptedException { |
- synchronized(closeEvent) { |
+ private boolean waitForPeerConnectionClosed(int timeoutMs) throws InterruptedException { |
+ synchronized (closeEvent) { |
if (!isClosed) { |
closeEvent.wait(timeoutMs); |
} |
@@ -239,15 +232,14 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
} |
- PeerConnectionClient createPeerConnectionClient( |
- MockRenderer localRenderer, MockRenderer remoteRenderer, |
- PeerConnectionParameters peerConnectionParameters, EglBase.Context eglContext) { |
- List<PeerConnection.IceServer> iceServers = |
- new LinkedList<PeerConnection.IceServer>(); |
- SignalingParameters signalingParameters = new SignalingParameters( |
- iceServers, true, // iceServers, initiator. |
- null, null, null, // clientId, wssUrl, wssPostUrl. |
- null, null); // offerSdp, iceCandidates. |
+ PeerConnectionClient createPeerConnectionClient(MockRenderer localRenderer, |
+ MockRenderer remoteRenderer, PeerConnectionParameters peerConnectionParameters, |
+ EglBase.Context eglContext) { |
+ List<PeerConnection.IceServer> iceServers = new LinkedList<PeerConnection.IceServer>(); |
+ SignalingParameters signalingParameters = |
+ new SignalingParameters(iceServers, true, // iceServers, initiator. |
+ null, null, null, // clientId, wssUrl, wssPostUrl. |
+ null, null); // offerSdp, iceCandidates. |
PeerConnectionClient client = PeerConnectionClient.getInstance(); |
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); |
@@ -263,8 +255,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
private PeerConnectionParameters createParametersForAudioCall() { |
PeerConnectionParameters peerConnectionParameters = |
- new PeerConnectionParameters( |
- false, /* videoCallEnabled */ |
+ new PeerConnectionParameters(false, /* videoCallEnabled */ |
true, /* loopback */ |
false, /* tracing */ |
// Video codec parameters. |
@@ -281,22 +272,18 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
"OPUS", /* audioCodec */ |
false, /* noAudioProcessing */ |
false, /* aecDump */ |
- false /* useOpenSLES */, |
- false /* disableBuiltInAEC */, |
- false /* disableBuiltInAGC */, |
- false /* disableBuiltInNS */, |
- false /* enableLevelControl */); |
+ false /* useOpenSLES */, false /* disableBuiltInAEC */, false /* disableBuiltInAGC */, |
+ false /* disableBuiltInNS */, false /* enableLevelControl */); |
return peerConnectionParameters; |
} |
private PeerConnectionParameters createParametersForVideoCall( |
String videoCodec, boolean captureToTexture) { |
- final boolean useCamera2 = captureToTexture |
- && Camera2Enumerator.isSupported(getInstrumentation().getTargetContext()); |
+ final boolean useCamera2 = |
+ captureToTexture && Camera2Enumerator.isSupported(getInstrumentation().getTargetContext()); |
PeerConnectionParameters peerConnectionParameters = |
- new PeerConnectionParameters( |
- true, /* videoCallEnabled */ |
+ new PeerConnectionParameters(true, /* videoCallEnabled */ |
true, /* loopback */ |
false, /* tracing */ |
// Video codec parameters. |
@@ -313,11 +300,8 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
"OPUS", /* audioCodec */ |
false, /* noAudioProcessing */ |
false, /* aecDump */ |
- false /* useOpenSLES */, |
- false /* disableBuiltInAEC */, |
- false /* disableBuiltInAGC */, |
- false /* disableBuiltInNS */, |
- false /* enableLevelControl */); |
+ false /* useOpenSLES */, false /* disableBuiltInAEC */, false /* disableBuiltInAGC */, |
+ false /* disableBuiltInNS */, false /* enableLevelControl */); |
return peerConnectionParameters; |
} |
@@ -338,26 +322,23 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
} |
@SmallTest |
- public void testSetLocalOfferMakesVideoFlowLocally() |
- throws InterruptedException { |
+ public void testSetLocalOfferMakesVideoFlowLocally() throws InterruptedException { |
Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally"); |
MockRenderer localRenderer = new MockRenderer(EXPECTED_VIDEO_FRAMES, LOCAL_RENDERER_NAME); |
- pcClient = createPeerConnectionClient( |
- localRenderer, new MockRenderer(0, null), |
+ pcClient = createPeerConnectionClient(localRenderer, new MockRenderer(0, null), |
createParametersForVideoCall(VIDEO_CODEC_VP8, false), null); |
// Wait for local SDP and ice candidates set events. |
assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
- assertTrue("ICE candidates were not generated.", |
- waitForIceCandidates(WAIT_TIMEOUT)); |
+ assertTrue("ICE candidates were not generated.", waitForIceCandidates(WAIT_TIMEOUT)); |
// Check that local video frames were rendered. |
- assertTrue("Local video frames were not rendered.", |
- localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
+ assertTrue( |
+ "Local video frames were not rendered.", localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
pcClient.close(); |
- assertTrue("PeerConnection close event was not received.", |
- waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
+ assertTrue( |
+ "PeerConnection close event was not received.", waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
Log.d(TAG, "testSetLocalOfferMakesVideoFlowLocally Done."); |
} |
@@ -379,8 +360,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
// Wait for local SDP, rename it to answer and set as remote SDP. |
assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
SessionDescription remoteSdp = new SessionDescription( |
- SessionDescription.Type.fromCanonicalForm("answer"), |
- localSdp.description); |
+ SessionDescription.Type.fromCanonicalForm("answer"), localSdp.description); |
pcClient.setRemoteDescription(remoteSdp); |
// Wait for ICE connection. |
@@ -492,15 +472,14 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
eglBase = null; |
SessionDescription remoteSdp = new SessionDescription( |
- SessionDescription.Type.fromCanonicalForm("answer"), |
- localSdp.description); |
+ SessionDescription.Type.fromCanonicalForm("answer"), localSdp.description); |
pcClient.setRemoteDescription(remoteSdp); |
// Wait for ICE connection. |
assertTrue("ICE connection failure.", waitForIceConnected(ICE_CONNECTION_WAIT_TIMEOUT)); |
// Check that local and remote video frames were rendered. |
- assertTrue("Local video frames were not rendered.", |
- localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
+ assertTrue( |
+ "Local video frames were not rendered.", localRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
assertTrue("Remote video frames were not rendered.", |
remoteRenderer.waitForFramesRendered(WAIT_TIMEOUT)); |
@@ -524,7 +503,6 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264, true), true); |
} |
- |
// Checks if default front camera can be switched to back camera and then |
// again to front camera. |
@SmallTest |
@@ -541,8 +519,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
// Wait for local SDP, rename it to answer and set as remote SDP. |
assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
SessionDescription remoteSdp = new SessionDescription( |
- SessionDescription.Type.fromCanonicalForm("answer"), |
- localSdp.description); |
+ SessionDescription.Type.fromCanonicalForm("answer"), localSdp.description); |
pcClient.setRemoteDescription(remoteSdp); |
// Wait for ICE connection. |
@@ -588,8 +565,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
// Wait for local SDP, rename it to answer and set as remote SDP. |
assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
SessionDescription remoteSdp = new SessionDescription( |
- SessionDescription.Type.fromCanonicalForm("answer"), |
- localSdp.description); |
+ SessionDescription.Type.fromCanonicalForm("answer"), localSdp.description); |
pcClient.setRemoteDescription(remoteSdp); |
// Wait for ICE connection. |
@@ -636,8 +612,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
// Wait for local SDP, rename it to answer and set as remote SDP. |
assertTrue("Local SDP was not set.", waitForLocalSDP(WAIT_TIMEOUT)); |
SessionDescription remoteSdp = new SessionDescription( |
- SessionDescription.Type.fromCanonicalForm("answer"), |
- localSdp.description); |
+ SessionDescription.Type.fromCanonicalForm("answer"), localSdp.description); |
pcClient.setRemoteDescription(remoteSdp); |
// Wait for ICE connection. |
@@ -671,5 +646,4 @@ public class PeerConnectionClientTest extends InstrumentationTestCase |
assertTrue(waitForPeerConnectionClosed(WAIT_TIMEOUT)); |
Log.d(TAG, "testCaptureFormatChange done."); |
} |
- |
} |