Add instrumentation tests and codecov support (#18)
* Add instrumentation tests * Run androidTests on api 22 * Fix lint errors * Nits * Add codecov support * Shieldpull/19/head
parent
87e73aec5d
commit
41f9f51ef9
@ -0,0 +1,58 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.annotation.TargetApi; |
||||
import android.hardware.Camera; |
||||
import android.hardware.camera2.CameraCharacteristics; |
||||
import android.os.Parcel; |
||||
import android.support.test.filters.SmallTest; |
||||
import android.support.test.runner.AndroidJUnit4; |
||||
import android.util.SizeF; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@SmallTest |
||||
public class AspectRatioTest { |
||||
|
||||
@Test |
||||
public void testConstructor() { |
||||
AspectRatio ratio = AspectRatio.of(50, 10); |
||||
assertEquals(ratio.getX(), 5f, 0); |
||||
assertEquals(ratio.getY(), 1f, 0); |
||||
assertEquals(ratio.toString(), "5:1"); |
||||
} |
||||
|
||||
@Test |
||||
public void testEquals() { |
||||
AspectRatio ratio = AspectRatio.of(50, 10); |
||||
AspectRatio ratio1 = AspectRatio.of(5, 1); |
||||
assertTrue(ratio.equals(ratio1)); |
||||
|
||||
Size size = new Size(500, 100); |
||||
assertTrue(ratio.matches(size)); |
||||
} |
||||
|
||||
@Test |
||||
public void testInverse() { |
||||
AspectRatio ratio = AspectRatio.of(50, 10); |
||||
AspectRatio inverse = ratio.inverse(); |
||||
assertEquals(inverse.getX(), 1f, 0); |
||||
assertEquals(inverse.getY(), 5f, 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testParcelable() { |
||||
AspectRatio ratio = AspectRatio.of(50, 10); |
||||
Parcel parcel = Parcel.obtain(); |
||||
ratio.writeToParcel(parcel, ratio.describeContents()); |
||||
|
||||
parcel.setDataPosition(0); |
||||
AspectRatio other = AspectRatio.CREATOR.createFromParcel(parcel); |
||||
assertEquals(ratio, other); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,132 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.hardware.Camera; |
||||
import android.support.test.filters.SmallTest; |
||||
import android.support.test.runner.AndroidJUnit4; |
||||
import android.test.ActivityInstrumentationTestCase2; |
||||
import android.test.InstrumentationTestCase; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.HashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
import static org.mockito.Mockito.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@SmallTest |
||||
public class CameraOptions1Test { |
||||
|
||||
@Test |
||||
public void testEmpty() { |
||||
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class)); |
||||
assertTrue(o.getSupportedWhiteBalance().isEmpty()); |
||||
assertTrue(o.getSupportedFlash().isEmpty()); |
||||
assertTrue(o.getSupportedHdr().isEmpty()); |
||||
assertFalse(o.isAutoFocusSupported()); |
||||
assertFalse(o.isExposureCorrectionSupported()); |
||||
assertFalse(o.isVideoSnapshotSupported()); |
||||
assertFalse(o.isZoomSupported()); |
||||
assertEquals(o.getExposureCorrectionMaxValue(), 0f, 0); |
||||
assertEquals(o.getExposureCorrectionMinValue(), 0f, 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testFacing() { |
||||
Set<Integer> supported = new HashSet<>(); |
||||
Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); |
||||
for (int i = 0, count = Camera.getNumberOfCameras(); i < count; i++) { |
||||
Camera.getCameraInfo(i, cameraInfo); |
||||
supported.add(cameraInfo.facing); |
||||
} |
||||
|
||||
CameraOptions o = new CameraOptions(mock(Camera.Parameters.class)); |
||||
Mapper m = new Mapper.Mapper1(); |
||||
Set<Facing> s = o.getSupportedFacing(); |
||||
assertEquals(o.getSupportedFacing().size(), supported.size()); |
||||
for (Facing facing : s) { |
||||
assertTrue(supported.contains(m.<Integer>map(facing))); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void testWhiteBalance() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.getSupportedWhiteBalance()).thenReturn(Arrays.asList( |
||||
Camera.Parameters.WHITE_BALANCE_AUTO, // Supported
|
||||
Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT, // Supported
|
||||
Camera.Parameters.WHITE_BALANCE_SHADE // Not supported
|
||||
)); |
||||
|
||||
CameraOptions o = new CameraOptions(params); |
||||
assertEquals(o.getSupportedWhiteBalance().size(), 2); |
||||
assertTrue(o.getSupportedWhiteBalance().contains(WhiteBalance.AUTO)); |
||||
assertTrue(o.getSupportedWhiteBalance().contains(WhiteBalance.CLOUDY)); |
||||
assertTrue(o.supports(WhiteBalance.AUTO)); |
||||
assertTrue(o.supports(WhiteBalance.CLOUDY)); |
||||
} |
||||
|
||||
@Test |
||||
public void testFlash() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.getSupportedFlashModes()).thenReturn(Arrays.asList( |
||||
Camera.Parameters.FLASH_MODE_AUTO, // Supported
|
||||
Camera.Parameters.FLASH_MODE_TORCH, // Supported
|
||||
Camera.Parameters.FLASH_MODE_RED_EYE // Not supported
|
||||
)); |
||||
|
||||
CameraOptions o = new CameraOptions(params); |
||||
assertEquals(o.getSupportedFlash().size(), 2); |
||||
assertTrue(o.getSupportedFlash().contains(Flash.AUTO)); |
||||
assertTrue(o.getSupportedFlash().contains(Flash.TORCH)); |
||||
assertTrue(o.supports(Flash.AUTO)); |
||||
assertTrue(o.supports(Flash.TORCH)); |
||||
} |
||||
|
||||
@Test |
||||
public void testHdr() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.getSupportedSceneModes()).thenReturn(Arrays.asList( |
||||
Camera.Parameters.SCENE_MODE_AUTO, // Supported
|
||||
Camera.Parameters.SCENE_MODE_HDR, // Supported
|
||||
Camera.Parameters.SCENE_MODE_FIREWORKS // Not supported
|
||||
)); |
||||
|
||||
CameraOptions o = new CameraOptions(params); |
||||
assertEquals(o.getSupportedHdr().size(), 2); |
||||
assertTrue(o.getSupportedHdr().contains(Hdr.OFF)); |
||||
assertTrue(o.getSupportedHdr().contains(Hdr.ON)); |
||||
assertTrue(o.supports(Hdr.OFF)); |
||||
assertTrue(o.supports(Hdr.ON)); |
||||
} |
||||
|
||||
@Test |
||||
public void testBooleanFlags() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.isVideoSnapshotSupported()).thenReturn(true); |
||||
when(params.isZoomSupported()).thenReturn(true); |
||||
when(params.getSupportedFocusModes()).thenReturn(Arrays.asList(Camera.Parameters.FOCUS_MODE_AUTO)); |
||||
CameraOptions o = new CameraOptions(params); |
||||
assertTrue(o.isVideoSnapshotSupported()); |
||||
assertTrue(o.isZoomSupported()); |
||||
assertTrue(o.isAutoFocusSupported()); |
||||
} |
||||
|
||||
@Test |
||||
public void testExposureCorrection() { |
||||
Camera.Parameters params = mock(Camera.Parameters.class); |
||||
when(params.getMaxExposureCompensation()).thenReturn(10); |
||||
when(params.getMinExposureCompensation()).thenReturn(-10); |
||||
when(params.getExposureCompensationStep()).thenReturn(0.5f); |
||||
CameraOptions o = new CameraOptions(params); |
||||
assertTrue(o.isExposureCorrectionSupported()); |
||||
assertEquals(o.getExposureCorrectionMinValue(), -10f * 0.5f, 0f); |
||||
assertEquals(o.getExposureCorrectionMaxValue(), 10f * 0.5f, 0f); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,279 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.app.Instrumentation; |
||||
import android.content.Context; |
||||
import android.hardware.Camera; |
||||
import android.os.Looper; |
||||
import android.support.test.InstrumentationRegistry; |
||||
import android.support.test.filters.MediumTest; |
||||
import android.support.test.runner.AndroidJUnit4; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import org.junit.After; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
import static org.mockito.Mockito.*; |
||||
|
||||
import static android.view.View.MeasureSpec.*; |
||||
import static android.view.ViewGroup.LayoutParams.*; |
||||
|
||||
@RunWith(AndroidJUnit4.class) |
||||
@MediumTest |
||||
public class CameraViewTest { |
||||
|
||||
private CameraView cameraView; |
||||
private MockCameraController mockController; |
||||
private Preview mockPreview; |
||||
|
||||
@Before |
||||
public void setUp() { |
||||
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
Context context = InstrumentationRegistry.getContext(); |
||||
cameraView = new CameraView(context) { |
||||
@Override |
||||
protected CameraController instantiateCameraController(CameraCallbacks callbacks, Preview preview) { |
||||
mockController = new MockCameraController(callbacks, preview); |
||||
return mockController; |
||||
} |
||||
|
||||
@Override |
||||
protected Preview instantiatePreview(Context context, ViewGroup container) { |
||||
mockPreview = new MockPreview(context, container); |
||||
return mockPreview; |
||||
} |
||||
}; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@After |
||||
public void tearDown() { |
||||
cameraView = null; |
||||
mockController = null; |
||||
mockPreview = null; |
||||
} |
||||
|
||||
//region testDefaults
|
||||
|
||||
@Test |
||||
public void testNotStarted() { |
||||
assertFalse(cameraView.isStarted()); |
||||
assertNull(cameraView.getCameraOptions()); |
||||
assertNull(cameraView.getExtraProperties()); |
||||
assertNull(cameraView.getPreviewSize()); |
||||
assertNull(cameraView.getCaptureSize()); |
||||
assertNull(cameraView.getSnapshotSize()); |
||||
} |
||||
|
||||
@Test |
||||
public void testDefaults() { |
||||
// CameraController
|
||||
assertEquals(cameraView.getFlash(), Flash.DEFAULT); |
||||
assertEquals(cameraView.getFacing(), Facing.DEFAULT); |
||||
assertEquals(cameraView.getGrid(), Grid.DEFAULT); |
||||
assertEquals(cameraView.getWhiteBalance(), WhiteBalance.DEFAULT); |
||||
assertEquals(cameraView.getSessionType(), SessionType.DEFAULT); |
||||
assertEquals(cameraView.getHdr(), Hdr.DEFAULT); |
||||
assertEquals(cameraView.getVideoQuality(), VideoQuality.DEFAULT); |
||||
|
||||
// Self managed
|
||||
assertEquals(cameraView.getExposureCorrection(), 0f, 0f); |
||||
assertEquals(cameraView.getZoom(), 0f, 0f); |
||||
assertEquals(cameraView.getCropOutput(), CameraView.DEFAULT_CROP_OUTPUT); |
||||
assertEquals(cameraView.getJpegQuality(), CameraView.DEFAULT_JPEG_QUALITY); |
||||
assertEquals(cameraView.getGestureAction(Gesture.TAP), GestureAction.DEFAULT_TAP); |
||||
assertEquals(cameraView.getGestureAction(Gesture.LONG_TAP), GestureAction.DEFAULT_LONG_TAP); |
||||
assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.DEFAULT_PINCH); |
||||
assertEquals(cameraView.getGestureAction(Gesture.SCROLL_HORIZONTAL), GestureAction.DEFAULT_SCROLL_HORIZONTAL); |
||||
assertEquals(cameraView.getGestureAction(Gesture.SCROLL_VERTICAL), GestureAction.DEFAULT_SCROLL_VERTICAL); |
||||
} |
||||
|
||||
//endregion
|
||||
|
||||
//region testGesture
|
||||
|
||||
@Test |
||||
public void testGesture_mapAndClear() { |
||||
// Assignable
|
||||
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); |
||||
assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.ZOOM); |
||||
|
||||
// Not assignable: This is like clearing
|
||||
cameraView.mapGesture(Gesture.PINCH, GestureAction.CAPTURE); |
||||
assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.NONE); |
||||
|
||||
// Test clearing
|
||||
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); |
||||
cameraView.clearGesture(Gesture.PINCH); |
||||
assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.NONE); |
||||
} |
||||
|
||||
@Test |
||||
public void testGesture_enablingDisablingLayouts() { |
||||
cameraView.clearGesture(Gesture.TAP); |
||||
cameraView.clearGesture(Gesture.LONG_TAP); |
||||
cameraView.clearGesture(Gesture.PINCH); |
||||
cameraView.clearGesture(Gesture.SCROLL_HORIZONTAL); |
||||
cameraView.clearGesture(Gesture.SCROLL_VERTICAL); |
||||
|
||||
// PinchGestureLayout
|
||||
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); |
||||
assertTrue(cameraView.mPinchGestureLayout.enabled()); |
||||
cameraView.clearGesture(Gesture.PINCH); |
||||
assertFalse(cameraView.mPinchGestureLayout.enabled()); |
||||
|
||||
// TapGestureLayout
|
||||
cameraView.mapGesture(Gesture.TAP, GestureAction.CAPTURE); |
||||
assertTrue(cameraView.mTapGestureLayout.enabled()); |
||||
cameraView.clearGesture(Gesture.TAP); |
||||
assertFalse(cameraView.mPinchGestureLayout.enabled()); |
||||
|
||||
// ScrollGestureLayout
|
||||
cameraView.mapGesture(Gesture.SCROLL_HORIZONTAL, GestureAction.ZOOM); |
||||
assertTrue(cameraView.mScrollGestureLayout.enabled()); |
||||
cameraView.clearGesture(Gesture.SCROLL_HORIZONTAL); |
||||
assertFalse(cameraView.mScrollGestureLayout.enabled()); |
||||
} |
||||
|
||||
//endregion
|
||||
|
||||
//region testMeasure
|
||||
|
||||
private void mockPreviewSize() { |
||||
Size size = new Size(900, 1600); |
||||
mockController.setMockPreviewSize(size); |
||||
} |
||||
|
||||
@Test |
||||
public void testMeasure_matchParentBoth() { |
||||
mockPreviewSize(); |
||||
|
||||
// Respect parent/layout constraints on both dimensions.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(500, EXACTLY), |
||||
makeMeasureSpec(500, EXACTLY)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 500); |
||||
assertEquals(cameraView.getMeasuredHeight(), 500); |
||||
|
||||
// Even if the parent ViewGroup passes AT_MOST
|
||||
cameraView.measure( |
||||
makeMeasureSpec(500, AT_MOST), |
||||
makeMeasureSpec(500, AT_MOST)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 500); |
||||
assertEquals(cameraView.getMeasuredHeight(), 500); |
||||
|
||||
cameraView.measure( |
||||
makeMeasureSpec(500, EXACTLY), |
||||
makeMeasureSpec(500, AT_MOST)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 500); |
||||
assertEquals(cameraView.getMeasuredHeight(), 500); |
||||
} |
||||
|
||||
@Test |
||||
public void testMeasure_wrapContentBoth() { |
||||
mockPreviewSize(); |
||||
|
||||
// Respect parent constraints, but fit aspect ratio.
|
||||
// Fit into a 160x160 parent so we espect final width to be 90.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(160, AT_MOST), |
||||
makeMeasureSpec(160, AT_MOST)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 90); |
||||
assertEquals(cameraView.getMeasuredHeight(), 160); |
||||
} |
||||
|
||||
@Test |
||||
public void testMeasure_wrapContentSingle() { |
||||
mockPreviewSize(); |
||||
|
||||
// Respect MATCH_PARENT on height, change width to fit the aspect ratio.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(160, AT_MOST), |
||||
makeMeasureSpec(160, AT_MOST)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 90); |
||||
assertEquals(cameraView.getMeasuredHeight(), 160); |
||||
|
||||
// Respect MATCH_PARENT on width. Enlarge height trying to fit aspect ratio as much as possible.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(160, AT_MOST), |
||||
makeMeasureSpec(160, AT_MOST)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 160); |
||||
assertEquals(cameraView.getMeasuredHeight(), 160); |
||||
} |
||||
|
||||
@Test |
||||
public void testMeasure_scrollableContainer() { |
||||
mockPreviewSize(); |
||||
|
||||
// Assume a vertical scroll view. It will pass UNSPECIFIED as height.
|
||||
// We respect MATCH_PARENT on width (160), and enlarge height to match the aspect ratio.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(160, AT_MOST), |
||||
makeMeasureSpec(0, UNSPECIFIED)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 160); |
||||
assertEquals(cameraView.getMeasuredHeight(), 160f * (16f / 9f), 1f); // Leave a margin
|
||||
|
||||
// Assume a view scrolling in both dimensions. It will pass UNSPECIFIED.
|
||||
// In this case we must fit the exact preview dimension.
|
||||
cameraView.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); |
||||
cameraView.measure( |
||||
makeMeasureSpec(0, UNSPECIFIED), |
||||
makeMeasureSpec(0, UNSPECIFIED)); |
||||
assertEquals(cameraView.getMeasuredWidth(), 900); |
||||
assertEquals(cameraView.getMeasuredHeight(), 1600); |
||||
} |
||||
|
||||
//endregion
|
||||
|
||||
//region Zoom, ExposureCorrection
|
||||
|
||||
@Test |
||||
public void testZoom() { |
||||
cameraView.setZoom(0.5f); |
||||
assertEquals(cameraView.getZoom(), 0.5f, 0f); |
||||
cameraView.setZoom(-10f); |
||||
assertEquals(cameraView.getZoom(), 0f, 0f); |
||||
cameraView.setZoom(10f); |
||||
assertEquals(cameraView.getZoom(), 1f, 0f); |
||||
} |
||||
|
||||
@Test |
||||
public void testExposureCorrection() { |
||||
// This needs a valid CameraOptions value.
|
||||
CameraOptions o = mock(CameraOptions.class); |
||||
when(o.getExposureCorrectionMinValue()).thenReturn(-10f); |
||||
when(o.getExposureCorrectionMaxValue()).thenReturn(10f); |
||||
mockController.setMockCameraOptions(o); |
||||
|
||||
cameraView.setExposureCorrection(5f); |
||||
assertEquals(cameraView.getExposureCorrection(), 5f, 0f); |
||||
cameraView.setExposureCorrection(-100f); |
||||
assertEquals(cameraView.getExposureCorrection(), -10f, 0f); |
||||
cameraView.setExposureCorrection(100f); |
||||
assertEquals(cameraView.getExposureCorrection(), 10f, 0f); |
||||
} |
||||
|
||||
//endregion
|
||||
|
||||
// TODO: test setLocation
|
||||
|
||||
// TODO: test touch events
|
||||
|
||||
// TODO: test permissions and start() stop() isStarted()
|
||||
|
||||
// TODO: test CameraCallbacks
|
||||
|
||||
} |
@ -0,0 +1,124 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.graphics.PointF; |
||||
import android.location.Location; |
||||
import android.support.annotation.NonNull; |
||||
import android.support.annotation.Nullable; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class MockCameraController extends CameraController { |
||||
|
||||
MockCameraController(CameraView.CameraCallbacks callback, Preview preview) { |
||||
super(callback, preview); |
||||
} |
||||
|
||||
void setMockCameraOptions(CameraOptions options) { |
||||
mOptions = options; |
||||
} |
||||
|
||||
void setMockPreviewSize(Size size) { |
||||
mPreviewSize = size; |
||||
} |
||||
|
||||
@Override |
||||
void onStart() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
void onStop() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
boolean setZoom(float zoom) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean setExposureCorrection(float EVvalue) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
void setFacing(Facing facing) { |
||||
mFacing = facing; |
||||
} |
||||
|
||||
@Override |
||||
void setFlash(Flash flash) { |
||||
mFlash = flash; |
||||
} |
||||
|
||||
@Override |
||||
void setWhiteBalance(WhiteBalance whiteBalance) { |
||||
mWhiteBalance = whiteBalance; |
||||
} |
||||
|
||||
@Override |
||||
void setVideoQuality(VideoQuality videoQuality) { |
||||
mVideoQuality = videoQuality; |
||||
} |
||||
|
||||
@Override |
||||
void setSessionType(SessionType sessionType) { |
||||
mSessionType = sessionType; |
||||
} |
||||
|
||||
@Override |
||||
void setHdr(Hdr hdr) { |
||||
mHdr = hdr; |
||||
} |
||||
|
||||
@Override |
||||
void setLocation(Location location) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
boolean capturePicture() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean captureSnapshot() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean startVideo(@NonNull File file) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean endVideo() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean shouldFlipSizes() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
boolean isCameraOpened() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
boolean startAutoFocus(@Nullable Gesture gesture, PointF point) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onSurfaceChanged() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onSurfaceAvailable() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.otaliastudios.cameraview; |
||||
|
||||
|
||||
import android.content.Context; |
||||
import android.view.Surface; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
public class MockPreview extends Preview { |
||||
|
||||
public MockPreview(Context context, ViewGroup parent) { |
||||
super(context, parent); |
||||
} |
||||
|
||||
@Override |
||||
Surface getSurface() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
View getView() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
Class getOutputClass() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
boolean isReady() { |
||||
return true; |
||||
} |
||||
} |
Loading…
Reference in new issue