use of com.google.testing.littlemock.AppDataDirGuesser in project android_packages_apps_Camera by CyanogenMod.
the class CameraTestCase method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
AppDataDirGuesser.setInstance(new AppDataDirGuesser() {
@Override
public File guessSuitableDirectoryForGeneratedClasses() {
return getInstrumentation().getTargetContext().getCacheDir();
}
});
AppDataDirGuesser.getsInstance().guessSuitableDirectoryForGeneratedClasses();
LittleMock.initMocks(this);
mCameraInfo = new CameraInfo[2];
mCameraInfo[0] = new CameraInfo();
mCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
mCameraInfo[1] = new CameraInfo();
mCameraInfo[1].facing = CameraInfo.CAMERA_FACING_FRONT;
mMockCamera = new CameraProxy[2];
mMockCamera[0] = mMockBackCamera;
mMockCamera[1] = mMockFrontCamera;
doReturn(getParameters()).when(mMockCamera[0]).getParameters();
doReturn(getParameters()).when(mMockCamera[1]).getParameters();
mOneCameraInfo = new CameraInfo[1];
mOneCameraInfo[0] = new CameraInfo();
mOneCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
mOneMockCamera = new CameraProxy[1];
mOneMockCamera[0] = mMockBackCamera;
doReturn(getParameters()).when(mOneMockCamera[0]).getParameters();
// Mock takePicture call.
doAnswer(mTakePictureCallable).when(mMockBackCamera).takePicture(mShutterCallback.capture(), mRawPictureCallback.capture(), (PictureCallback) anyObject(), mJpegPictureCallback.capture());
// Mock autoFocus call.
doAnswer(mAutoFocusCallable).when(mMockBackCamera).autoFocus(mAutoFocusCallback.capture());
}
Aggregations