|
|
@ -206,6 +206,7 @@ public class CameraViewTest extends BaseTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testGestureAction_zoom() { |
|
|
|
public void testGestureAction_zoom() { |
|
|
|
mockController.mockStarted(true); |
|
|
|
mockController.mockStarted(true); |
|
|
|
|
|
|
|
mockController.mZoomChanged = false; |
|
|
|
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0); |
|
|
|
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0); |
|
|
|
ui(new Runnable() { |
|
|
|
ui(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -214,10 +215,18 @@ public class CameraViewTest extends BaseTest { |
|
|
|
public boolean onTouchEvent(MotionEvent event) { return true; } |
|
|
|
public boolean onTouchEvent(MotionEvent event) { return true; } |
|
|
|
}; |
|
|
|
}; |
|
|
|
cameraView.mPinchGestureLayout.setGestureType(Gesture.PINCH); |
|
|
|
cameraView.mPinchGestureLayout.setGestureType(Gesture.PINCH); |
|
|
|
|
|
|
|
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
mockController.mZoomChanged = false; |
|
|
|
|
|
|
|
cameraView.mapGesture(Gesture.PINCH, GestureAction.ZOOM); |
|
|
|
// If factor is 0, we return the same value. The controller should not be notified.
|
|
|
|
|
|
|
|
cameraView.mPinchGestureLayout.mFactor = 0f; |
|
|
|
|
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
|
|
|
|
assertFalse(mockController.mZoomChanged); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For larger factors, the value is scaled. The controller should be notified.
|
|
|
|
|
|
|
|
cameraView.mPinchGestureLayout.mFactor = 1f; |
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
assertTrue(mockController.mZoomChanged); |
|
|
|
assertTrue(mockController.mZoomChanged); |
|
|
|
} |
|
|
|
} |
|
|
@ -230,7 +239,7 @@ public class CameraViewTest extends BaseTest { |
|
|
|
when(o.getExposureCorrectionMaxValue()).thenReturn(10f); |
|
|
|
when(o.getExposureCorrectionMaxValue()).thenReturn(10f); |
|
|
|
mockController.setMockCameraOptions(o); |
|
|
|
mockController.setMockCameraOptions(o); |
|
|
|
mockController.mockStarted(true); |
|
|
|
mockController.mockStarted(true); |
|
|
|
|
|
|
|
mockController.mExposureCorrectionChanged = false; |
|
|
|
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0); |
|
|
|
MotionEvent event = MotionEvent.obtain(0L, 0L, 0, 0f, 0f, 0); |
|
|
|
ui(new Runnable() { |
|
|
|
ui(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -239,10 +248,17 @@ public class CameraViewTest extends BaseTest { |
|
|
|
public boolean onTouchEvent(MotionEvent event) { return true; } |
|
|
|
public boolean onTouchEvent(MotionEvent event) { return true; } |
|
|
|
}; |
|
|
|
}; |
|
|
|
cameraView.mScrollGestureLayout.setGestureType(Gesture.SCROLL_HORIZONTAL); |
|
|
|
cameraView.mScrollGestureLayout.setGestureType(Gesture.SCROLL_HORIZONTAL); |
|
|
|
|
|
|
|
cameraView.mapGesture(Gesture.SCROLL_HORIZONTAL, GestureAction.EXPOSURE_CORRECTION); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
mockController.mExposureCorrectionChanged = false; |
|
|
|
|
|
|
|
cameraView.mapGesture(Gesture.SCROLL_HORIZONTAL, GestureAction.EXPOSURE_CORRECTION); |
|
|
|
// If factor is 0, we return the same value. The controller should not be notified.
|
|
|
|
|
|
|
|
cameraView.mScrollGestureLayout.mFactor = 0f; |
|
|
|
|
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
|
|
|
|
assertFalse(mockController.mExposureCorrectionChanged); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For larger factors, the value is scaled. The controller should be notified.
|
|
|
|
|
|
|
|
cameraView.mScrollGestureLayout.mFactor = 1f; |
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
cameraView.dispatchTouchEvent(event); |
|
|
|
assertTrue(mockController.mExposureCorrectionChanged); |
|
|
|
assertTrue(mockController.mExposureCorrectionChanged); |
|
|
|
} |
|
|
|
} |
|
|
|