forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request flutter#9 from bottlepay/android-rework-test-expos…
…urelock-feature Android rework test exposure lock feature
- Loading branch information
Showing
4 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...rc/test/java/io/flutter/plugins/camera/features/exposurelock/ExposureLockFeatureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.flutter.plugins.camera.features.exposurelock; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import android.hardware.camera2.CaptureRequest; | ||
import io.flutter.plugins.camera.CameraProperties; | ||
import org.junit.Test; | ||
|
||
public class ExposureLockFeatureTest { | ||
@Test | ||
public void getDebugName_should_return_the_name_of_the_feature() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
|
||
assertEquals("ExposureLockFeature", exposureLockFeature.getDebugName()); | ||
} | ||
|
||
@Test | ||
public void getValue_should_return_auto_if_not_set() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
|
||
assertEquals(ExposureMode.auto, exposureLockFeature.getValue()); | ||
} | ||
|
||
@Test | ||
public void getValue_should_echo_the_set_value() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
ExposureMode expectedValue = ExposureMode.locked; | ||
|
||
exposureLockFeature.setValue(expectedValue); | ||
ExposureMode actualValue = exposureLockFeature.getValue(); | ||
|
||
assertEquals(expectedValue, actualValue); | ||
} | ||
|
||
@Test | ||
public void checkIsSupported_should_return_true() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
|
||
assertTrue(exposureLockFeature.checkIsSupported()); | ||
} | ||
|
||
@Test | ||
public void updateBuilder_should_set_control_ae_lock_to_false_when_auto_exposure_is_set_to_auto() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
CaptureRequest.Builder mockBuilder = mock(CaptureRequest.Builder.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
|
||
|
||
exposureLockFeature.setValue(ExposureMode.auto); | ||
exposureLockFeature.updateBuilder(mockBuilder); | ||
|
||
verify(mockBuilder, times(1)).set(CaptureRequest.CONTROL_AE_LOCK, false); | ||
} | ||
|
||
@Test | ||
public void updateBuilder_should_set_control_ae_lock_to_false_when_auto_exposure_is_set_to_locked() { | ||
CameraProperties mockCameraProperties = mock(CameraProperties.class); | ||
CaptureRequest.Builder mockBuilder = mock(CaptureRequest.Builder.class); | ||
ExposureLockFeature exposureLockFeature = new ExposureLockFeature(mockCameraProperties); | ||
|
||
|
||
exposureLockFeature.setValue(ExposureMode.locked); | ||
exposureLockFeature.updateBuilder(mockBuilder); | ||
|
||
verify(mockBuilder, times(1)).set(CaptureRequest.CONTROL_AE_LOCK, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters