Merge "Check Exception Code for Service specific error" into tm-dev am: cb1fd25a53

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/17921233

Change-Id: I243a4df22209c1e1e0a3d893582527d307489b92
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ram Indani 2022-04-26 17:59:43 +00:00 committed by Automerger Merge Worker
commit be6e0a7899
2 changed files with 97 additions and 63 deletions

View file

@ -109,6 +109,11 @@ class GraphicsCompositionTestBase : public ::testing::Test {
int32_t getDisplayHeight() const { return getPrimaryDisplay().getDisplayHeight(); } 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) { std::pair<bool, ::android::sp<::android::GraphicBuffer>> allocateBuffer(uint32_t usage) {
const auto width = static_cast<uint32_t>(getDisplayWidth()); const auto width = static_cast<uint32_t>(getDisplayWidth());
const auto height = static_cast<uint32_t>(getDisplayHeight()); const auto height = static_cast<uint32_t>(getDisplayHeight());
@ -222,7 +227,8 @@ class GraphicsCompositionTestBase : public ::testing::Test {
mDataspace = readBackBufferAttributes.dataspace; mDataspace = readBackBufferAttributes.dataspace;
return ReadbackHelper::readbackSupported(mPixelFormat, mDataspace); return ReadbackHelper::readbackSupported(mPixelFormat, mDataspace);
} }
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
return false; return false;
} }
@ -458,7 +464,7 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadDisplay) {
mComposerClient->setReadbackBuffer(getInvalidDisplayId(), bufferHandle, fence); mComposerClient->setReadbackBuffer(getInvalidDisplayId(), bufferHandle, fence);
EXPECT_FALSE(status.isOk()); 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) { TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadParameter) {
@ -475,7 +481,7 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadParameter) {
mComposerClient->setReadbackBuffer(getPrimaryDisplayId(), &bufferHandle, releaseFence); mComposerClient->setReadbackBuffer(getPrimaryDisplayId(), &bufferHandle, releaseFence);
EXPECT_FALSE(status.isOk()); 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) { TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) {
@ -490,7 +496,7 @@ TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) {
mComposerClient->getReadbackBufferFence(getPrimaryDisplayId()); mComposerClient->getReadbackBufferFence(getPrimaryDisplayId());
EXPECT_FALSE(status.isOk()); 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()); EXPECT_EQ(-1, releaseFence.get());
} }
@ -1300,7 +1306,7 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
for (ColorMode mode : mTestColorModes) { for (ColorMode mode : mTestColorModes) {
auto status = mComposerClient->setColorMode(getPrimaryDisplayId(), mode, auto status = mComposerClient->setColorMode(getPrimaryDisplayId(), mode,
RenderIntent::COLORIMETRIC); RenderIntent::COLORIMETRIC);
if (!status.isOk() && if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
(status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED || (status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED ||
status.getServiceSpecificError() == IComposerClient::EX_BAD_PARAMETER)) { status.getServiceSpecificError() == IComposerClient::EX_BAD_PARAMETER)) {
SUCCEED() << "ColorMode not supported, skip test"; SUCCEED() << "ColorMode not supported, skip test";

View file

@ -71,6 +71,11 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam<std::string> {
mComposerClient.reset(); mComposerClient.reset();
} }
void assertServiceSpecificError(const ScopedAStatus& status, int32_t serviceSpecificError) {
ASSERT_EQ(status.getExceptionCode(), EX_SERVICE_SPECIFIC);
ASSERT_EQ(status.getServiceSpecificError(), serviceSpecificError);
}
void Test_setContentTypeForDisplay(int64_t display, void Test_setContentTypeForDisplay(int64_t display,
const std::vector<ContentType>& supportedContentTypes, const std::vector<ContentType>& supportedContentTypes,
ContentType contentType, const char* contentTypeStr) { ContentType contentType, const char* contentTypeStr) {
@ -81,7 +86,8 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam<std::string> {
if (!contentTypeSupport) { if (!contentTypeSupport) {
const auto& status = mComposerClient->setContentType(display, contentType); const auto& status = mComposerClient->setContentType(display, contentType);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
GTEST_SUCCEED() << contentTypeStr << " content type is not supported on display " GTEST_SUCCEED() << contentTypeStr << " content type is not supported on display "
<< std::to_string(display) << ", skipping test"; << std::to_string(display) << ", skipping test";
return; return;
@ -132,7 +138,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayCapabilities_BadDisplay) {
const auto& [status, _] = mComposerClient->getDisplayCapabilities(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getDisplayCapabilities(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayCapabilities) { TEST_P(GraphicsComposerAidlTest, GetDisplayCapabilities) {
@ -153,13 +159,14 @@ TEST_P(GraphicsComposerAidlTest, CreateClientSingleton) {
const auto& status = mComposerClient->createClient(); const auto& status = mComposerClient->createClient();
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_NO_RESOURCES, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_NO_RESOURCES));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayIdentificationData) { TEST_P(GraphicsComposerAidlTest, GetDisplayIdentificationData) {
const auto& [status0, displayIdentification0] = const auto& [status0, displayIdentification0] =
mComposerClient->getDisplayIdentificationData(getPrimaryDisplayId()); mComposerClient->getDisplayIdentificationData(getPrimaryDisplayId());
if (!status0.isOk() && status0.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status0.isOk() && status0.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status0.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
GTEST_SUCCEED() << "Display identification data not supported, skipping test"; GTEST_SUCCEED() << "Display identification data not supported, skipping test";
return; return;
} }
@ -200,7 +207,8 @@ TEST_P(GraphicsComposerAidlTest, GetHdrCapabilities) {
TEST_P(GraphicsComposerAidlTest, GetPerFrameMetadataKeys) { TEST_P(GraphicsComposerAidlTest, GetPerFrameMetadataKeys) {
const auto& [status, keys] = mComposerClient->getPerFrameMetadataKeys(getPrimaryDisplayId()); const auto& [status, keys] = mComposerClient->getPerFrameMetadataKeys(getPrimaryDisplayId());
if (!status.isOk() && status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
GTEST_SUCCEED() << "getPerFrameMetadataKeys is not supported"; GTEST_SUCCEED() << "getPerFrameMetadataKeys is not supported";
return; return;
} }
@ -211,7 +219,8 @@ TEST_P(GraphicsComposerAidlTest, GetPerFrameMetadataKeys) {
TEST_P(GraphicsComposerAidlTest, GetReadbackBufferAttributes) { TEST_P(GraphicsComposerAidlTest, GetReadbackBufferAttributes) {
const auto& [status, _] = mComposerClient->getReadbackBufferAttributes(getPrimaryDisplayId()); const auto& [status, _] = mComposerClient->getReadbackBufferAttributes(getPrimaryDisplayId());
if (!status.isOk() && status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
GTEST_SUCCEED() << "getReadbackBufferAttributes is not supported"; GTEST_SUCCEED() << "getReadbackBufferAttributes is not supported";
return; return;
} }
@ -254,7 +263,8 @@ TEST_P(GraphicsComposerAidlTest, GetRenderIntents_BadDisplay) {
mComposerClient->getRenderIntents(getInvalidDisplayId(), mode); mComposerClient->getRenderIntents(getInvalidDisplayId(), mode);
EXPECT_FALSE(intentStatus.isOk()); EXPECT_FALSE(intentStatus.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, intentStatus.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(intentStatus, IComposerClient::EX_BAD_DISPLAY));
} }
} }
@ -263,7 +273,7 @@ TEST_P(GraphicsComposerAidlTest, GetRenderIntents_BadParameter) {
mComposerClient->getRenderIntents(getPrimaryDisplayId(), static_cast<ColorMode>(-1)); mComposerClient->getRenderIntents(getPrimaryDisplayId(), static_cast<ColorMode>(-1));
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
} }
TEST_P(GraphicsComposerAidlTest, GetColorModes) { TEST_P(GraphicsComposerAidlTest, GetColorModes) {
@ -278,7 +288,7 @@ TEST_P(GraphicsComposerAidlTest, GetColorMode_BadDisplay) {
const auto& [status, _] = mComposerClient->getColorModes(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getColorModes(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetColorMode) { TEST_P(GraphicsComposerAidlTest, SetColorMode) {
@ -294,7 +304,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode) {
const auto modeStatus = const auto modeStatus =
mComposerClient->setColorMode(getPrimaryDisplayId(), mode, intent); mComposerClient->setColorMode(getPrimaryDisplayId(), mode, intent);
EXPECT_TRUE(modeStatus.isOk() || EXPECT_TRUE(modeStatus.isOk() ||
IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()) (modeStatus.getExceptionCode() == EX_SERVICE_SPECIFIC &&
IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()))
<< "failed to set color mode"; << "failed to set color mode";
} }
} }
@ -302,7 +313,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode) {
const auto modeStatus = mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE, const auto modeStatus = mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE,
RenderIntent::COLORIMETRIC); RenderIntent::COLORIMETRIC);
EXPECT_TRUE(modeStatus.isOk() || EXPECT_TRUE(modeStatus.isOk() ||
IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()) (modeStatus.getExceptionCode() == EX_SERVICE_SPECIFIC &&
IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()))
<< "failed to set color mode"; << "failed to set color mode";
} }
@ -320,7 +332,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode_BadDisplay) {
mComposerClient->setColorMode(getInvalidDisplayId(), mode, intent); mComposerClient->setColorMode(getInvalidDisplayId(), mode, intent);
EXPECT_FALSE(modeStatus.isOk()); EXPECT_FALSE(modeStatus.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, modeStatus.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(modeStatus, IComposerClient::EX_BAD_DISPLAY));
} }
} }
} }
@ -330,13 +343,13 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode_BadParameter) {
RenderIntent::COLORIMETRIC); RenderIntent::COLORIMETRIC);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
status = mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE, status = mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE,
static_cast<RenderIntent>(-1)); static_cast<RenderIntent>(-1));
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSamplingAttributes) { TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSamplingAttributes) {
@ -344,7 +357,8 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSamplingAttributes) {
const auto& [status, format] = const auto& [status, format] =
mComposerClient->getDisplayedContentSamplingAttributes(getPrimaryDisplayId()); mComposerClient->getDisplayedContentSamplingAttributes(getPrimaryDisplayId());
if (!status.isOk() && status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
SUCCEED() << "Device does not support optional extension. Test skipped"; SUCCEED() << "Device does not support optional extension. Test skipped";
return; return;
} }
@ -360,7 +374,8 @@ TEST_P(GraphicsComposerAidlTest, SetDisplayedContentSamplingEnabled) {
FormatColorComponent enableAllComponents = FormatColorComponent::FORMAT_COMPONENT_0; FormatColorComponent enableAllComponents = FormatColorComponent::FORMAT_COMPONENT_0;
auto status = mComposerClient->setDisplayedContentSamplingEnabled( auto status = mComposerClient->setDisplayedContentSamplingEnabled(
getPrimaryDisplayId(), /*isEnabled*/ true, enableAllComponents, kMaxFrames); getPrimaryDisplayId(), /*isEnabled*/ true, enableAllComponents, kMaxFrames);
if (!status.isOk() && status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
SUCCEED() << "Device does not support optional extension. Test skipped"; SUCCEED() << "Device does not support optional extension. Test skipped";
return; return;
} }
@ -374,7 +389,8 @@ TEST_P(GraphicsComposerAidlTest, SetDisplayedContentSamplingEnabled) {
TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) { TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) {
const auto& [status, displayContentSamplingAttributes] = const auto& [status, displayContentSamplingAttributes] =
mComposerClient->getDisplayedContentSamplingAttributes(getPrimaryDisplayId()); mComposerClient->getDisplayedContentSamplingAttributes(getPrimaryDisplayId());
if (!status.isOk() && status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
SUCCEED() << "Sampling attributes aren't supported on this device, test skipped"; SUCCEED() << "Sampling attributes aren't supported on this device, test skipped";
return; return;
} }
@ -383,7 +399,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) {
int64_t constexpr kTimestamp = 0; int64_t constexpr kTimestamp = 0;
const auto& [sampleStatus, displayContentSample] = mComposerClient->getDisplayedContentSample( const auto& [sampleStatus, displayContentSample] = mComposerClient->getDisplayedContentSample(
getPrimaryDisplayId(), kMaxFrames, kTimestamp); getPrimaryDisplayId(), kMaxFrames, kTimestamp);
if (!sampleStatus.isOk() && if (!sampleStatus.isOk() && sampleStatus.getExceptionCode() == EX_SERVICE_SPECIFIC &&
sampleStatus.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { sampleStatus.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
SUCCEED() << "Device does not support optional extension. Test skipped"; SUCCEED() << "Device does not support optional extension. Test skipped";
return; return;
@ -405,7 +421,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayConnectionType) {
const auto& [status, type] = mComposerClient->getDisplayConnectionType(getInvalidDisplayId()); const auto& [status, type] = mComposerClient->getDisplayConnectionType(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
for (const auto& display : mDisplays) { for (const auto& display : mDisplays) {
const auto& [connectionTypeStatus, _] = const auto& [connectionTypeStatus, _] =
@ -440,8 +456,10 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayAttribute) {
for (const auto& attribute : optionalAttributes) { for (const auto& attribute : optionalAttributes) {
const auto& [attribStatus, value] = mComposerClient->getDisplayAttribute( const auto& [attribStatus, value] = mComposerClient->getDisplayAttribute(
display.getDisplayId(), config, attribute); display.getDisplayId(), config, attribute);
EXPECT_TRUE(attribStatus.isOk() || IComposerClient::EX_UNSUPPORTED == EXPECT_TRUE(attribStatus.isOk() ||
attribStatus.getServiceSpecificError()); (attribStatus.getExceptionCode() == EX_SERVICE_SPECIFIC &&
IComposerClient::EX_UNSUPPORTED ==
attribStatus.getServiceSpecificError()));
} }
} }
} }
@ -463,7 +481,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayVsyncPeriod_BadDisplay) {
mComposerClient->getDisplayVsyncPeriod(getInvalidDisplayId()); mComposerClient->getDisplayVsyncPeriod(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadDisplay) { TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadDisplay) {
@ -476,7 +494,7 @@ TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadDisplay) {
&invalidDisplay, /*config*/ 0, constraints); &invalidDisplay, /*config*/ 0, constraints);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadConfig) { TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadConfig) {
@ -490,7 +508,7 @@ TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadConfig) {
&display, kInvalidConfigId, constraints); &display, kInvalidConfigId, constraints);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_CONFIG, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_CONFIG));
} }
} }
@ -502,7 +520,7 @@ TEST_P(GraphicsComposerAidlTest, SetBootDisplayConfig_BadDisplay) {
const auto& status = mComposerClient->setBootDisplayConfig(getInvalidDisplayId(), /*config*/ 0); const auto& status = mComposerClient->setBootDisplayConfig(getInvalidDisplayId(), /*config*/ 0);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetBootDisplayConfig_BadConfig) { TEST_P(GraphicsComposerAidlTest, SetBootDisplayConfig_BadConfig) {
@ -516,7 +534,7 @@ TEST_P(GraphicsComposerAidlTest, SetBootDisplayConfig_BadConfig) {
mComposerClient->setBootDisplayConfig(display.getDisplayId(), kInvalidConfigId); mComposerClient->setBootDisplayConfig(display.getDisplayId(), kInvalidConfigId);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_CONFIG, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_CONFIG));
} }
} }
@ -540,7 +558,7 @@ TEST_P(GraphicsComposerAidlTest, ClearBootDisplayConfig_BadDisplay) {
const auto& status = mComposerClient->clearBootDisplayConfig(getInvalidDisplayId()); const auto& status = mComposerClient->clearBootDisplayConfig(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, ClearBootDisplayConfig) { TEST_P(GraphicsComposerAidlTest, ClearBootDisplayConfig) {
@ -559,7 +577,7 @@ TEST_P(GraphicsComposerAidlTest, GetPreferredBootDisplayConfig_BadDisplay) {
const auto& [status, _] = mComposerClient->getPreferredBootDisplayConfig(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getPreferredBootDisplayConfig(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetPreferredBootDisplayConfig) { TEST_P(GraphicsComposerAidlTest, GetPreferredBootDisplayConfig) {
@ -585,26 +603,29 @@ TEST_P(GraphicsComposerAidlTest, BootDisplayConfig_Unsupported) {
auto status = mComposerClient->setBootDisplayConfig(getPrimaryDisplayId(), config); auto status = mComposerClient->setBootDisplayConfig(getPrimaryDisplayId(), config);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
status = mComposerClient->getPreferredBootDisplayConfig(getPrimaryDisplayId()).first; status = mComposerClient->getPreferredBootDisplayConfig(getPrimaryDisplayId()).first;
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
status = mComposerClient->clearBootDisplayConfig(getPrimaryDisplayId()); status = mComposerClient->clearBootDisplayConfig(getPrimaryDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
} }
} }
TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode_BadDisplay) { TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode_BadDisplay) {
auto status = mComposerClient->setAutoLowLatencyMode(getInvalidDisplayId(), /*isEnabled*/ true); auto status = mComposerClient->setAutoLowLatencyMode(getInvalidDisplayId(), /*isEnabled*/ true);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
status = mComposerClient->setAutoLowLatencyMode(getInvalidDisplayId(), /*isEnabled*/ false); status = mComposerClient->setAutoLowLatencyMode(getInvalidDisplayId(), /*isEnabled*/ false);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode) { TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode) {
@ -621,11 +642,13 @@ TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode) {
const auto& statusIsOn = mComposerClient->setAutoLowLatencyMode(display.getDisplayId(), const auto& statusIsOn = mComposerClient->setAutoLowLatencyMode(display.getDisplayId(),
/*isEnabled*/ true); /*isEnabled*/ true);
EXPECT_FALSE(statusIsOn.isOk()); EXPECT_FALSE(statusIsOn.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, statusIsOn.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(statusIsOn, IComposerClient::EX_UNSUPPORTED));
const auto& statusIsOff = mComposerClient->setAutoLowLatencyMode(display.getDisplayId(), const auto& statusIsOff = mComposerClient->setAutoLowLatencyMode(display.getDisplayId(),
/*isEnabled*/ false); /*isEnabled*/ false);
EXPECT_FALSE(statusIsOff.isOk()); EXPECT_FALSE(statusIsOff.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, statusIsOff.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(statusIsOff, IComposerClient::EX_UNSUPPORTED));
GTEST_SUCCEED() << "Auto Low Latency Mode is not supported on display " GTEST_SUCCEED() << "Auto Low Latency Mode is not supported on display "
<< std::to_string(display.getDisplayId()) << ", skipping test"; << std::to_string(display.getDisplayId()) << ", skipping test";
return; return;
@ -640,7 +663,7 @@ TEST_P(GraphicsComposerAidlTest, GetSupportedContentTypes_BadDisplay) {
const auto& [status, _] = mComposerClient->getSupportedContentTypes(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getSupportedContentTypes(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetSupportedContentTypes) { TEST_P(GraphicsComposerAidlTest, GetSupportedContentTypes) {
@ -671,7 +694,8 @@ TEST_P(GraphicsComposerAidlTest, SetContentType_BadDisplay) {
const auto& status = mComposerClient->setContentType(getInvalidDisplayId(), type); const auto& status = mComposerClient->setContentType(getInvalidDisplayId(), type);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
} }
@ -720,7 +744,8 @@ TEST_P(GraphicsComposerAidlTest, DestroyVirtualDisplay_BadDisplay) {
const auto& destroyStatus = mComposerClient->destroyVirtualDisplay(getInvalidDisplayId()); const auto& destroyStatus = mComposerClient->destroyVirtualDisplay(getInvalidDisplayId());
EXPECT_FALSE(destroyStatus.isOk()); EXPECT_FALSE(destroyStatus.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, destroyStatus.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(destroyStatus, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, CreateLayer) { TEST_P(GraphicsComposerAidlTest, CreateLayer) {
@ -735,7 +760,7 @@ TEST_P(GraphicsComposerAidlTest, CreateLayer_BadDisplay) {
const auto& [status, _] = mComposerClient->createLayer(getInvalidDisplayId(), kBufferSlotCount); const auto& [status, _] = mComposerClient->createLayer(getInvalidDisplayId(), kBufferSlotCount);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadDisplay) { TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadDisplay) {
@ -746,7 +771,8 @@ TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadDisplay) {
const auto& destroyStatus = mComposerClient->destroyLayer(getInvalidDisplayId(), layer); const auto& destroyStatus = mComposerClient->destroyLayer(getInvalidDisplayId(), layer);
EXPECT_FALSE(destroyStatus.isOk()); EXPECT_FALSE(destroyStatus.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, destroyStatus.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(destroyStatus, IComposerClient::EX_BAD_DISPLAY));
ASSERT_TRUE(mComposerClient->destroyLayer(getPrimaryDisplayId(), layer).isOk()); ASSERT_TRUE(mComposerClient->destroyLayer(getPrimaryDisplayId(), layer).isOk());
} }
@ -755,14 +781,14 @@ TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadLayerError) {
const auto& status = mComposerClient->destroyLayer(getPrimaryDisplayId(), /*layer*/ 1); const auto& status = mComposerClient->destroyLayer(getPrimaryDisplayId(), /*layer*/ 1);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_LAYER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_LAYER));
} }
TEST_P(GraphicsComposerAidlTest, GetActiveConfig_BadDisplay) { TEST_P(GraphicsComposerAidlTest, GetActiveConfig_BadDisplay) {
const auto& [status, _] = mComposerClient->getActiveConfig(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getActiveConfig(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayConfig) { TEST_P(GraphicsComposerAidlTest, GetDisplayConfig) {
@ -774,7 +800,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayConfig_BadDisplay) {
const auto& [status, _] = mComposerClient->getDisplayConfigs(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getDisplayConfigs(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayName) { TEST_P(GraphicsComposerAidlTest, GetDisplayName) {
@ -786,7 +812,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientation_BadDisplay) {
const auto& [status, _] = mComposerClient->getDisplayPhysicalOrientation(getInvalidDisplayId()); const auto& [status, _] = mComposerClient->getDisplayPhysicalOrientation(getInvalidDisplayId());
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientation) { TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientation) {
@ -863,27 +889,28 @@ TEST_P(GraphicsComposerAidlTest, SetPowerModeUnsupported) {
const auto& powerModeDozeStatus = const auto& powerModeDozeStatus =
mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE); mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE);
EXPECT_FALSE(powerModeDozeStatus.isOk()); EXPECT_FALSE(powerModeDozeStatus.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, powerModeDozeStatus.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(powerModeDozeStatus, IComposerClient::EX_UNSUPPORTED));
const auto& powerModeDozeSuspendStatus = const auto& powerModeDozeSuspendStatus =
mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND); mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND);
EXPECT_FALSE(powerModeDozeSuspendStatus.isOk()); EXPECT_FALSE(powerModeDozeSuspendStatus.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeDozeSuspendStatus,
powerModeDozeSuspendStatus.getServiceSpecificError()); IComposerClient::EX_UNSUPPORTED));
} }
if (!isSuspendSupported) { if (!isSuspendSupported) {
const auto& powerModeSuspendStatus = const auto& powerModeSuspendStatus =
mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::ON_SUSPEND); mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::ON_SUSPEND);
EXPECT_FALSE(powerModeSuspendStatus.isOk()); EXPECT_FALSE(powerModeSuspendStatus.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeSuspendStatus,
powerModeSuspendStatus.getServiceSpecificError()); IComposerClient::EX_UNSUPPORTED));
const auto& powerModeDozeSuspendStatus = const auto& powerModeDozeSuspendStatus =
mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND); mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND);
EXPECT_FALSE(powerModeDozeSuspendStatus.isOk()); EXPECT_FALSE(powerModeDozeSuspendStatus.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeDozeSuspendStatus,
powerModeDozeSuspendStatus.getServiceSpecificError()); IComposerClient::EX_UNSUPPORTED));
} }
} }
@ -994,7 +1021,7 @@ TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadDisplay) {
const auto& status = mComposerClient->setPowerMode(getInvalidDisplayId(), PowerMode::ON); const auto& status = mComposerClient->setPowerMode(getInvalidDisplayId(), PowerMode::ON);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_DISPLAY));
} }
TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadParameter) { TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadParameter) {
@ -1002,7 +1029,7 @@ TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadParameter) {
mComposerClient->setPowerMode(getPrimaryDisplayId(), static_cast<PowerMode>(-1)); mComposerClient->setPowerMode(getPrimaryDisplayId(), static_cast<PowerMode>(-1));
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
ASSERT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
} }
TEST_P(GraphicsComposerAidlTest, GetDataspaceSaturationMatrix) { TEST_P(GraphicsComposerAidlTest, GetDataspaceSaturationMatrix) {
@ -1023,7 +1050,7 @@ TEST_P(GraphicsComposerAidlTest, GetDataspaceSaturationMatrix_BadParameter) {
mComposerClient->getDataspaceSaturationMatrix(common::Dataspace::UNKNOWN); mComposerClient->getDataspaceSaturationMatrix(common::Dataspace::UNKNOWN);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
} }
// Tests for Command. // Tests for Command.
@ -2003,8 +2030,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetActiveConfigWithConstraints_SeamlessN
const auto& [status, _] = mComposerClient->setActiveConfigWithConstraints( const auto& [status, _] = mComposerClient->setActiveConfigWithConstraints(
&display, config2, constraints); &display, config2, constraints);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_SEAMLESS_NOT_ALLOWED, EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(
status.getServiceSpecificError()); status, IComposerClient::EX_SEAMLESS_NOT_ALLOWED));
} }
}); });
} }
@ -2029,7 +2056,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Unsupported) {
const auto& status = const auto& status =
mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ 0); mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ 0);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(
assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED));
} }
} }
@ -2044,7 +2072,7 @@ TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_BadParameter) {
const auto& status = const auto& status =
mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ -1); mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ -1);
EXPECT_FALSE(status.isOk()); EXPECT_FALSE(status.isOk());
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, status.getServiceSpecificError()); EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(status, IComposerClient::EX_BAD_PARAMETER));
} }
TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Disable) { TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Disable) {