From 503a9e822a259504f6eccc4c5eac6633945e8cea Mon Sep 17 00:00:00 2001 From: "kjellander@webrtc.org" Date: Fri, 13 Mar 2015 09:06:29 +0000 Subject: [PATCH] Make AppRTCDemoTest pass without Internet connection. The AppRTCDemoTest is failing if the Android device lacks an Internet connection (e.g. is in flight mode). This change makes it benefit from the work done in https://review.webrtc.org/36769004/ to work around that limitation for loopback tests. R=phoglund@webrtc.org TBR=glaznev@webrtc.org BUG=4421 TESTED=Successful run on Nexus 7 (2013) in flight mode using: ninja -C out/Release . build/android/envsetup.sh adb install -r out/Release/apks/AppRTCDemo.apk webrtc/build/android/test_runner.py instrumentation --test-apk AppRTCDemoTest --verbose --release Review URL: https://webrtc-codereview.appspot.com/45649004 Cr-Commit-Position: refs/heads/master@{#8714} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8714 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../org/appspot/apprtc/PeerConnectionClient.java | 7 +++++++ .../apprtc/test/PeerConnectionClientTest.java | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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);