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 org.junit.Assert.assertEquals; | 13 import static org.junit.Assert.assertEquals; |
14 import static org.junit.Assert.assertTrue; | 14 import static org.junit.Assert.assertTrue; |
15 | 15 |
| 16 import android.os.Environment; |
16 import android.support.test.filters.LargeTest; | 17 import android.support.test.filters.LargeTest; |
17 import android.support.test.filters.MediumTest; | 18 import android.support.test.filters.MediumTest; |
18 import android.support.test.filters.SmallTest; | 19 import android.support.test.filters.SmallTest; |
19 import java.io.IOException; | 20 import java.io.IOException; |
20 import java.lang.Thread; | 21 import java.lang.Thread; |
21 import java.nio.charset.StandardCharsets; | 22 import java.nio.charset.StandardCharsets; |
22 import java.util.ArrayList; | 23 import java.util.ArrayList; |
23 import java.util.Arrays; | 24 import java.util.Arrays; |
24 import org.chromium.base.test.BaseJUnit4ClassRunner; | 25 import org.chromium.base.test.BaseJUnit4ClassRunner; |
25 import org.junit.Test; | 26 import org.junit.Test; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 return new ArrayList<Frame>(frameDatas); | 75 return new ArrayList<Frame>(frameDatas); |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 @Test | 79 @Test |
79 @SmallTest | 80 @SmallTest |
80 public void testVideoCaptureFromFile() throws InterruptedException, IOExceptio
n { | 81 public void testVideoCaptureFromFile() throws InterruptedException, IOExceptio
n { |
81 final int FRAME_WIDTH = 4; | 82 final int FRAME_WIDTH = 4; |
82 final int FRAME_HEIGHT = 4; | 83 final int FRAME_HEIGHT = 4; |
83 final FileVideoCapturer fileVideoCapturer = new FileVideoCapturer( | 84 final FileVideoCapturer fileVideoCapturer = |
84 "/sdcard/chromium_tests_root/webrtc/examples/androidtests/src/org/appspo
t/apprtc/test/" | 85 new FileVideoCapturer(Environment.getExternalStorageDirectory().getPath(
) |
85 + "capturetestvideo.y4m"); | 86 + "/chromium_tests_root/webrtc/examples/androidtests/src/org/appspot
/apprtc/test/" |
| 87 + "capturetestvideo.y4m"); |
86 final MockCapturerObserver capturerObserver = new MockCapturerObserver(); | 88 final MockCapturerObserver capturerObserver = new MockCapturerObserver(); |
87 fileVideoCapturer.initialize(null, null, capturerObserver); | 89 fileVideoCapturer.initialize(null, null, capturerObserver); |
88 fileVideoCapturer.startCapture(FRAME_WIDTH, FRAME_HEIGHT, 33); | 90 fileVideoCapturer.startCapture(FRAME_WIDTH, FRAME_HEIGHT, 33); |
89 | 91 |
90 final String[] expectedFrames = { | 92 final String[] expectedFrames = { |
91 "THIS IS JUST SOME TEXT x", "THE SECOND FRAME qwerty.", "HERE IS THE THR
ID FRAME!"}; | 93 "THIS IS JUST SOME TEXT x", "THE SECOND FRAME qwerty.", "HERE IS THE THR
ID FRAME!"}; |
92 | 94 |
93 final ArrayList<Frame> frameDatas; | 95 final ArrayList<Frame> frameDatas; |
94 frameDatas = capturerObserver.getMinimumFramesBlocking(expectedFrames.length
); | 96 frameDatas = capturerObserver.getMinimumFramesBlocking(expectedFrames.length
); |
95 | 97 |
(...skipping 10 matching lines...) Expand all Loading... |
106 assertEquals(FRAME_WIDTH * FRAME_HEIGHT * 3 / 2, frame.data.length); | 108 assertEquals(FRAME_WIDTH * FRAME_HEIGHT * 3 / 2, frame.data.length); |
107 | 109 |
108 byte[] expectedNV12Bytes = new byte[frame.data.length]; | 110 byte[] expectedNV12Bytes = new byte[frame.data.length]; |
109 FileVideoCapturer.nativeI420ToNV21(expectedFrames[i].getBytes(StandardChar
sets.US_ASCII), | 111 FileVideoCapturer.nativeI420ToNV21(expectedFrames[i].getBytes(StandardChar
sets.US_ASCII), |
110 FRAME_WIDTH, FRAME_HEIGHT, expectedNV12Bytes); | 112 FRAME_WIDTH, FRAME_HEIGHT, expectedNV12Bytes); |
111 | 113 |
112 assertTrue(Arrays.equals(expectedNV12Bytes, frame.data)); | 114 assertTrue(Arrays.equals(expectedNV12Bytes, frame.data)); |
113 } | 115 } |
114 } | 116 } |
115 } | 117 } |
OLD | NEW |