CameraTestpublic class CameraTest extends android.test.ActivityInstrumentationTestCase Junit / Instrumentation test case for the camera api |
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 RawPreviewCallback | mRawPreviewCallback | private TestShutterCallback | mShutterCallback | private RawPictureCallback | mRawPictureCallback | private JpegPictureCallback | mJpegPictureCallback | private boolean | mInitialized | private android.os.Looper | mLooper | private final Object | lock | private final Object | previewDone | android.hardware.Camera | mCamera | android.content.Context | mContext |
Constructors Summary |
---|
public CameraTest()
super("com.android.mediaframeworktest", MediaFrameworkTest.class);
|
Methods Summary |
---|
private void | checkPreviewCallback()
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "start preview");
mCamera.startPreview();
synchronized (previewDone) {
try {
previewDone.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
Log.v(TAG, "setPreview done");
} catch (Exception e) {
Log.v(TAG, "wait was interrupted.");
}
}
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();
synchronized (previewDone) {
try {
previewDone.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
Log.v(TAG, "Preview Done");
} catch (Exception e) {
Log.v(TAG, "wait was interrupted.");
}
}
mCamera.setPreviewCallback(null);
mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
Thread.sleep(MediaNames.WAIT_LONG);
} catch (Exception e) {
Log.v(TAG, e.toString());
}
| private void | initializeMessageLooper()
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();
synchronized (lock) {
mInitialized = true;
lock.notify();
}
Looper.loop(); // Blocks forever until Looper.quit() is called.
Log.v(TAG, "initializeMessageLooper: quit.");
}
}.start();
| protected void | setUp()
super.setUp();
| private void | terminateMessageLooper()
mLooper.quit();
//TODO yslau : take out the sleep until bug#1693519 fix
try {
Thread.sleep(1000);
} catch (Exception e){
Log.v(TAG, e.toString());
}
mCamera.release();
| public void | testCheckPreview()
synchronized (lock) {
initializeMessageLooper();
try {
lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch(Exception e) {
Log.v(TAG, "wait was interrupted.");
}
}
mCamera.setPreviewCallback(mRawPreviewCallback);
checkPreviewCallback();
terminateMessageLooper();
assertTrue("RawPreviewCallbackResult", rawPreviewCallbackResult);
| public void | testTakePicture()
synchronized (lock) {
initializeMessageLooper();
try {
lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch(Exception e) {
Log.v(TAG, "runTestOnMethod: wait was interrupted.");
}
}
mCamera.setPreviewCallback(mRawPreviewCallback);
checkTakePicture();
terminateMessageLooper();
assertTrue("shutterCallbackResult", shutterCallbackResult);
assertTrue("rawPictureCallbackResult", rawPictureCallbackResult);
assertTrue("jpegPictureCallbackResult", jpegPictureCallbackResult);
|
|