Index: talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java |
diff --git a/talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java b/talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java |
index 7e24f8c0dc0c1f4ffe64febfd913822cb7a4e121..11b3ce98a092f080767bc11ef5296282b5c8fd5f 100644 |
--- a/talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java |
+++ b/talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java |
@@ -170,6 +170,32 @@ public class VideoCapturerAndroidTestFixtures { |
} |
} |
+ static class CameraEvents implements |
+ VideoCapturerAndroid.CameraEventsHandler { |
+ public boolean onCameraOpeningCalled; |
+ public boolean onFirstFrameAvailableCalled; |
+ |
+ @Override |
+ public void onCameraError(String errorDescription) { } |
+ |
+ @Override |
+ public void onCameraOpening(int cameraId) { |
+ onCameraOpeningCalled = true; |
+ } |
+ |
+ @Override |
+ public void onFirstFrameAvailable() { |
+ onFirstFrameAvailableCalled = true; |
+ } |
+ |
+ @Override |
+ public void onCameraClosed() { } |
+ } |
+ |
+ static public CameraEvents createCameraEvents() { |
+ return new CameraEvents(); |
+ } |
+ |
// Return true if the device under test have at least two cameras. |
@SuppressWarnings("deprecation") |
static public boolean HaveTwoCameras() { |
@@ -237,6 +263,28 @@ public class VideoCapturerAndroidTestFixtures { |
assertTrue(capturer.isReleased()); |
} |
+ static public void cameraEventsInvoked(VideoCapturerAndroid capturer, CameraEvents events, |
+ Context appContext) throws InterruptedException { |
+ final List<CaptureFormat> formats = capturer.getSupportedFormats(); |
+ final CameraEnumerationAndroid.CaptureFormat format = formats.get(0); |
+ |
+ final FakeCapturerObserver observer = new FakeCapturerObserver(); |
+ capturer.startCapture(format.width, format.height, format.maxFramerate, |
+ appContext, observer); |
+ // Make sure camera is started and first frame is received and then stop it. |
+ assertTrue(observer.WaitForCapturerToStart()); |
+ observer.WaitForNextCapturedFrame(); |
+ capturer.stopCapture(); |
+ for (long timeStamp : observer.getCopyAndResetListOftimeStamps()) { |
+ capturer.returnBuffer(timeStamp); |
+ } |
+ capturer.dispose(); |
+ |
+ assertTrue(capturer.isReleased()); |
+ assertTrue(events.onCameraOpeningCalled); |
+ assertTrue(events.onFirstFrameAvailableCalled); |
+ } |
+ |
static public void cameraCallsAfterStop( |
VideoCapturerAndroid capturer, Context appContext) throws InterruptedException { |
final List<CaptureFormat> formats = capturer.getSupportedFormats(); |