Merge "gralloc4-vts: correctly instantiate std::optional" into rvc-dev

This commit is contained in:
Marissa Ikonomidis
2020-02-26 18:05:06 +00:00
committed by Android (Google) Code Review

View File

@@ -278,6 +278,8 @@ class GraphicsMapperHidlTest
}
}
bool isEqual(float a, float b) { return abs(a - b) < 0.0001; }
std::unique_ptr<Gralloc> mGralloc;
IMapper::BufferDescriptorInfo mDummyDescriptorInfo{};
static const std::set<StandardMetadataType> sRequiredMetadataTypes;
@@ -1455,17 +1457,17 @@ TEST_P(GraphicsMapperHidlTest, SetSmpte2086) {
* red 0.680 0.320
* white (D65) 0.3127 0.3290
*/
std::optional<Smpte2086> smpte2086;
smpte2086->primaryRed.x = 0.680;
smpte2086->primaryRed.y = 0.320;
smpte2086->primaryGreen.x = 0.265;
smpte2086->primaryGreen.y = 0.690;
smpte2086->primaryBlue.x = 0.150;
smpte2086->primaryBlue.y = 0.060;
smpte2086->whitePoint.x = 0.3127;
smpte2086->whitePoint.y = 0.3290;
smpte2086->maxLuminance = 100.0;
smpte2086->minLuminance = 0.1;
Smpte2086 smpte2086;
smpte2086.primaryRed.x = 0.680;
smpte2086.primaryRed.y = 0.320;
smpte2086.primaryGreen.x = 0.265;
smpte2086.primaryGreen.y = 0.690;
smpte2086.primaryBlue.x = 0.150;
smpte2086.primaryBlue.y = 0.060;
smpte2086.whitePoint.x = 0.3127;
smpte2086.whitePoint.y = 0.3290;
smpte2086.maxLuminance = 100.0;
smpte2086.minLuminance = 0.1;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeSmpte2086(smpte2086, &vec));
@@ -1475,16 +1477,16 @@ TEST_P(GraphicsMapperHidlTest, SetSmpte2086) {
std::optional<Smpte2086> realSmpte2086;
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2086(vec, &realSmpte2086));
ASSERT_TRUE(realSmpte2086.has_value());
EXPECT_EQ(smpte2086->primaryRed.x, realSmpte2086->primaryRed.x);
EXPECT_EQ(smpte2086->primaryRed.y, realSmpte2086->primaryRed.y);
EXPECT_EQ(smpte2086->primaryGreen.x, realSmpte2086->primaryGreen.x);
EXPECT_EQ(smpte2086->primaryGreen.y, realSmpte2086->primaryGreen.y);
EXPECT_EQ(smpte2086->primaryBlue.x, realSmpte2086->primaryBlue.x);
EXPECT_EQ(smpte2086->primaryBlue.y, realSmpte2086->primaryBlue.y);
EXPECT_EQ(smpte2086->whitePoint.x, realSmpte2086->whitePoint.x);
EXPECT_EQ(smpte2086->whitePoint.y, realSmpte2086->whitePoint.y);
EXPECT_EQ(smpte2086->maxLuminance, realSmpte2086->maxLuminance);
EXPECT_EQ(smpte2086->minLuminance, realSmpte2086->minLuminance);
EXPECT_TRUE(isEqual(smpte2086.primaryRed.x, realSmpte2086->primaryRed.x));
EXPECT_TRUE(isEqual(smpte2086.primaryRed.y, realSmpte2086->primaryRed.y));
EXPECT_TRUE(isEqual(smpte2086.primaryGreen.x, realSmpte2086->primaryGreen.x));
EXPECT_TRUE(isEqual(smpte2086.primaryGreen.y, realSmpte2086->primaryGreen.y));
EXPECT_TRUE(isEqual(smpte2086.primaryBlue.x, realSmpte2086->primaryBlue.x));
EXPECT_TRUE(isEqual(smpte2086.primaryBlue.y, realSmpte2086->primaryBlue.y));
EXPECT_TRUE(isEqual(smpte2086.whitePoint.x, realSmpte2086->whitePoint.x));
EXPECT_TRUE(isEqual(smpte2086.whitePoint.y, realSmpte2086->whitePoint.y));
EXPECT_TRUE(isEqual(smpte2086.maxLuminance, realSmpte2086->maxLuminance));
EXPECT_TRUE(isEqual(smpte2086.minLuminance, realSmpte2086->minLuminance));
});
}
@@ -1492,9 +1494,9 @@ TEST_P(GraphicsMapperHidlTest, SetSmpte2086) {
* Test IMapper::set(Cta8613)
*/
TEST_P(GraphicsMapperHidlTest, SetCta861_3) {
std::optional<Cta861_3> cta861_3;
cta861_3->maxContentLightLevel = 78.0;
cta861_3->maxFrameAverageLightLevel = 62.0;
Cta861_3 cta861_3;
cta861_3.maxContentLightLevel = 78.0;
cta861_3.maxFrameAverageLightLevel = 62.0;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeCta861_3(cta861_3, &vec));
@@ -1504,9 +1506,10 @@ TEST_P(GraphicsMapperHidlTest, SetCta861_3) {
std::optional<Cta861_3> realCta861_3;
ASSERT_EQ(NO_ERROR, gralloc4::decodeCta861_3(vec, &realCta861_3));
ASSERT_TRUE(realCta861_3.has_value());
EXPECT_EQ(cta861_3->maxContentLightLevel, realCta861_3->maxContentLightLevel);
EXPECT_EQ(cta861_3->maxFrameAverageLightLevel,
realCta861_3->maxFrameAverageLightLevel);
EXPECT_TRUE(
isEqual(cta861_3.maxContentLightLevel, realCta861_3->maxContentLightLevel));
EXPECT_TRUE(isEqual(cta861_3.maxFrameAverageLightLevel,
realCta861_3->maxFrameAverageLightLevel));
});
}