SF: Fix unit tests re-registering a display
As written, these tests register a PhysicalDisplayId with a
RefreshRateSelector while setting up their TestableSchedulers, and then
later register the same PhysicalDisplayId with a different
RefreshRateSelector. While the tests pass as is, along with
Icdb80253436b4d0034fc20fcae8583efb7c30292, this causes the tests to
fail.
Update the failing tests to skip registering the PhysicalDisplayId
because it's already been registered and to use the same
RefreshRateSelector in the FakeDisplayDeviceInjector.
Bug: 241285191
Test: libsurfaceflinger_unittest
Change-Id: Ib147ce14995cc5544812aab2c788ad046124d292
diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index 17ef6ff..19a93e1 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -284,13 +284,16 @@
constexpr auto kDisplayConnectionType = ui::DisplayConnectionType::Internal;
constexpr bool kIsPrimary = true;
- test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, compositionDisplay,
- kDisplayConnectionType, HWC_DISPLAY, kIsPrimary)
- .setDisplaySurface(test->mDisplaySurface)
- .setNativeWindow(test->mNativeWindow)
- .setSecure(Derived::IS_SECURE)
- .setPowerMode(Derived::INIT_POWER_MODE)
- .inject();
+ test->mDisplay =
+ FakeDisplayDeviceInjector(test->mFlinger, compositionDisplay,
+ kDisplayConnectionType, HWC_DISPLAY, kIsPrimary)
+ .setDisplaySurface(test->mDisplaySurface)
+ .setNativeWindow(test->mNativeWindow)
+ .setSecure(Derived::IS_SECURE)
+ .setPowerMode(Derived::INIT_POWER_MODE)
+ .setRefreshRateSelector(test->mFlinger.scheduler()->refreshRateSelector())
+ .skipRegisterDisplay()
+ .inject();
Mock::VerifyAndClear(test->mNativeWindow.get());
constexpr bool kIsInternal = kDisplayConnectionType == ui::DisplayConnectionType::Internal;