Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java

Issue 2529313002: Fix potential synchronization issues with framelisteners in EglRenderer. (Closed)
Patch Set: Remove unnecessary lock. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/android/java/src/org/webrtc/EglRenderer.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 11 matching lines...) Expand all
22 import java.util.concurrent.CountDownLatch; 22 import java.util.concurrent.CountDownLatch;
23 import java.util.concurrent.TimeUnit; 23 import java.util.concurrent.TimeUnit;
24 24
25 // EmptyActivity is needed for the surface. 25 // EmptyActivity is needed for the surface.
26 public class EglRendererTest extends InstrumentationTestCase { 26 public class EglRendererTest extends InstrumentationTestCase {
27 final static String TAG = "EglRendererTest"; 27 final static String TAG = "EglRendererTest";
28 final static int RENDER_WAIT_MS = 1000; 28 final static int RENDER_WAIT_MS = 1000;
29 final static int SURFACE_WAIT_MS = 1000; 29 final static int SURFACE_WAIT_MS = 1000;
30 final static int TEST_FRAME_WIDTH = 4; 30 final static int TEST_FRAME_WIDTH = 4;
31 final static int TEST_FRAME_HEIGHT = 4; 31 final static int TEST_FRAME_HEIGHT = 4;
32 final static int REMOVE_FRAME_LISTENER_RACY_NUM_TESTS = 10;
32 // Some arbitrary frames. 33 // Some arbitrary frames.
33 final static ByteBuffer[][] TEST_FRAMES = { 34 final static ByteBuffer[][] TEST_FRAMES = {
34 { 35 {
35 ByteBuffer.wrap(new byte[] { 36 ByteBuffer.wrap(new byte[] {
36 11, -12, 13, -14, -15, 16, -17, 18, 19, -110, 111, -112, -113, 114 , -115, 116}), 37 11, -12, 13, -14, -15, 16, -17, 18, 19, -110, 111, -112, -113, 114 , -115, 116}),
37 ByteBuffer.wrap(new byte[] {117, 118, 119, 120}), 38 ByteBuffer.wrap(new byte[] {117, 118, 119, 120}),
38 ByteBuffer.wrap(new byte[] {121, 122, 123, 124}), 39 ByteBuffer.wrap(new byte[] {121, 122, 123, 124}),
39 }, 40 },
40 { 41 {
41 ByteBuffer.wrap(new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -1 9, -110, -111, -112, 42 ByteBuffer.wrap(new byte[] {-11, -12, -13, -14, -15, -16, -17, -18, -1 9, -110, -111, -112,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 @SmallTest 258 @SmallTest
258 public void testAddFrameListenerBitmapScale() throws Exception { 259 public void testAddFrameListenerBitmapScale() throws Exception {
259 for (int i = 0; i < 3; ++i) { 260 for (int i = 0; i < 3; ++i) {
260 float scale = i * 0.5f + 0.5f; 261 float scale = i * 0.5f + 0.5f;
261 eglRenderer.addFrameListener(testFrameListener, scale); 262 eglRenderer.addFrameListener(testFrameListener, scale);
262 feedFrame(i); 263 feedFrame(i);
263 assertTrue(testFrameListener.waitForBitmap(RENDER_WAIT_MS)); 264 assertTrue(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
264 checkBitmap(testFrameListener.resetAndGetBitmap(), scale); 265 checkBitmap(testFrameListener.resetAndGetBitmap(), scale);
265 } 266 }
266 } 267 }
268
269 /**
270 * Checks that the frame listener will not be called with a frame that was del ivered before the
271 * frame listener was added.
272 */
273 @SmallTest
274 public void testFrameListenerNotCalledWithOldFrames() throws Exception {
275 feedFrame(0);
276 eglRenderer.addFrameListener(testFrameListener, 0f);
277 // Check the old frame does not trigger frame listener.
278 assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
279 }
280
281 /** Checks that the frame listener will not be called after it is removed. */
282 @SmallTest
283 public void testRemoveFrameListenerNotRacy() throws Exception {
284 for (int i = 0; i < REMOVE_FRAME_LISTENER_RACY_NUM_TESTS; i++) {
285 feedFrame(0);
286 eglRenderer.addFrameListener(testFrameListener, 0f);
287 eglRenderer.removeFrameListener(testFrameListener);
288 feedFrame(1);
289 }
290 // Check the frame listener hasn't triggered.
291 assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
292 }
267 } 293 }
OLDNEW
« no previous file with comments | « webrtc/api/android/java/src/org/webrtc/EglRenderer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698