resolved conflicts for merge of 332674c2 to lmp-mr1-dev
Change-Id: Ide8ec418ee1e19141a35496af074a690ee2afcfc
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index a5ed0e1..014c752 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -19,13 +19,16 @@
import static android.hardware.camera2.CameraCharacteristics.*;
import android.graphics.ImageFormat;
+import android.graphics.Rect;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.CameraCharacteristics.Key;
import android.hardware.camera2.cts.helpers.StaticMetadata;
import android.hardware.camera2.cts.helpers.StaticMetadata.CheckLevel;
import android.hardware.camera2.cts.testcases.Camera2AndroidTestCase;
+import android.hardware.camera2.params.StreamConfigurationMap;
import android.util.Log;
import android.util.Pair;
import android.util.Size;
@@ -62,8 +65,14 @@
* Test the available capability for different hardware support level devices.
*/
public void testHwSupportedLevel() throws Exception {
+ Key<StreamConfigurationMap> key =
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
+ final float SIZE_ERROR_MARGIN = 0.03f;
for (String id : mCameraIds) {
initStaticMetadata(id);
+ StreamConfigurationMap configs = mStaticInfo.getValueFromKeyNonNull(key);
+ Rect activeRect = mStaticInfo.getActiveArraySizeChecked();
+ Size sensorSize = new Size(activeRect.width(), activeRect.height());
List<Integer> availableCaps = mStaticInfo.getAvailableCapabilitiesChecked();
mCollector.expectTrue("All device must contains BACKWARD_COMPATIBLE capability",
@@ -79,6 +88,13 @@
mCollector.expectTrue("Full device must contain BURST_CAPTURE capability",
availableCaps.contains(REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE));
+ // Max yuv resolution must be very close to sensor resolution
+ Size[] yuvSizes = configs.getOutputSizes(ImageFormat.YUV_420_888);
+ Size maxYuvSize = CameraTestUtils.getMaxSize(yuvSizes);
+ mCollector.expectSizesAreSimilar(
+ "Active array size and max YUV size should be similar",
+ sensorSize, maxYuvSize, SIZE_ERROR_MARGIN);
+
// Max resolution fps must be >= 20.
mCollector.expectTrue("Full device must support at least 20fps for max resolution",
getFpsForMaxSize(id) >= MIN_FPS_FOR_FULL_DEVICE);
@@ -94,6 +110,13 @@
availableCaps.contains(REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS));
}
+ // Max jpeg resolution must be very close to sensor resolution
+ Size[] jpegSizes = configs.getOutputSizes(ImageFormat.JPEG);
+ Size maxJpegSize = CameraTestUtils.getMaxSize(jpegSizes);
+ mCollector.expectSizesAreSimilar(
+ "Active array size and max JPEG size should be similar",
+ sensorSize, maxJpegSize, SIZE_ERROR_MARGIN);
+
// TODO: test all the keys mandatory for all capability devices.
}
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
index f0e7e57..0ee5ffc 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
@@ -520,6 +520,37 @@
}
/**
+ * Check that two sizes are similar enough by ensuring that their width and height
+ * are within {@code errorPercent} of each other.
+ *
+ * <p>Only the first error is collected, to avoid spamming several error messages when
+ * the rectangle is hugely dissimilar.</p>
+ *
+ * @param msg Message to be logged
+ * @param expected The reference 'expected' value to be used to check against
+ * @param actual The actual value that was received
+ * @param errorPercent Within how many percent the components should be
+ *
+ * @return {@code true} if all expects passed, {@code false} otherwise
+ */
+ public boolean expectSizesAreSimilar(String msg, Size expected, Size actual,
+ float errorPercent) {
+ String formattedMsg = String.format("%s: rects are not similar enough; expected (%s), " +
+ "actual (%s), error percent (%s), reason: ",
+ msg, expected, actual, errorPercent);
+
+ if (!expectSimilarValues(
+ formattedMsg, "too wide", "too narrow", actual.getWidth(), expected.getWidth(),
+ errorPercent)) return false;
+
+ if (!expectSimilarValues(
+ formattedMsg, "too tall", "too short", actual.getHeight(), expected.getHeight(),
+ errorPercent)) return false;
+
+ return true;
+ }
+
+ /**
* Check that the rectangle is centered within a certain tolerance of {@code errorPercent},
* with respect to the {@code bounds} bounding rectangle.
*