| Index: webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java
|
| diff --git a/webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java b/webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java
|
| index 2ba019367590f4feacf73c02319b53e083e14116..241b6e5bcef1249eaf7c05ebaae8c3ab821c4ab0 100644
|
| --- a/webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java
|
| +++ b/webrtc/api/androidtests/src/org/webrtc/EglRendererTest.java
|
| @@ -29,6 +29,7 @@ public class EglRendererTest extends InstrumentationTestCase {
|
| final static int SURFACE_WAIT_MS = 1000;
|
| final static int TEST_FRAME_WIDTH = 4;
|
| final static int TEST_FRAME_HEIGHT = 4;
|
| + final static int REMOVE_FRAME_LISTENER_RACY_NUM_TESTS = 10;
|
| // Some arbitrary frames.
|
| final static ByteBuffer[][] TEST_FRAMES = {
|
| {
|
| @@ -264,4 +265,29 @@ public class EglRendererTest extends InstrumentationTestCase {
|
| checkBitmap(testFrameListener.resetAndGetBitmap(), scale);
|
| }
|
| }
|
| +
|
| + /**
|
| + * Checks that the frame listener will not be called with a frame that was delivered before the
|
| + * frame listener was added.
|
| + */
|
| + @SmallTest
|
| + public void testFrameListenerNotCalledWithOldFrames() throws Exception {
|
| + feedFrame(0);
|
| + eglRenderer.addFrameListener(testFrameListener, 0f);
|
| + // Check the old frame does not trigger frame listener.
|
| + assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
|
| + }
|
| +
|
| + /** Checks that the frame listener will not be called after it is removed. */
|
| + @SmallTest
|
| + public void testRemoveFrameListenerNotRacy() throws Exception {
|
| + for (int i = 0; i < REMOVE_FRAME_LISTENER_RACY_NUM_TESTS; i++) {
|
| + feedFrame(0);
|
| + eglRenderer.addFrameListener(testFrameListener, 0f);
|
| + eglRenderer.removeFrameListener(testFrameListener);
|
| + feedFrame(1);
|
| + }
|
| + // Check the frame listener hasn't triggered.
|
| + assertFalse(testFrameListener.waitForBitmap(RENDER_WAIT_MS));
|
| + }
|
| }
|
|
|