Correct FormatMetadataFactoryTest

Was assuming HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED was either YUV or JPEG.

BUG: b/32942342
TEST: unit tests pass
Change-Id: I3aaa6ee8040efa699c2856b687fc3b8a6d84b5cc
diff --git a/modules/camera/3_4/format_metadata_factory_test.cpp b/modules/camera/3_4/format_metadata_factory_test.cpp
index f033e37..a9603e8 100644
--- a/modules/camera/3_4/format_metadata_factory_test.cpp
+++ b/modules/camera/3_4/format_metadata_factory_test.cpp
@@ -62,6 +62,13 @@
                   {{{3, 6}}, {{11000000000, 21000000000}}},
                   {{{12, 24}}, {{10500000000, 19000000000}}}}}};
 
+  // Device must support IMPLEMENTATION_DEFINED (as well as JPEG & YUV).
+  // Just duplicate the values from another format.
+  uint32_t imp_defined_format = StreamFormat::HalToV4L2PixelFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
+  formats.insert(imp_defined_format);
+  sizes[imp_defined_format] = sizes[V4L2_PIX_FMT_YUV420];
+  durations[imp_defined_format] = durations[V4L2_PIX_FMT_YUV420];
+
   EXPECT_CALL(*mock_device_, GetFormats(_))
       .WillOnce(DoAll(SetArgPointee<0>(formats), Return(0)));
 
@@ -110,4 +117,40 @@
     }
   }
 }
+
+TEST_F(FormatMetadataFactoryTest, GetFormatMetadataMissingJpeg) {
+  uint32_t imp_defined_format = StreamFormat::HalToV4L2PixelFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
+  std::set<uint32_t> formats{V4L2_PIX_FMT_YUV420, imp_defined_format};
+  EXPECT_CALL(*mock_device_, GetFormats(_))
+      .WillOnce(DoAll(SetArgPointee<0>(formats), Return(0)));
+  PartialMetadataSet components;
+  ASSERT_EQ(AddFormatComponents(mock_device_,
+                                std::inserter(components, components.end())),
+            -ENODEV);
+
+}
+
+TEST_F(FormatMetadataFactoryTest, GetFormatMetadataMissingYuv) {
+  uint32_t imp_defined_format = StreamFormat::HalToV4L2PixelFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
+  std::set<uint32_t> formats{V4L2_PIX_FMT_JPEG, imp_defined_format};
+  EXPECT_CALL(*mock_device_, GetFormats(_))
+      .WillOnce(DoAll(SetArgPointee<0>(formats), Return(0)));
+  PartialMetadataSet components;
+  ASSERT_EQ(AddFormatComponents(mock_device_,
+                                std::inserter(components, components.end())),
+            -ENODEV);
+
+}
+
+TEST_F(FormatMetadataFactoryTest, GetFormatMetadataMissingImplementationDefined) {
+  std::set<uint32_t> formats{V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_YUV420};
+  EXPECT_CALL(*mock_device_, GetFormats(_))
+      .WillOnce(DoAll(SetArgPointee<0>(formats), Return(0)));
+  PartialMetadataSet components;
+  ASSERT_EQ(AddFormatComponents(mock_device_,
+                                std::inserter(components, components.end())),
+            -ENODEV);
+
+}
+
 }  // namespace v4l2_camera_hal