diff options
author | Zhijun He <zhijunhe@google.com> | 2013-07-23 07:54:38 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2013-07-23 13:46:37 -0700 |
commit | 7f4d3147d1851d2f0c544e45390c139bda9fd9aa (patch) | |
tree | e53c1c97ec454fa3c56670aa4ac4ce5d16c1997c /media/tests/MediaFrameworkTest/src | |
parent | 5830e0752121c5565da184727888de6567b50e3a (diff) | |
download | frameworks_base-7f4d3147d1851d2f0c544e45390c139bda9fd9aa.zip frameworks_base-7f4d3147d1851d2f0c544e45390c139bda9fd9aa.tar.gz frameworks_base-7f4d3147d1851d2f0c544e45390c139bda9fd9aa.tar.bz2 |
camera2: Implement CameraDevice#waitUntilIdle
Also cleanup some logging/comments.
Change-Id: Id1a4dd853519802a2b74b8d2172095ba388329e6
Diffstat (limited to 'media/tests/MediaFrameworkTest/src')
2 files changed, 46 insertions, 0 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java index 2ebe11a..1be2a62 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraBinderTestUtils.java @@ -19,6 +19,7 @@ public class CameraBinderTestUtils { protected static final int USE_CALLING_UID = -1; protected static final int BAD_VALUE = -22; + protected static final int INVALID_OPERATION = -38; protected static final int ALREADY_EXISTS = -17; public static final int NO_ERROR = 0; private final Context mContext; diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java index 5e4fabd..a9a0757 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/integration/CameraDeviceBinderTest.java @@ -307,4 +307,49 @@ public class CameraDeviceBinderTest extends AndroidTestCase { assertNotNull(info.get(CameraPropertiesKeys.Scaler.AVAILABLE_FORMATS)); } + @SmallTest + public void testWaitUntilIdle() throws Exception { + CameraMetadata metadata = new CameraMetadata(); + assertTrue(metadata.isEmpty()); + + CaptureRequest request = new CaptureRequest(); + assertTrue(request.isEmpty()); + + // Create default request from template. + int status = mCameraUser.createDefaultRequest(TEMPLATE_PREVIEW, /* out */metadata); + assertEquals(CameraBinderTestUtils.NO_ERROR, status); + assertFalse(metadata.isEmpty()); + + request.swap(metadata); + assertFalse(request.isEmpty()); + assertTrue(metadata.isEmpty()); + + SurfaceTexture surfaceTexture = new SurfaceTexture(/* ignored */0); + surfaceTexture.setDefaultBufferSize(640, 480); + Surface surface = new Surface(surfaceTexture); + + // Create stream first. Pre-requisite to submitting a request using that + // stream. + + int streamId = mCameraUser.createStream(/* ignored */10, /* ignored */20, /* ignored */30, + surface); + assertEquals(0, streamId); + + request.addTarget(surface); + + int requestIdStreaming = mCameraUser.submitRequest(request, /* streaming */true); + assertTrue("Request IDs should be non-negative", requestIdStreaming >= 0); + + // Test Bad case first: waitUntilIdle when there is active repeating request + status = mCameraUser.waitUntilIdle(); + assertEquals("waitUntilIdle is invalid operation when there is active repeating request", + CameraBinderTestUtils.INVALID_OPERATION, status); + + // Test good case, waitUntilIdle when there is no active repeating request + status = mCameraUser.cancelRequest(requestIdStreaming); + assertEquals(CameraBinderTestUtils.NO_ERROR, status); + status = mCameraUser.waitUntilIdle(); + assertEquals(CameraBinderTestUtils.NO_ERROR, status); + } + } |