Fields Summary |
---|
private String | TAG |
private boolean | rawPreviewCallbackResult |
private boolean | shutterCallbackResult |
private boolean | rawPictureCallbackResult |
private boolean | jpegPictureCallbackResult |
private static int | WAIT_FOR_COMMAND_TO_COMPLETE |
private static final int | CAMERA_ID |
private RawPreviewCallback | mRawPreviewCallback |
private TestShutterCallback | mShutterCallback |
private RawPictureCallback | mRawPictureCallback |
private JpegPictureCallback | mJpegPictureCallback |
private boolean | mInitialized |
private android.os.Looper | mLooper |
private final android.os.ConditionVariable | mPreviewDone |
private final android.os.ConditionVariable | mSnapshotDone |
android.hardware.Camera | mCamera |
android.content.Context | mContext |
Methods Summary |
---|
private void | checkPreviewCallback()
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "start preview");
mCamera.startPreview();
waitForPreviewDone();
mCamera.setPreviewCallback(null);
} catch (Exception e) {
Log.v(TAG, e.toString());
}
|
private void | checkTakePicture()
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "Start preview");
mCamera.startPreview();
waitForPreviewDone();
mCamera.setPreviewCallback(null);
mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
waitForSnapshotDone();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
|
private void | initializeMessageLooper()
final ConditionVariable startDone = new ConditionVariable();
Log.v(TAG, "start looper");
new Thread() {
@Override
public void run() {
// Set up a looper to be used by camera.
Looper.prepare();
Log.v(TAG, "start loopRun");
// Save the looper so that we can terminate this thread
// after we are done with it.
mLooper = Looper.myLooper();
mCamera = Camera.open(CAMERA_ID);
startDone.open();
Looper.loop(); // Blocks forever until Looper.quit() is called.
Log.v(TAG, "initializeMessageLooper: quit.");
}
}.start();
if (!startDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
fail("initializeMessageLooper: start timeout");
}
|
protected void | setUp()
super.setUp();
|
private void | terminateMessageLooper()
mLooper.quit();
// Looper.quit() is asynchronous. The looper may still has some
// preview callbacks in the queue after quit is called. The preview
// callback still uses the camera object (setHasPreviewCallback).
// After camera is released, RuntimeException will be thrown from
// the method. So we need to join the looper thread here.
mLooper.getThread().join();
mCamera.release();
|
public void | testCheckPreview()
initializeMessageLooper();
mCamera.setPreviewCallback(mRawPreviewCallback);
checkPreviewCallback();
terminateMessageLooper();
assertTrue("RawPreviewCallbackResult", rawPreviewCallbackResult);
|
public void | testTakePicture()
initializeMessageLooper();
mCamera.setPreviewCallback(mRawPreviewCallback);
checkTakePicture();
terminateMessageLooper();
assertTrue("shutterCallbackResult", shutterCallbackResult);
assertTrue("rawPictureCallbackResult", rawPictureCallbackResult);
assertTrue("jpegPictureCallbackResult", jpegPictureCallbackResult);
|
private void | waitForPreviewDone()
if (!mPreviewDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
Log.v(TAG, "waitForPreviewDone: timeout");
}
mPreviewDone.close();
|
private void | waitForSnapshotDone()
if (!mSnapshotDone.block(MediaNames.WAIT_SNAPSHOT_TIME)) {
// timeout could be expected or unexpected. The caller will decide.
Log.v(TAG, "waitForSnapshotDone: timeout");
}
mSnapshotDone.close();
|