summaryrefslogtreecommitdiffstats
path: root/media/tests/MediaFrameworkTest
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2014-05-19 16:31:02 -0700
committerIgor Murashkin <iam@google.com>2014-05-23 11:55:29 -0700
commitd6d65154e55612b489aae95b60f3145f3b81f3b4 (patch)
treef3e9c677e29a524624271d3ce3bff9321533f6db /media/tests/MediaFrameworkTest
parenta06d76b139b85bd28e87c390d97d1ee165a1430b (diff)
downloadframeworks_base-d6d65154e55612b489aae95b60f3145f3b81f3b4.zip
frameworks_base-d6d65154e55612b489aae95b60f3145f3b81f3b4.tar.gz
frameworks_base-d6d65154e55612b489aae95b60f3145f3b81f3b4.tar.bz2
camera2: Refactor CameraMetadata.Key out into 3 key classes
Before: * CameraMetadata.Key<T> After: * CameraCharacteristics.Key<T> * CaptureResult.Key<T> * CaptureRequest.Key<T> CameraMetadata#get has been removed (each metadata subclass has its own #get now) due to java generic limitations (in particular a type bound <T1<T2> extends Key<T2>> is an illegal bound). CameraMetadataNative gets a new #dumpToLog function to dump the native metadata to logcat. Bug: 15091017 Change-Id: Ic56c54c0d184e209e20de374dc8a6d79527c209f
Diffstat (limited to 'media/tests/MediaFrameworkTest')
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java41
1 files changed, 37 insertions, 4 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java
index a77b647..a3caba2 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java
@@ -17,6 +17,7 @@
package com.android.mediaframeworktest.unit;
import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
import android.util.Range;
import android.util.Rational;
import android.util.SizeF;
@@ -26,6 +27,8 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraMetadata;
+import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.util.Size;
import android.hardware.camera2.impl.CameraMetadataNative;
@@ -46,6 +49,7 @@ import static com.android.mediaframeworktest.unit.ByteArrayHelpers.*;
import java.lang.reflect.Array;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.List;
/**
* <pre>
@@ -56,6 +60,10 @@ import java.nio.ByteOrder;
*/
public class CameraMetadataTest extends junit.framework.TestCase {
+ private static final boolean VERBOSE = false;
+ private static final String TAG = "CameraMetadataTest";
+
+
CameraMetadataNative mMetadata;
// Sections
@@ -940,7 +948,7 @@ public class CameraMetadataTest extends junit.framework.TestCase {
};
int availableFormatTag = CameraMetadataNative.getTag("android.scaler.availableFormats");
- Key<int[]> formatKey = CameraCharacteristics.SCALER_AVAILABLE_FORMATS;
+ Key<int[]> formatKey = CameraCharacteristics.SCALER_AVAILABLE_FORMATS.getNativeKey();
validateArrayMetadataReadWriteOverride(formatKey, availableFormats,
expectedIntValues, availableFormatTag);
@@ -1046,7 +1054,7 @@ public class CameraMetadataTest extends junit.framework.TestCase {
0x20, 320, 240, INPUT, // RAW16
};
Key<StreamConfiguration[]> configKey =
- CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS;
+ CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS.getNativeKey();
mMetadata.writeValues(configKey.getTag(),
toByteArray(rawAvailableStreamConfigs));
@@ -1074,7 +1082,7 @@ public class CameraMetadataTest extends junit.framework.TestCase {
0x21, 1920, 1080, 33333338 // BLOB
};
Key<StreamConfigurationDuration[]> durationKey =
- CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS;
+ CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS.getNativeKey();
mMetadata.writeValues(durationKey.getTag(),
toByteArray(rawAvailableMinDurations));
@@ -1100,7 +1108,7 @@ public class CameraMetadataTest extends junit.framework.TestCase {
0x21, 1920, 1080, 33333338 // BLOB
};
Key<StreamConfigurationDuration[]> stallDurationKey =
- CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS;
+ CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS.getNativeKey();
mMetadata.writeValues(stallDurationKey.getTag(),
toByteArray(rawAvailableStallDurations));
@@ -1158,6 +1166,31 @@ public class CameraMetadataTest extends junit.framework.TestCase {
}
}
+ @SmallTest
+ public void testCaptureResult() {
+ mMetadata.set(CaptureRequest.CONTROL_AE_MODE,
+ CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH);
+
+ if (VERBOSE) mMetadata.dumpToLog();
+
+ CaptureResult captureResult = new CaptureResult(mMetadata, /*sequenceId*/0);
+
+ List<CaptureResult.Key<?>> allKeys = captureResult.getKeys();
+ if (VERBOSE) Log.v(TAG, "testCaptureResult: key list size " + allKeys);
+ for (CaptureResult.Key<?> key : captureResult.getKeys()) {
+ if (VERBOSE) {
+ Log.v(TAG,
+ "testCaptureResult: key " + key + " value" + captureResult.get(key));
+ }
+ }
+
+ assertTrue(allKeys.size() >= 1); // FIXME: android.statistics.faces counts as a key
+ assertTrue(allKeys.contains(CaptureResult.CONTROL_AE_MODE));
+
+ assertEquals(CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH,
+ (int)captureResult.get(CaptureResult.CONTROL_AE_MODE));
+ }
+
private static void checkStreamConfigurationMapByFormatSize(StreamConfigurationMap configMap,
int format, int width, int height,
boolean output) {