LocalDisplayAdapterTest - fixed issue with real DDC loading for fake display

Depending on device config file name it is possible that real DDC will be loaded and used in test for FakeDisplay. Introduced method to override/set DisplayDeviceConifg (loaded from mock resources) and used it in probelmatic tests
This fixed testDpiValues and testHdrSdrRatio_notifiesOnChange

Bug: b/284119555
Test: atest LocalDisplayAdapterTest on problematic devices
Change-Id: I67051b4c1a4662b216eb702d04a8a280ea200ec5
This commit is contained in:
Oleg Petsjonkin
2023-06-23 16:08:35 +00:00
committed by Oleg Petšjonkin
parent 54906d0618
commit dbfb7f88b6
2 changed files with 17 additions and 1 deletions

View File

@@ -496,7 +496,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
private void loadDisplayDeviceConfig() {
// Load display device config
final Context context = getOverlayContext();
mDisplayDeviceConfig = DisplayDeviceConfig.create(context, mPhysicalDisplayId,
mDisplayDeviceConfig = mInjector.createDisplayDeviceConfig(context, mPhysicalDisplayId,
mIsFirstDisplay);
// Load brightness HWC quirk
@@ -1336,6 +1336,11 @@ final class LocalDisplayAdapter extends DisplayAdapter {
public SurfaceControlProxy getSurfaceControlProxy() {
return new SurfaceControlProxy();
}
public DisplayDeviceConfig createDisplayDeviceConfig(Context context,
long physicalDisplayId, boolean isFirstDisplay) {
return DisplayDeviceConfig.create(context, physicalDisplayId, isFirstDisplay);
}
}
public interface DisplayEventListener {

View File

@@ -1257,6 +1257,17 @@ public class LocalDisplayAdapterTest {
public LocalDisplayAdapter.SurfaceControlProxy getSurfaceControlProxy() {
return mSurfaceControlProxy;
}
// Instead of using DisplayDeviceConfig.create(context, physicalDisplayId, isFirstDisplay)
// we should use DisplayDeviceConfig.create(context, isFirstDisplay) for the test to ensure
// that real device DisplayDeviceConfig is not loaded for FakeDisplay and we are getting
// consistent behaviour. Please also note that context passed to this method, is
// mMockContext and values will be loaded from mMockResources.
@Override
public DisplayDeviceConfig createDisplayDeviceConfig(Context context,
long physicalDisplayId, boolean isFirstDisplay) {
return DisplayDeviceConfig.create(context, isFirstDisplay);
}
}
private class TestListener implements DisplayAdapter.Listener {