Camera2UtilsTestpublic class Camera2UtilsTest extends Camera2DeviceTester
Methods Summary |
---|
public void | captureListenerSplitter()
CaptureCallback firstBackingListener = mock(CaptureCallback.class);
CaptureCallback secondBackingListener = mock(CaptureCallback.class);
captureListenerSplitterAllCallbacksReceived(
new Camera2CaptureCallbackSplitter(firstBackingListener, secondBackingListener),
firstBackingListener, secondBackingListener);
| private void | captureListenerSplitterAllCallbacksReceived(android.hardware.camera2.CameraCaptureSession.CaptureCallback splitter, android.hardware.camera2.CameraCaptureSession.CaptureCallback terminals)
splitter.onCaptureCompleted(null, null, null);
for (CaptureCallback each : terminals) {
verify(each).onCaptureCompleted(null, null, null);
}
splitter.onCaptureFailed(null, null, null);
for (CaptureCallback each : terminals) {
verify(each).onCaptureFailed(null, null, null);
}
splitter.onCaptureProgressed(null, null, null);
for (CaptureCallback each : terminals) {
verify(each).onCaptureProgressed(null, null, null);
}
splitter.onCaptureSequenceAborted(null, 0);
for (CaptureCallback each : terminals) {
verify(each).onCaptureSequenceAborted(null, 0);
}
splitter.onCaptureSequenceCompleted(null, 0, 0L);
for (CaptureCallback each : terminals) {
verify(each).onCaptureSequenceCompleted(null, 0, 0L);
}
splitter.onCaptureStarted(null, null, 0L, 1L);
for (CaptureCallback each : terminals) {
verify(each).onCaptureStarted(null, null, 0L, 1L);
}
| public void | captureListenerSplitterEmpty()
captureListenerSplitterAllCallbacksReceived(new Camera2CaptureCallbackSplitter());
| public void | captureListenerSplitterMultipleNulls()
captureListenerSplitterAllCallbacksReceived(
new Camera2CaptureCallbackSplitter(null, null, null));
| public void | captureListenerSplitterNoNpe()
captureListenerSplitterAllCallbacksReceived(
new Camera2CaptureCallbackSplitter((CaptureCallback) null));
| public void | captureListenerSplitterValidAndNull()
CaptureCallback onlyRealBackingListener = mock(CaptureCallback.class);
captureListenerSplitterAllCallbacksReceived(
new Camera2CaptureCallbackSplitter(null, onlyRealBackingListener),
onlyRealBackingListener);
| public void | requestSettingsSet()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
// Try a boolean
requestSettingsSetAndForget(setUp, CaptureRequest.CONTROL_AE_LOCK, false);
requestSettingsSetAndForget(setUp, CaptureRequest.CONTROL_AE_LOCK, true);
// Try an int
requestSettingsSetAndForget(setUp, CaptureRequest.CONTROL_AE_MODE, 1);
requestSettingsSetAndForget(setUp, CaptureRequest.CONTROL_AE_MODE, -1);
requestSettingsSetAndForget(setUp, CaptureRequest.CONTROL_AE_MODE, 0);
// Try an int[]
requestSettingsSetAndForget(setUp, CaptureRequest.SENSOR_TEST_PATTERN_DATA, new int[] {1});
requestSettingsSetAndForget(setUp, CaptureRequest.SENSOR_TEST_PATTERN_DATA,
new int[] {2, 2});
| private void | requestSettingsSetAndAssertChanged(Camera2RequestSettingsSet settings, android.hardware.camera2.CaptureRequest.Key key, T value, boolean shouldHaveChanged)
long revision = settings.getRevision();
assertEquals(shouldHaveChanged, settings.set(key, value));
assertEquals(shouldHaveChanged ? revision + 1 : revision, settings.getRevision());
| private void | requestSettingsSetAndForget(Camera2RequestSettingsSet s, android.hardware.camera2.CaptureRequest.Key k, T v)
s.set(k, v);
assertEquals(v, s.get(k));
| public void | requestSettingsSetChangesReportedCorrectly()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, true);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, false);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, true, true);
| public void | requestSettingsSetCopyConstructor()
Camera2RequestSettingsSet original = new Camera2RequestSettingsSet();
Camera2RequestSettingsSet unchanged = new Camera2RequestSettingsSet(original);
requestSettingsSetAndForget(original, CaptureRequest.CONTROL_AE_LOCK, true);
Camera2RequestSettingsSet changed = new Camera2RequestSettingsSet(original);
assertEquals(true, changed.get(CaptureRequest.CONTROL_AE_LOCK));
| public void | requestSettingsSetCopyConstructorPerformsDeepCopy()
Camera2RequestSettingsSet original = new Camera2RequestSettingsSet();
requestSettingsSetAndForget(original, CaptureRequest.CONTROL_AE_LOCK, true);
Camera2RequestSettingsSet changed = new Camera2RequestSettingsSet(original);
requestSettingsSetAndForget(changed, CaptureRequest.CONTROL_AE_LOCK, false);
assertEquals(true, original.get(CaptureRequest.CONTROL_AE_LOCK));
| public void | requestSettingsSetCopyConstructorPreservesChangedStatus()
Camera2RequestSettingsSet original = new Camera2RequestSettingsSet();
Camera2RequestSettingsSet unchanged = new Camera2RequestSettingsSet(original);
assertEquals(original.getRevision(), unchanged.getRevision());
requestSettingsSetAndAssertChanged(original, CaptureRequest.CONTROL_AE_LOCK, true, true);
Camera2RequestSettingsSet changed = new Camera2RequestSettingsSet(original);
assertEquals(original.getRevision(), changed.getRevision());
assertNotSame(original.getRevision(), unchanged.getRevision());
| public void | requestSettingsSetDetectsNoopChanges()
Camera2RequestSettingsSet s = new Camera2RequestSettingsSet();
int[] one = {1}, two = {2};
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, one, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, one, false);
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, null, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, null, false);
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, two, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.SENSOR_TEST_PATTERN_DATA, two, false);
| public void | requestSettingsSetMatchesPrimitives()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertTrue(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, null));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, false));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, true));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, null);
assertTrue(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, null));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, false));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, true));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, false);
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, null));
assertTrue(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, false));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, true));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, true);
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, null));
assertFalse(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, false));
assertTrue(setUp.matches(CaptureRequest.CONTROL_AE_LOCK, true));
| public void | requestSettingsSetMatchesReferences()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertTrue(setUp.matches(CaptureRequest.SCALER_CROP_REGION, null));
assertFalse(setUp.matches(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, 0, 0)));
setUp.set(CaptureRequest.SCALER_CROP_REGION, null);
assertTrue(setUp.matches(CaptureRequest.SCALER_CROP_REGION, null));
assertFalse(setUp.matches(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, 0, 0)));
setUp.set(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, 0, 0));
assertFalse(setUp.matches(CaptureRequest.SCALER_CROP_REGION, null));
assertTrue(setUp.matches(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, 0, 0)));
assertFalse(setUp.matches(CaptureRequest.SCALER_CROP_REGION, new Rect(0, 0, 1, 1)));
| public void | requestSettingsSetNullArgToContains()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.contains(null);
| public void | requestSettingsSetNullArgToCopyConstructor()
Camera2RequestSettingsSet flop = new Camera2RequestSettingsSet(null);
| public void | requestSettingsSetNullArgToCreateRequest0()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.createRequest(null, CameraDevice.TEMPLATE_PREVIEW);
| public void | requestSettingsSetNullArgToCreateRequest02()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.createRequest(null, CameraDevice.TEMPLATE_PREVIEW, (Surface) null);
| public void | requestSettingsSetNullArgToCreateRequest2()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.createRequest(mCamera, CameraDevice.TEMPLATE_PREVIEW, (Surface) null);
| public void | requestSettingsSetNullArgToGet()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.get(null);
| public void | requestSettingsSetNullArgToSetKey()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.set(null, null);
| public void | requestSettingsSetNullArgToUnion()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertFalse(setUp.union(null));
assertEquals(0, setUp.getRevision());
| public void | requestSettingsSetNullArgToUnset()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
setUp.unset(null);
| public void | requestSettingsSetNullChangesRecorded()
Camera2RequestSettingsSet s = new Camera2RequestSettingsSet();
requestSettingsSetAndAssertChanged(s, CaptureRequest.CONTROL_CAPTURE_INTENT, null, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.CONTROL_CAPTURE_INTENT,
CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.CONTROL_CAPTURE_INTENT, null, true);
requestSettingsSetAndAssertChanged(s, CaptureRequest.CONTROL_CAPTURE_INTENT, null, false);
| public void | requestSettingsSetNullMeansDefault()
Camera2RequestSettingsSet s = new Camera2RequestSettingsSet();
CaptureRequest r1 = s.createRequest(mCamera, CameraDevice.TEMPLATE_PREVIEW);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW,
r1.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
requestSettingsSetAndForget(s, CaptureRequest.CONTROL_CAPTURE_INTENT,
CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE);
CaptureRequest r2 = s.createRequest(mCamera, CameraDevice.TEMPLATE_PREVIEW);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE,
r2.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
requestSettingsSetAndForget(s, CaptureRequest.CONTROL_CAPTURE_INTENT, null);
CaptureRequest r3 = s.createRequest(mCamera, CameraDevice.TEMPLATE_PREVIEW);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW,
r3.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
s.unset(CaptureRequest.CONTROL_CAPTURE_INTENT);
CaptureRequest r4 = s.createRequest(mCamera, CameraDevice.TEMPLATE_PREVIEW);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW,
r4.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
| public void | requestSettingsSetNullPreservedByUnions()
Camera2RequestSettingsSet master = new Camera2RequestSettingsSet();
requestSettingsSetAndForget(master, CaptureRequest.CONTROL_CAPTURE_INTENT,
CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW);
Camera2RequestSettingsSet slave = new Camera2RequestSettingsSet();
master.union(slave);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW,
master.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
requestSettingsSetAndForget(slave, CaptureRequest.CONTROL_CAPTURE_INTENT, null);
master.union(slave);
assertEquals(null, master.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
requestSettingsSetAndForget(slave, CaptureRequest.CONTROL_CAPTURE_INTENT,
CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE);
master.union(slave);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE,
master.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
slave.unset(CaptureRequest.CONTROL_CAPTURE_INTENT);
master.union(slave);
assertEquals((Object) CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE,
master.get(CaptureRequest.CONTROL_CAPTURE_INTENT));
| public void | requestSettingsSetNullValue()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
requestSettingsSetAndForget(setUp, CaptureRequest.SENSOR_TEST_PATTERN_DATA, new int[] {1});
requestSettingsSetAndForget(setUp, CaptureRequest.SENSOR_TEST_PATTERN_DATA, null);
requestSettingsSetAndForget(setUp, CaptureRequest.SENSOR_TEST_PATTERN_DATA,
new int[] {2, 2});
| public void | requestSettingsSetSelfArgToUnion()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertFalse(setUp.union(setUp));
assertEquals(0, setUp.getRevision());
| public void | requestSettingsSetStartsWithoutChanges()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertEquals(0, setUp.getRevision());
| public void | requestSettingsSetUnionChangesRecorded()
Camera2RequestSettingsSet[] sets = { new Camera2RequestSettingsSet(),
new Camera2RequestSettingsSet() };
sets[0].union(sets[1]);
assertEquals(1, sets[0].getRevision());
assertEquals(0, sets[1].getRevision());
| public void | requestSettingsSetUnionChangesReflected()
Camera2RequestSettingsSet[] sets = { new Camera2RequestSettingsSet(),
new Camera2RequestSettingsSet() };
sets[0].set(CaptureRequest.CONTROL_AE_LOCK, true);
sets[1].set(CaptureRequest.CONTROL_AWB_LOCK, true);
sets[0].union(sets[1]);
sets[1].set(CaptureRequest.CONTROL_AE_LOCK, false);
requestSettingsSetsCheckPairOfProperties(sets[0], sets[1],
CaptureRequest.CONTROL_AE_LOCK, CaptureRequest.CONTROL_AWB_LOCK,
true, true, false, true);
sets[0].union(sets[1]);
requestSettingsSetsCheckPairOfProperties(sets[0], sets[1],
CaptureRequest.CONTROL_AE_LOCK, CaptureRequest.CONTROL_AWB_LOCK,
false, true, false, true);
sets[1].set(CaptureRequest.CONTROL_AE_LOCK, false);
sets[1].set(CaptureRequest.CONTROL_AWB_LOCK, false);
sets[0].union(sets[1]);
requestSettingsSetsCheckPairOfProperties(sets[0], sets[1],
CaptureRequest.CONTROL_AE_LOCK, CaptureRequest.CONTROL_AWB_LOCK,
false, false, false, false);
| public void | requestSettingsSetUnsetAndContains()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
assertFalse(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, false);
assertTrue(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, null);
assertTrue(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.unset(CaptureRequest.CONTROL_AE_LOCK);
assertFalse(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, null);
assertTrue(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.set(CaptureRequest.CONTROL_AE_LOCK, false);
assertTrue(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
setUp.unset(CaptureRequest.CONTROL_AE_LOCK);
assertFalse(setUp.contains(CaptureRequest.CONTROL_AE_LOCK));
| public void | requestSettingsSetUnsetMakesChangesAndDetectsNoops()
Camera2RequestSettingsSet setUp = new Camera2RequestSettingsSet();
requestSettingsUnsetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, true);
requestSettingsUnsetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, true);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, true);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, false);
requestSettingsUnsetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, true);
requestSettingsUnsetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, false, true);
requestSettingsSetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, true, true);
requestSettingsUnsetAndAssertChanged(setUp, CaptureRequest.CONTROL_AE_LOCK, true);
| private void | requestSettingsSetsCheckPairOfProperties(Camera2RequestSettingsSet firstSet, Camera2RequestSettingsSet secondSet, android.hardware.camera2.CaptureRequest.Key firstKey, android.hardware.camera2.CaptureRequest.Key secondKey, T expectedFirstSetFirstValue, T expectedFirstSetSecondValue, T expectedSecondSetFirstValue, T expectedSecondSetSecondValue)
assertEquals(expectedFirstSetFirstValue, firstSet.get(firstKey));
assertEquals(expectedFirstSetSecondValue, firstSet.get(secondKey));
assertEquals(expectedSecondSetFirstValue, secondSet.get(firstKey));
assertEquals(expectedSecondSetSecondValue, secondSet.get(secondKey));
| private void | requestSettingsUnsetAndAssertChanged(Camera2RequestSettingsSet settings, android.hardware.camera2.CaptureRequest.Key key, boolean shouldHaveChanged)
long revision = settings.getRevision();
assertEquals(shouldHaveChanged, settings.unset(key));
assertEquals(shouldHaveChanged ? revision + 1 : revision, settings.getRevision());
|
|