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

Unified Diff: talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTestFixtures.java

Issue 1398793005: Add new Android camera events. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Add unit test Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698