diff options
author | Igor Murashkin <iam@google.com> | 2013-07-11 19:37:04 -0700 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2013-07-12 17:25:50 -0700 |
commit | b9dd637f830e6bd4f257ffb2c807c3ea27f8feee (patch) | |
tree | 52a62c46bcafaa230a44f90d173b6a06db9c9a84 /media/tests/MediaFrameworkTest/src | |
parent | b519cc52ecba8f44da31173c9fc90a7b66d52b79 (diff) | |
download | frameworks_base-b9dd637f830e6bd4f257ffb2c807c3ea27f8feee.zip frameworks_base-b9dd637f830e6bd4f257ffb2c807c3ea27f8feee.tar.gz frameworks_base-b9dd637f830e6bd4f257ffb2c807c3ea27f8feee.tar.bz2 |
camera2 api: Generate metadata keys and enums from XML
Change-Id: I9b04b5933c5922fc522e9216f4deebcd6fc24d78
Diffstat (limited to 'media/tests/MediaFrameworkTest/src')
-rw-r--r-- | media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java | 70 |
1 files changed, 70 insertions, 0 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 8a2d347..293d6f3 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java @@ -27,6 +27,7 @@ import static android.hardware.photography.CameraMetadata.*; import java.lang.reflect.Array; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.IntBuffer; import static org.junit.Assert.assertArrayEquals; @@ -436,4 +437,73 @@ public class CameraMetadataTest extends junit.framework.TestCase { }); } + + @SmallTest + public void testReadWriteEnumWithCustomValues() { + CameraMetadata.registerEnumValues(AeAntibandingMode.class, new int[] { + 0, + 10, + 20, + 30 + }); + + // byte (single) + checkKeyGetAndSet("android.control.aeAntibandingMode", AeAntibandingMode.class, + AeAntibandingMode.AUTO); + + // byte (n) + checkKeyGetAndSetArray("android.control.aeAvailableAntibandingModes", + AeAntibandingMode[].class, new AeAntibandingMode[] { + AeAntibandingMode.OFF, AeAntibandingMode._50HZ, AeAntibandingMode._60HZ, + AeAntibandingMode.AUTO + }); + + Key<AeAntibandingMode[]> aeAntibandingModeKey = + new Key<AeAntibandingMode[]>("android.control.aeAvailableAntibandingModes", + AeAntibandingMode[].class); + byte[] aeAntibandingModeValues = mMetadata.readValues(CameraMetadata + .getTag("android.control.aeAvailableAntibandingModes")); + byte[] expectedValues = new byte[] { 0, 10, 20, 30 }; + assertArrayEquals(expectedValues, aeAntibandingModeValues); + + + /** + * Stranger cases that don't use byte enums + */ + // int (n) + CameraMetadata.registerEnumValues(AvailableFormat.class, new int[] { + 0x20, + 0x32315659, + 0x11, + 0x22, + 0x23, + 0x21, + }); + + checkKeyGetAndSetArray("android.scaler.availableFormats", AvailableFormat[].class, + new AvailableFormat[] { + AvailableFormat.RAW_SENSOR, + AvailableFormat.YV12, + AvailableFormat.IMPLEMENTATION_DEFINED + }); + + Key<AeAntibandingMode> availableFormatsKey = + new Key<AeAntibandingMode>("android.scaler.availableFormats", + AeAntibandingMode.class); + byte[] availableFormatValues = mMetadata.readValues(CameraMetadata + .getTag(availableFormatsKey.getName())); + + int[] expectedIntValues = new int[] { + 0x20, + 0x32315659, + 0x22 + }; + + ByteBuffer bf = ByteBuffer.wrap(availableFormatValues).order(ByteOrder.nativeOrder()); + + assertEquals(expectedIntValues.length * 4, availableFormatValues.length); + for (int i = 0; i < expectedIntValues.length; ++i) { + assertEquals(expectedIntValues[i], bf.getInt()); + } + } } |