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; |
31 import org.junit.Rule; | 34 import org.junit.Rule; |
32 import org.junit.Test; | 35 import org.junit.Test; |
33 import org.junit.runner.RunWith; | 36 import org.junit.runner.RunWith; |
34 | 37 |
35 /** | 38 /** |
36 * Used to start a loopback call with video input from file and video output als
o to file. | 39 * 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. | 40 * The test case is a building block in other testing for video quality. |
38 */ | 41 */ |
39 @RunWith(AndroidJUnit4.class) | 42 @RunWith(AndroidJUnit4.class) |
40 @LargeTest | 43 @LargeTest |
41 public class ConnectActivityStubbedInputOutputTest { | 44 public class CallActivityStubbedInputOutputTest { |
42 private static final String TAG = "ConnectActivityStubbedInputOutputTest"; | 45 private static final String TAG = "CallActivityStubbedInputOutputTest"; |
43 | 46 |
44 @Rule | 47 @Rule |
45 public ActivityTestRule<ConnectActivity> rule = | 48 public ActivityTestRule<CallActivity> rule = new ActivityTestRule<CallActivity
>( |
46 new ActivityTestRule<ConnectActivity>(ConnectActivity.class) { | 49 CallActivity.class) { |
47 @Override | 50 @Override |
48 protected Intent getActivityIntent() { | 51 protected Intent getActivityIntent() { |
49 Context context = InstrumentationRegistry.getInstrumentation().getTarg
etContext(); | 52 Context context = InstrumentationRegistry.getContext(); |
50 Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("ht
tps://appr.tc"), | 53 Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("http:/
/localhost:9999")); |
51 context, ConnectActivity.class); | |
52 | 54 |
53 intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true); | 55 intent.putExtra(CallActivity.EXTRA_USE_VALUES_FROM_INTENT, true); |
54 | 56 |
55 intent.putExtra(CallActivity.EXTRA_LOOPBACK, true); | 57 intent.putExtra(CallActivity.EXTRA_COLLIDERURL, "http://localhost:8089"); |
56 intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS"); | |
57 intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8"); | |
58 intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false); | |
59 intent.putExtra(CallActivity.EXTRA_CAMERA2, false); | |
60 intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString(
).substring(0, 8)); | |
61 | 58 |
62 intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA, | 59 intent.putExtra(CallActivity.EXTRA_LOOPBACK, true); |
63 Environment.getExternalStorageDirectory().getAbsolutePath() | 60 intent.putExtra(CallActivity.EXTRA_AUDIOCODEC, "OPUS"); |
64 + "/chromium_tests_root/resources/reference_video_640x360_30fp
s.y4m"); | 61 intent.putExtra(CallActivity.EXTRA_VIDEOCODEC, "VP8"); |
| 62 intent.putExtra(CallActivity.EXTRA_CAPTURETOTEXTURE_ENABLED, false); |
| 63 intent.putExtra(CallActivity.EXTRA_CAMERA2, false); |
| 64 intent.putExtra(CallActivity.EXTRA_ROOMID, UUID.randomUUID().toString().su
bstring(0, 8)); |
65 | 65 |
66 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE, | 66 intent.putExtra(CallActivity.EXTRA_VIDEO_FILE_AS_CAMERA, |
67 Environment.getExternalStorageDirectory().getAbsolutePath() + "/ou
tput.y4m"); | 67 Environment.getExternalStorageDirectory().getAbsolutePath() |
68 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 64
0); | 68 + "/chromium_tests_root/resources/reference_video_640x360_30fps.y4
m"); |
69 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 3
60); | |
70 | 69 |
71 return intent; | 70 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE, |
72 } | 71 Environment.getExternalStorageDirectory().getAbsolutePath() + "/output
.y4m"); |
73 }; | 72 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_WIDTH, 640); |
| 73 intent.putExtra(CallActivity.EXTRA_SAVE_REMOTE_VIDEO_TO_FILE_HEIGHT, 360); |
| 74 |
| 75 return intent; |
| 76 } |
| 77 }; |
74 | 78 |
75 @Test | 79 @Test |
76 public void testLoopback() throws InterruptedException { | 80 public void testLoopback() throws InterruptedException { |
77 // The time to write down the data during closing of the program can take a
while. | 81 // The time to write down the data during closing of the program can take a
while. |
78 IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS); | 82 IdlingPolicies.setMasterPolicyTimeout(240000, TimeUnit.MILLISECONDS); |
79 | 83 |
80 // During the time we sleep it will record video. | 84 // During the time we sleep it will record video. |
81 Thread.sleep(10000); | 85 Thread.sleep(8000); |
82 | 86 |
83 // Click on hang-up button. | 87 // Click on hang-up button. |
84 onView(withId(R.id.button_call_disconnect)).perform(click()); | 88 onView(withId(R.id.button_call_disconnect)).perform(click()); |
85 } | 89 } |
86 } | 90 } |
OLD | NEW |