Loading services/core/java/com/android/server/display/DisplayManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -2105,8 +2105,7 @@ public final class DisplayManagerService extends SystemService { } } // TODO (b/264979880) - Add unit test for HDR output control methods. private void setHdrConversionModeInternal(HdrConversionMode hdrConversionMode) { void setHdrConversionModeInternal(HdrConversionMode hdrConversionMode) { if (!mInjector.getHdrOutputConversionSupport()) { return; } Loading Loading @@ -2140,7 +2139,7 @@ public final class DisplayManagerService extends SystemService { } } private HdrConversionMode getHdrConversionModeSettingInternal() { HdrConversionMode getHdrConversionModeSettingInternal() { if (!mInjector.getHdrOutputConversionSupport()) { return HDR_CONVERSION_MODE_UNSUPPORTED; } Loading services/tests/servicestests/src/com/android/server/display/DisplayManagerServiceTest.java +42 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyLong; Loading Loading @@ -127,6 +128,10 @@ public class DisplayManagerServiceTest { private Context mContext; private int mHdrConversionMode; private int mPreferredHdrOutputType; private final DisplayManagerService.Injector mShortMockedInjector = new DisplayManagerService.Injector() { @Override Loading Loading @@ -176,6 +181,8 @@ public class DisplayManagerServiceTest { @Override int setHdrConversionMode(int conversionMode, int preferredHdrOutputType, int[] autoHdrTypes) { mHdrConversionMode = conversionMode; mPreferredHdrOutputType = preferredHdrOutputType; return Display.HdrCapabilities.HDR_TYPE_INVALID; } Loading @@ -185,7 +192,7 @@ public class DisplayManagerServiceTest { } boolean getHdrOutputConversionSupport() { return false; return true; } } Loading Loading @@ -1541,6 +1548,40 @@ public class DisplayManagerServiceTest { new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_SYSTEM)); } @Test public void testCreateHdrConversionMode_withInvalidArguments_throwsException() { assertThrows( "preferredHdrOutputType must not be set if the conversion mode is " + "HDR_CONVERSION_PASSTHROUGH", IllegalArgumentException.class, () -> new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION)); } @Test public void testSetHdrConversionModeInternal_withInvalidArguments_throwsException() { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); assertThrows("Expected DisplayManager to throw IllegalArgumentException when " + "preferredHdrOutputType is set and the conversion mode is " + "HDR_CONVERSION_SYSTEM", IllegalArgumentException.class, () -> displayManager.setHdrConversionModeInternal(new HdrConversionMode( HdrConversionMode.HDR_CONVERSION_SYSTEM, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION))); } @Test public void testSetAndGetHdrConversionModeInternal() { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); final HdrConversionMode mode = new HdrConversionMode( HdrConversionMode.HDR_CONVERSION_FORCE, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION); displayManager.setHdrConversionModeInternal(mode); assertEquals(mode, displayManager.getHdrConversionModeSettingInternal()); assertEquals(mode.getConversionMode(), mHdrConversionMode); assertEquals(mode.getPreferredHdrOutputType(), mPreferredHdrOutputType); } private void testDisplayInfoFrameRateOverrideModeCompat(boolean compatChangeEnabled) throws Exception { DisplayManagerService displayManager = Loading Loading
services/core/java/com/android/server/display/DisplayManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -2105,8 +2105,7 @@ public final class DisplayManagerService extends SystemService { } } // TODO (b/264979880) - Add unit test for HDR output control methods. private void setHdrConversionModeInternal(HdrConversionMode hdrConversionMode) { void setHdrConversionModeInternal(HdrConversionMode hdrConversionMode) { if (!mInjector.getHdrOutputConversionSupport()) { return; } Loading Loading @@ -2140,7 +2139,7 @@ public final class DisplayManagerService extends SystemService { } } private HdrConversionMode getHdrConversionModeSettingInternal() { HdrConversionMode getHdrConversionModeSettingInternal() { if (!mInjector.getHdrOutputConversionSupport()) { return HDR_CONVERSION_MODE_UNSUPPORTED; } Loading
services/tests/servicestests/src/com/android/server/display/DisplayManagerServiceTest.java +42 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyLong; Loading Loading @@ -127,6 +128,10 @@ public class DisplayManagerServiceTest { private Context mContext; private int mHdrConversionMode; private int mPreferredHdrOutputType; private final DisplayManagerService.Injector mShortMockedInjector = new DisplayManagerService.Injector() { @Override Loading Loading @@ -176,6 +181,8 @@ public class DisplayManagerServiceTest { @Override int setHdrConversionMode(int conversionMode, int preferredHdrOutputType, int[] autoHdrTypes) { mHdrConversionMode = conversionMode; mPreferredHdrOutputType = preferredHdrOutputType; return Display.HdrCapabilities.HDR_TYPE_INVALID; } Loading @@ -185,7 +192,7 @@ public class DisplayManagerServiceTest { } boolean getHdrOutputConversionSupport() { return false; return true; } } Loading Loading @@ -1541,6 +1548,40 @@ public class DisplayManagerServiceTest { new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_SYSTEM)); } @Test public void testCreateHdrConversionMode_withInvalidArguments_throwsException() { assertThrows( "preferredHdrOutputType must not be set if the conversion mode is " + "HDR_CONVERSION_PASSTHROUGH", IllegalArgumentException.class, () -> new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION)); } @Test public void testSetHdrConversionModeInternal_withInvalidArguments_throwsException() { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); assertThrows("Expected DisplayManager to throw IllegalArgumentException when " + "preferredHdrOutputType is set and the conversion mode is " + "HDR_CONVERSION_SYSTEM", IllegalArgumentException.class, () -> displayManager.setHdrConversionModeInternal(new HdrConversionMode( HdrConversionMode.HDR_CONVERSION_SYSTEM, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION))); } @Test public void testSetAndGetHdrConversionModeInternal() { DisplayManagerService displayManager = new DisplayManagerService(mContext, mBasicInjector); final HdrConversionMode mode = new HdrConversionMode( HdrConversionMode.HDR_CONVERSION_FORCE, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION); displayManager.setHdrConversionModeInternal(mode); assertEquals(mode, displayManager.getHdrConversionModeSettingInternal()); assertEquals(mode.getConversionMode(), mHdrConversionMode); assertEquals(mode.getPreferredHdrOutputType(), mPreferredHdrOutputType); } private void testDisplayInfoFrameRateOverrideModeCompat(boolean compatChangeEnabled) throws Exception { DisplayManagerService displayManager = Loading