diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp index 72ff9babed..46dde09dd4 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp @@ -109,6 +109,11 @@ class GraphicsCompositionTestBase : public ::testing::Test { 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> allocateBuffer(uint32_t usage) { const auto width = static_cast(getDisplayWidth()); const auto height = static_cast(getDisplayHeight()); @@ -222,7 +227,8 @@ class GraphicsCompositionTestBase : public ::testing::Test { 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 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadDisplay) { 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 @@ TEST_P(GraphicsCompositionTest, SetReadbackBuffer_BadParameter) { 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 @@ TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) { 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 @@ TEST_P(GraphicsTransformCompositionTest, FLIP_H) { 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"; diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index 2cae5a2c93..759bfecca3 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -71,6 +71,11 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam { 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, const std::vector& supportedContentTypes, ContentType contentType, const char* contentTypeStr) { @@ -81,7 +86,8 @@ class GraphicsComposerAidlTest : public ::testing::TestWithParam { if (!contentTypeSupport) { const auto& status = mComposerClient->setContentType(display, contentType); 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 " << std::to_string(display) << ", skipping test"; return; @@ -132,7 +138,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayCapabilities_BadDisplay) { const auto& [status, _] = mComposerClient->getDisplayCapabilities(getInvalidDisplayId()); 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) { @@ -153,13 +159,14 @@ TEST_P(GraphicsComposerAidlTest, CreateClientSingleton) { const auto& status = mComposerClient->createClient(); 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) { const auto& [status0, displayIdentification0] = 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"; return; } @@ -200,7 +207,8 @@ TEST_P(GraphicsComposerAidlTest, GetHdrCapabilities) { TEST_P(GraphicsComposerAidlTest, GetPerFrameMetadataKeys) { 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"; return; } @@ -211,7 +219,8 @@ TEST_P(GraphicsComposerAidlTest, GetPerFrameMetadataKeys) { TEST_P(GraphicsComposerAidlTest, GetReadbackBufferAttributes) { 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"; return; } @@ -254,7 +263,8 @@ TEST_P(GraphicsComposerAidlTest, GetRenderIntents_BadDisplay) { mComposerClient->getRenderIntents(getInvalidDisplayId(), mode); 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(-1)); 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) { @@ -278,7 +288,7 @@ TEST_P(GraphicsComposerAidlTest, GetColorMode_BadDisplay) { const auto& [status, _] = mComposerClient->getColorModes(getInvalidDisplayId()); 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) { @@ -294,7 +304,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode) { const auto modeStatus = mComposerClient->setColorMode(getPrimaryDisplayId(), mode, intent); EXPECT_TRUE(modeStatus.isOk() || - IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()) + (modeStatus.getExceptionCode() == EX_SERVICE_SPECIFIC && + IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError())) << "failed to set color mode"; } } @@ -302,7 +313,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode) { const auto modeStatus = mComposerClient->setColorMode(getPrimaryDisplayId(), ColorMode::NATIVE, RenderIntent::COLORIMETRIC); EXPECT_TRUE(modeStatus.isOk() || - IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError()) + (modeStatus.getExceptionCode() == EX_SERVICE_SPECIFIC && + IComposerClient::EX_UNSUPPORTED == modeStatus.getServiceSpecificError())) << "failed to set color mode"; } @@ -320,7 +332,8 @@ TEST_P(GraphicsComposerAidlTest, SetColorMode_BadDisplay) { mComposerClient->setColorMode(getInvalidDisplayId(), mode, intent); 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); 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, static_cast(-1)); 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) { @@ -344,7 +357,8 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSamplingAttributes) { const auto& [status, format] = 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"; return; } @@ -360,7 +374,8 @@ TEST_P(GraphicsComposerAidlTest, SetDisplayedContentSamplingEnabled) { FormatColorComponent enableAllComponents = FormatColorComponent::FORMAT_COMPONENT_0; auto status = mComposerClient->setDisplayedContentSamplingEnabled( 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"; return; } @@ -374,7 +389,8 @@ TEST_P(GraphicsComposerAidlTest, SetDisplayedContentSamplingEnabled) { TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) { const auto& [status, displayContentSamplingAttributes] = 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"; return; } @@ -383,7 +399,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSample) { int64_t constexpr kTimestamp = 0; const auto& [sampleStatus, displayContentSample] = mComposerClient->getDisplayedContentSample( getPrimaryDisplayId(), kMaxFrames, kTimestamp); - if (!sampleStatus.isOk() && + if (!sampleStatus.isOk() && sampleStatus.getExceptionCode() == EX_SERVICE_SPECIFIC && sampleStatus.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { SUCCEED() << "Device does not support optional extension. Test skipped"; return; @@ -405,7 +421,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayConnectionType) { const auto& [status, type] = mComposerClient->getDisplayConnectionType(getInvalidDisplayId()); 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) { const auto& [connectionTypeStatus, _] = @@ -440,8 +456,10 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayAttribute) { for (const auto& attribute : optionalAttributes) { const auto& [attribStatus, value] = mComposerClient->getDisplayAttribute( display.getDisplayId(), config, attribute); - EXPECT_TRUE(attribStatus.isOk() || IComposerClient::EX_UNSUPPORTED == - attribStatus.getServiceSpecificError()); + EXPECT_TRUE(attribStatus.isOk() || + (attribStatus.getExceptionCode() == EX_SERVICE_SPECIFIC && + IComposerClient::EX_UNSUPPORTED == + attribStatus.getServiceSpecificError())); } } } @@ -463,7 +481,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayVsyncPeriod_BadDisplay) { mComposerClient->getDisplayVsyncPeriod(getInvalidDisplayId()); 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) { @@ -476,7 +494,7 @@ TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadDisplay) { &invalidDisplay, /*config*/ 0, constraints); 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) { @@ -490,7 +508,7 @@ TEST_P(GraphicsComposerAidlTest, SetActiveConfigWithConstraints_BadConfig) { &display, kInvalidConfigId, constraints); 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); 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) { @@ -516,7 +534,7 @@ TEST_P(GraphicsComposerAidlTest, SetBootDisplayConfig_BadConfig) { mComposerClient->setBootDisplayConfig(display.getDisplayId(), kInvalidConfigId); 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()); 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) { @@ -559,7 +577,7 @@ TEST_P(GraphicsComposerAidlTest, GetPreferredBootDisplayConfig_BadDisplay) { const auto& [status, _] = mComposerClient->getPreferredBootDisplayConfig(getInvalidDisplayId()); 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) { @@ -585,26 +603,29 @@ TEST_P(GraphicsComposerAidlTest, BootDisplayConfig_Unsupported) { auto status = mComposerClient->setBootDisplayConfig(getPrimaryDisplayId(), config); 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; EXPECT_FALSE(status.isOk()); - EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, status.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE( + assertServiceSpecificError(status, IComposerClient::EX_UNSUPPORTED)); status = mComposerClient->clearBootDisplayConfig(getPrimaryDisplayId()); 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) { auto status = mComposerClient->setAutoLowLatencyMode(getInvalidDisplayId(), /*isEnabled*/ true); 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); 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) { @@ -621,11 +642,13 @@ TEST_P(GraphicsComposerAidlTest, SetAutoLowLatencyMode) { const auto& statusIsOn = mComposerClient->setAutoLowLatencyMode(display.getDisplayId(), /*isEnabled*/ true); 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(), /*isEnabled*/ false); 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 " << std::to_string(display.getDisplayId()) << ", skipping test"; return; @@ -640,7 +663,7 @@ TEST_P(GraphicsComposerAidlTest, GetSupportedContentTypes_BadDisplay) { const auto& [status, _] = mComposerClient->getSupportedContentTypes(getInvalidDisplayId()); 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) { @@ -671,7 +694,8 @@ TEST_P(GraphicsComposerAidlTest, SetContentType_BadDisplay) { const auto& status = mComposerClient->setContentType(getInvalidDisplayId(), type); 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()); 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) { @@ -735,7 +760,7 @@ TEST_P(GraphicsComposerAidlTest, CreateLayer_BadDisplay) { const auto& [status, _] = mComposerClient->createLayer(getInvalidDisplayId(), kBufferSlotCount); 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) { @@ -746,7 +771,8 @@ TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadDisplay) { const auto& destroyStatus = mComposerClient->destroyLayer(getInvalidDisplayId(), layer); 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()); } @@ -755,14 +781,14 @@ TEST_P(GraphicsComposerAidlTest, DestroyLayer_BadLayerError) { const auto& status = mComposerClient->destroyLayer(getPrimaryDisplayId(), /*layer*/ 1); 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) { const auto& [status, _] = mComposerClient->getActiveConfig(getInvalidDisplayId()); 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) { @@ -774,7 +800,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayConfig_BadDisplay) { const auto& [status, _] = mComposerClient->getDisplayConfigs(getInvalidDisplayId()); 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) { @@ -786,7 +812,7 @@ TEST_P(GraphicsComposerAidlTest, GetDisplayPhysicalOrientation_BadDisplay) { const auto& [status, _] = mComposerClient->getDisplayPhysicalOrientation(getInvalidDisplayId()); 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) { @@ -863,27 +889,28 @@ TEST_P(GraphicsComposerAidlTest, SetPowerModeUnsupported) { const auto& powerModeDozeStatus = mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE); EXPECT_FALSE(powerModeDozeStatus.isOk()); - EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, powerModeDozeStatus.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE( + assertServiceSpecificError(powerModeDozeStatus, IComposerClient::EX_UNSUPPORTED)); const auto& powerModeDozeSuspendStatus = mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND); EXPECT_FALSE(powerModeDozeSuspendStatus.isOk()); - EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, - powerModeDozeSuspendStatus.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeDozeSuspendStatus, + IComposerClient::EX_UNSUPPORTED)); } if (!isSuspendSupported) { const auto& powerModeSuspendStatus = mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::ON_SUSPEND); EXPECT_FALSE(powerModeSuspendStatus.isOk()); - EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, - powerModeSuspendStatus.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeSuspendStatus, + IComposerClient::EX_UNSUPPORTED)); const auto& powerModeDozeSuspendStatus = mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::DOZE_SUSPEND); EXPECT_FALSE(powerModeDozeSuspendStatus.isOk()); - EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, - powerModeDozeSuspendStatus.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError(powerModeDozeSuspendStatus, + IComposerClient::EX_UNSUPPORTED)); } } @@ -994,7 +1021,7 @@ TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadDisplay) { const auto& status = mComposerClient->setPowerMode(getInvalidDisplayId(), PowerMode::ON); 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) { @@ -1002,7 +1029,7 @@ TEST_P(GraphicsComposerAidlTest, SetPowerMode_BadParameter) { mComposerClient->setPowerMode(getPrimaryDisplayId(), static_cast(-1)); 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) { @@ -1023,7 +1050,7 @@ TEST_P(GraphicsComposerAidlTest, GetDataspaceSaturationMatrix_BadParameter) { mComposerClient->getDataspaceSaturationMatrix(common::Dataspace::UNKNOWN); 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. @@ -2003,8 +2030,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetActiveConfigWithConstraints_SeamlessN const auto& [status, _] = mComposerClient->setActiveConfigWithConstraints( &display, config2, constraints); EXPECT_FALSE(status.isOk()); - EXPECT_EQ(IComposerClient::EX_SEAMLESS_NOT_ALLOWED, - status.getServiceSpecificError()); + EXPECT_NO_FATAL_FAILURE(assertServiceSpecificError( + status, IComposerClient::EX_SEAMLESS_NOT_ALLOWED)); } }); } @@ -2029,7 +2056,8 @@ TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Unsupported) { const auto& status = mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ 0); 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 = mComposerClient->setIdleTimerEnabled(getPrimaryDisplayId(), /*timeout*/ -1); 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) {