diff --git a/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java b/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java index 46354c9af..04517c0d9 100644 --- a/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java +++ b/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java @@ -330,9 +330,16 @@ public class PeerConnectionClient { events.onPeerConnectionError("Failed to initializeAndroidGlobals"); } factory = new PeerConnectionFactory(); + configureFactory(factory); Log.d(TAG, "Peer connection factory created."); } + /** + * Hook where tests can provide additional configuration for the factory. + */ + protected void configureFactory(PeerConnectionFactory factory) { + } + private void createPeerConnectionInternal() { if (factory == null || isError) { Log.e(TAG, "Peerconnection factory is not created"); diff --git a/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java b/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java index 487c031b6..55e8bdf12 100644 --- a/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java +++ b/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java @@ -40,6 +40,7 @@ import org.appspot.apprtc.util.LooperExecutor; import org.webrtc.IceCandidate; import org.webrtc.MediaConstraints; import org.webrtc.PeerConnection; +import org.webrtc.PeerConnectionFactory; import org.webrtc.SessionDescription; import org.webrtc.StatsReport; import org.webrtc.VideoRenderer; @@ -123,6 +124,17 @@ public class PeerConnectionClientTest extends InstrumentationTestCase } } + // Test instance of the PeerConnectionClient class that overrides the options + // for the factory so we can run the test without an Internet connection. + class TestPeerConnectionClient extends PeerConnectionClient { + protected void configureFactory(PeerConnectionFactory factory) { + PeerConnectionFactory.Options options = + new PeerConnectionFactory.Options(); + options.networkIgnoreMask = 0; + factory.setOptions(options); + } + } + // Peer connection events implementation. @Override public void onLocalDescription(SessionDescription sdp) { @@ -259,7 +271,7 @@ public class PeerConnectionClientTest extends InstrumentationTestCase 0, 0, 0, 0, videoCodec, true, // video codec parameters. 0, "OPUS", true); // audio codec parameters. - PeerConnectionClient client = new PeerConnectionClient(); + PeerConnectionClient client = new TestPeerConnectionClient(); client.createPeerConnectionFactory( getInstrumentation().getContext(), null, peerConnectionParameters, this);