Espresso test case to control loopback call
The test case is put inside a new test target. That test target will be started from a test script to asses video quality.
BUG=webrtc:6545
Review-Url: https://codereview.webrtc.org/2585813002
Cr-Commit-Position: refs/heads/master@{#16088}
diff --git a/resources/reference_video_640x360_30fps.y4m.sha1 b/resources/reference_video_640x360_30fps.y4m.sha1
new file mode 100644
index 0000000..c2b50dd
--- /dev/null
+++ b/resources/reference_video_640x360_30fps.y4m.sha1
@@ -0,0 +1 @@
+f9cabbf3a9c5562cd6cdfd19aae1cb5ef8a7ad7d
diff --git a/webrtc/examples/BUILD.gn b/webrtc/examples/BUILD.gn
index cf0c195..428498d 100644
--- a/webrtc/examples/BUILD.gn
+++ b/webrtc/examples/BUILD.gn
@@ -25,6 +25,7 @@
public_deps += [
":AppRTCMobile",
":AppRTCMobileTest",
+ ":AppRTCMobileTestStubbedVideoIO",
]
}
@@ -126,6 +127,29 @@
"//webrtc/examples/androidtests/src/org/appspot/apprtc/test/capturetestvideo.y4m",
]
}
+
+ instrumentation_test_apk("AppRTCMobileTestStubbedVideoIO") {
+ apk_name = "AppRTCMobileTestStubbedVideoIO"
+ android_manifest = "androidtests/AndroidManifest.xml"
+
+ java_files = [ "androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java" ]
+
+ apk_under_test = ":AppRTCMobile"
+
+ deps = [
+ ":AppRTCMobile_javalib",
+ "//third_party/android_support_test_runner:rules_java",
+ "//third_party/android_support_test_runner:runner_java",
+ "//third_party/espresso:espresso_all_java",
+ "//third_party/hamcrest:hamcrest_java",
+ "//third_party/junit",
+ "//webrtc/sdk/android:libjingle_peerconnection_java",
+ ]
+
+ data = [
+ "//resources/reference_video_640x360_30fps.y4m",
+ ]
+ }
}
if (is_ios || (is_mac && target_cpu != "x86")) {
diff --git a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
index 276f752..87ee844 100644
--- a/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
+++ b/webrtc/examples/androidapp/src/org/appspot/apprtc/CallActivity.java
@@ -280,7 +280,7 @@
videoHeight = displayMetrics.heightPixels;
}
DataChannelParameters dataChannelParameters = null;
- if (intent.getBooleanExtra(EXTRA_DATA_CHANNEL_ENABLED, true)) {
+ if (intent.getBooleanExtra(EXTRA_DATA_CHANNEL_ENABLED, false)) {
dataChannelParameters = new DataChannelParameters(intent.getBooleanExtra(EXTRA_ORDERED, true),
intent.getIntExtra(EXTRA_MAX_RETRANSMITS_MS, -1),
intent.getIntExtra(EXTRA_MAX_RETRANSMITS, -1), intent.getStringExtra(EXTRA_PROTOCOL),
diff --git a/webrtc/examples/androidtests/AndroidManifest.xml b/webrtc/examples/androidtests/AndroidManifest.xml
index 30aeee0..3df2c69 100644
--- a/webrtc/examples/androidtests/AndroidManifest.xml
+++ b/webrtc/examples/androidtests/AndroidManifest.xml
@@ -12,6 +12,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.appspot.apprtc.test">
+ <uses-permission android:name="android.permissions.RUN_INSTRUMENTATION" />
<uses-sdk android:minSdkVersion="13" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
diff --git a/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
new file mode 100644
index 0000000..ebb445bc
--- /dev/null
+++ b/webrtc/examples/androidtests/src/org/appspot/apprtc/test/ConnectActivityStubbedInputOutputTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016 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.appspot.apprtc.test;
+
+import static android.support.test.espresso.action.ViewActions.click;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.Espresso.onView;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Environment;
+import android.support.test.espresso.IdlingPolicies;
+import android.support.test.filters.LargeTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.InstrumentationRegistry;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.appspot.apprtc.CallActivity;
+import org.appspot.apprtc.ConnectActivity;
+import org.appspot.apprtc.R;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Used to start a loopback call with video input from file and video output also to file.
+ * The test case is a building block in other testing for video quality.
+ */
+@RunWith(AndroidJUnit4.class)
+@LargeTest
+public class ConnectActivityStubbedInputOutputTest {
+ private static final String TAG = "ConnectActivityStubbedInputOutputTest";
+
+ @Rule
+ public ActivityTestRule<ConnectActivity> rule =
+ new ActivityTestRule<ConnectActivity>(ConnectActivity.class) {
+ @Override
+ protected Intent getActivityIntent() {
+ Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https://appr.tc"),
+ context, ConnectActivity.class);
+
+ intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true);
+
+ intent.putExtra(CallActivity.EXTRA_LOOPBACK, true);
+ intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS");
+ intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8");
+ intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false);
+ intent.putExtra(CallActivity.EXTRA_CAMERA2, false);
+ intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString().substring(0, 8));
+
+ intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA,
+ Environment.getExternalStorageDirectory().getAbsolutePath()
+ + "/chromium_tests_root/resources/reference_video_640x360_30fps.y4m");
+
+ intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE,
+ Environment.getExternalStorageDirectory().getAbsolutePath() + "/output.y4m");
+ intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 640);
+ intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 360);
+
+ return intent;
+ }
+ };
+
+ @Test
+ public void testLoopback() throws InterruptedException {
+ // The time to write down the data during closing of the program can take a while.
+ IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS);
+
+ // During the time we sleep it will record video.
+ Thread.sleep(10000);
+
+ // Click on hang-up button.
+ onView(withId(R.id.button_call_disconnect)).perform(click());
+ }
+}