Camera: add missing FULL level expectation

Bug: 19969183
Change-Id: I1991d4bf79d2eef15cf4d5b3131e5de4815fcccf
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 ec7ecf8..dd1882e 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -19,12 +19,15 @@
 import static android.hardware.camera2.CameraCharacteristics.*;
 
 import android.graphics.ImageFormat;
+import android.graphics.Rect;
 import android.hardware.camera2.CameraCharacteristics;
 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.Size;
 
@@ -56,8 +59,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",
@@ -71,6 +80,13 @@
                         availableCaps.contains(
                                 REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING));
 
+                // 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);
@@ -80,6 +96,13 @@
                         mStaticInfo.isPerFrameControlSupported());
             }
 
+            // 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 7cf4089..f4859e5 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.
      *