OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 package org.appspot.apprtc.test; |
| 12 |
| 13 import java.lang.Thread; |
| 14 import java.lang.InterruptedException; |
| 15 import java.util.UUID; |
| 16 import java.util.concurrent.TimeUnit; |
| 17 |
| 18 import android.content.Context; |
| 19 import android.content.Intent; |
| 20 import android.net.Uri; |
| 21 import android.support.test.espresso.IdlingPolicies; |
| 22 import android.support.test.rule.ActivityTestRule; |
| 23 import android.support.test.runner.AndroidJUnit4; |
| 24 import android.support.test.InstrumentationRegistry; |
| 25 import android.test.suitebuilder.annotation.LargeTest; |
| 26 |
| 27 import org.appspot.apprtc.CallActivity; |
| 28 import org.appspot.apprtc.ConnectActivity; |
| 29 |
| 30 import org.appspot.apprtc.R; |
| 31 |
| 32 import org.junit.Rule; |
| 33 import org.junit.Test; |
| 34 import org.junit.runner.RunWith; |
| 35 |
| 36 import static android.support.test.espresso.action.ViewActions.click; |
| 37 import static android.support.test.espresso.matcher.ViewMatchers.withId; |
| 38 import static android.support.test.espresso.Espresso.onView; |
| 39 |
| 40 /** |
| 41 * Used to start a loopback call with video input from file and video output als
o to file. |
| 42 * The test case is a building block in other testing for video quality. |
| 43 */ |
| 44 @RunWith(AndroidJUnit4.class) |
| 45 @LargeTest |
| 46 public class ConnectActivityStubbedInputOutputTest { |
| 47 private static final String TAG = "ConnectActivityStubbedInputOutputTest"; |
| 48 |
| 49 // The third parameter is set to false which means the activity is not started
automatically. |
| 50 @Rule |
| 51 public ActivityTestRule<ConnectActivity> rule = new ActivityTestRule(ConnectAc
tivity.class) { |
| 52 @Override |
| 53 protected Intent getActivityIntent() { |
| 54 Context context = InstrumentationRegistry.getInstrumentation().getTargetCo
ntext(); |
| 55 Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("https:
//appr.tc"), |
| 56 context, ConnectActivity.class); |
| 57 |
| 58 intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true); |
| 59 |
| 60 intent.putExtra(CallActivity.EXTRA_LOOPBACK, true); |
| 61 intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS"); |
| 62 intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8"); |
| 63 intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false); |
| 64 intent.putExtra(CallActivity.EXTRA_CAMERA2, false); |
| 65 intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString().su
bstring(0, 8)); |
| 66 |
| 67 intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA, |
| 68 "/sdcard/chromium_tests_root/resources/reference_video_640x360_30fps.y
4m"); |
| 69 |
| 70 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE, "/sdcard/out
put.y4m"); |
| 71 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 640); |
| 72 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 360); |
| 73 |
| 74 return intent; |
| 75 } |
| 76 }; |
| 77 |
| 78 @Test |
| 79 public void testLoopback() throws InterruptedException { |
| 80 // The time to write down the data during closing of the program can take a
while. |
| 81 IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS); |
| 82 |
| 83 // During the time we sleep it will record video. |
| 84 Thread.sleep(10000); |
| 85 |
| 86 // Click on hang-up button. |
| 87 onView(withId(R.id.button_call_disconnect)).perform(click()); |
| 88 } |
| 89 } |
OLD | NEW |