Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 package org.appspot.apprtc.test; | 11 package org.appspot.apprtc.test; |
| 12 | 12 |
| 13 import static android.support.test.espresso.action.ViewActions.click; | 13 import static android.support.test.espresso.action.ViewActions.click; |
| 14 import static android.support.test.espresso.matcher.ViewMatchers.withId; | 14 import static android.support.test.espresso.matcher.ViewMatchers.withId; |
| 15 import static android.support.test.espresso.Espresso.onView; | 15 import static android.support.test.espresso.Espresso.onView; |
| 16 | 16 |
| 17 import android.content.Context; | 17 import android.content.Context; |
| 18 import android.content.Intent; | 18 import android.content.Intent; |
| 19 import android.net.Uri; | 19 import android.net.Uri; |
| 20 import android.os.Environment; | 20 import android.os.Environment; |
| 21 import android.support.test.espresso.contrib.CountingIdlingResource; | |
| 22 import android.support.test.espresso.Espresso; | |
| 21 import android.support.test.espresso.IdlingPolicies; | 23 import android.support.test.espresso.IdlingPolicies; |
| 24 import android.support.test.espresso.IdlingResource; | |
| 22 import android.support.test.filters.LargeTest; | 25 import android.support.test.filters.LargeTest; |
| 23 import android.support.test.rule.ActivityTestRule; | 26 import android.support.test.rule.ActivityTestRule; |
| 24 import android.support.test.runner.AndroidJUnit4; | 27 import android.support.test.runner.AndroidJUnit4; |
| 25 import android.support.test.InstrumentationRegistry; | 28 import android.support.test.InstrumentationRegistry; |
| 26 import java.util.UUID; | 29 import java.util.UUID; |
| 27 import java.util.concurrent.TimeUnit; | 30 import java.util.concurrent.TimeUnit; |
| 28 import org.appspot.apprtc.CallActivity; | 31 import org.appspot.apprtc.CallActivity; |
| 29 import org.appspot.apprtc.ConnectActivity; | 32 import org.appspot.apprtc.ConnectActivity; |
| 30 import org.appspot.apprtc.R; | 33 import org.appspot.apprtc.R; |
| 34 import org.junit.After; | |
| 35 import org.junit.Before; | |
| 31 import org.junit.Rule; | 36 import org.junit.Rule; |
| 32 import org.junit.Test; | 37 import org.junit.Test; |
| 33 import org.junit.runner.RunWith; | 38 import org.junit.runner.RunWith; |
| 34 | 39 |
| 35 /** | 40 /** |
| 36 * Used to start a loopback call with video input from file and video output als o to file. | 41 * Used to start a loopback call with video input from file and video output als o to file. |
| 37 * The test case is a building block in other testing for video quality. | 42 * The test case is a building block in other testing for video quality. |
| 38 */ | 43 */ |
| 39 @RunWith(AndroidJUnit4.class) | 44 @RunWith(AndroidJUnit4.class) |
| 40 @LargeTest | 45 @LargeTest |
| 41 public class ConnectActivityStubbedInputOutputTest { | 46 public class CallActivityStubbedInputOutputTest { |
| 42 private static final String TAG = "ConnectActivityStubbedInputOutputTest"; | 47 private static final String TAG = "CallActivityStubbedInputOutputTest"; |
| 43 | 48 |
| 44 @Rule | 49 @Rule |
| 45 public ActivityTestRule<ConnectActivity> rule = | 50 public ActivityTestRule<CallActivity> rule = |
| 46 new ActivityTestRule<ConnectActivity>(ConnectActivity.class) { | 51 new ActivityTestRule<CallActivity>(CallActivity.class) { |
| 47 @Override | 52 @Override |
| 48 protected Intent getActivityIntent() { | 53 protected Intent getActivityIntent() { |
| 49 Context context = InstrumentationRegistry.getInstrumentation().getTarg etContext(); | 54 Context context = |
| 50 Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("ht tps://appr.tc"), | 55 InstrumentationRegistry |
| 51 context, ConnectActivity.class); | 56 .getContext(); // InstrumentationRegistry.getInstrumentation() .getTargetContext(); |
| 57 Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("ht tps://appr.tc")); | |
| 52 | 58 |
| 53 intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true); | 59 intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true); |
| 54 | 60 |
| 55 intent.putExtra(CallActivity.EXTRA_LOOPBACK, true); | 61 intent.putExtra(CallActivity.EXTRA_LOOPBACK, true); |
| 56 intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS"); | 62 intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS"); |
| 57 intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8"); | 63 intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8"); |
| 58 intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false); | 64 intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false); |
| 59 intent.putExtra(CallActivity.EXTRA_CAMERA2, false); | 65 intent.putExtra(CallActivity.EXTRA_CAMERA2, false); |
| 60 intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString( ).substring(0, 8)); | 66 intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString( ).substring(0, 8)); |
| 61 | 67 |
| 62 intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA, | 68 intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA, |
| 63 Environment.getExternalStorageDirectory().getAbsolutePath() | 69 Environment.getExternalStorageDirectory().getAbsolutePath() |
| 64 + "/chromium_tests_root/resources/reference_video_640x360_30fp s.y4m"); | 70 + "/chromium_tests_root/resources/reference_video_640x360_30fp s.y4m"); |
| 65 | 71 |
| 66 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE, | 72 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE, |
| 67 Environment.getExternalStorageDirectory().getAbsolutePath() + "/ou tput.y4m"); | 73 Environment.getExternalStorageDirectory().getAbsolutePath() + "/ou tput.y4m"); |
| 68 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 64 0); | 74 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 64 0); |
| 69 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 3 60); | 75 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 3 60); |
| 70 | 76 |
| 71 return intent; | 77 return intent; |
| 72 } | 78 } |
| 73 }; | 79 }; |
| 74 | 80 |
| 81 private static class BusyResource implements CallActivity.CountingResource { | |
| 82 CountingIdlingResource countingIdlingResource = new CountingIdlingResource(" BusyResource"); | |
| 83 | |
| 84 @Override | |
| 85 public void increment() { | |
| 86 countingIdlingResource.increment(); | |
| 87 } | |
| 88 | |
| 89 @Override | |
| 90 public void decrement() { | |
| 91 countingIdlingResource.decrement(); | |
| 92 } | |
| 93 } | |
| 94 private IdlingResource idlingResource; | |
| 95 | |
| 96 @Before | |
| 97 public void registerIdlingResource() { | |
| 98 BusyResource busyR = new BusyResource(); | |
| 99 idlingResource = busyR.countingIdlingResource; | |
| 100 rule.getActivity().setCountingResource(busyR); | |
| 101 Espresso.registerIdlingResources(idlingResource); | |
| 102 } | |
| 103 | |
| 104 @After | |
| 105 public void unregisterIdlingResources() { | |
| 106 if (idlingResource != null) { | |
| 107 Espresso.unregisterIdlingResources(idlingResource); | |
| 108 } | |
| 109 } | |
| 110 | |
| 75 @Test | 111 @Test |
| 76 public void testLoopback() throws InterruptedException { | 112 public void testLoopback() throws InterruptedException { |
| 77 // The time to write down the data during closing of the program can take a while. | 113 // The time to write down the data during closing of the program can take a while. |
| 78 IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS); | 114 IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS); |
| 79 | 115 |
| 80 // During the time we sleep it will record video. | 116 // During the time we sleep it will record video. |
| 81 Thread.sleep(10000); | 117 Thread.sleep(10000); |
| 82 | 118 |
| 119 // XXX: Not needed at the moment to finish the call. | |
|
kjellander_webrtc
2017/03/10 12:14:12
What does this mean "not at the moment"? When will
| |
| 83 // Click on hang-up button. | 120 // Click on hang-up button. |
| 84 onView(withId(R.id.button_call_disconnect)).perform(click()); | 121 // onView(withId(R.id.button_call_disconnect)).perform(click()); |
| 85 } | 122 } |
| 86 } | 123 } |
| OLD | NEW |