Check Exception Code for Service specific error
Before checking the service specific error
we need to check that getExceptionCode returns
EX_SERVICE_SPECIFIC error code. Added a method and
used that to do the two checks together for exceptionCode
and for the service specific error code, so that we don't
repeat two lines in all the tests that need them.
EXPECT_NO_FATAL_FAILURES print the correct line number of the test
or iteration of the test when used with helper functions, and
testing guidelines recommend it too here: go/gunitadvanced#propagating-fatal-failures
Test: atest VtsHalGraphicsComposer3_TargetTest
BUG: 205152739
Change-Id: I1d3c3aa9b34dcefb14be507ff61b73b6f08a5204
diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
index 72ff9ba..46dde09 100644
--- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
+++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
@@ -109,6 +109,11 @@
int32_t getDisplayHeight() const { return getPrimaryDisplay().getDisplayHeight(); }
+ void assertServiceSpecificError(const ScopedAStatus& status, int32_t serviceSpecificError) {
+ ASSERT_EQ(status.getExceptionCode(), EX_SERVICE_SPECIFIC);
+ ASSERT_EQ(status.getServiceSpecificError(), serviceSpecificError);
+ }
+
std::pair<bool, ::android::sp<::android::GraphicBuffer>> allocateBuffer(uint32_t usage) {
const auto width = static_cast<uint32_t>(getDisplayWidth());
const auto height = static_cast<uint32_t>(getDisplayHeight());
@@ -222,7 +227,8 @@
mDataspace = readBackBufferAttributes.dataspace;
return ReadbackHelper::readbackSupported(mPixelFormat, mDataspace);
}
- EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError());
+ EXPECT_NO_FATAL_FAILURE(
+ assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
return false;
}
@@ -458,7 +464,7 @@
mComposerClient->setReadbackBuffer(getInvalidDisplayId(), bufferHandle, fence);
EXPECT_FALSE(status.isOk());
- ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError());
+ EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
}
TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadParameter) {
@@ -475,7 +481,7 @@
mComposerClient->setReadbackBuffer(getPrimaryDisplayId(), &bufferHandle, releaseFence);
EXPECT_FALSE(status.isOk());
- ASSERT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError());
+ EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
}
TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) {
@@ -490,7 +496,7 @@
mComposerClient->getReadbackBufferFence(getPrimaryDisplayId());
EXPECT_FALSE(status.isOk());
- EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError());
+ EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
EXPECT_EQ(-1, releaseFence.get());
}
@@ -1300,7 +1306,7 @@
for (ColorMode mode : mTestColorModes) {
auto status = mComposerClient->setColorMode(getPrimaryDisplayId(), mode,
RenderIntent::COLORIMETRIC);
- if (!status.isOk() &&
+ if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
(status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED ||
status.getServiceSpecificError() == IComposerClient::EX_BAD_PARAMETER)) {
SUCCEED() << "ColorMode not supported, skip test";