From d2c468d40c5b908b15381fc3d438de0fc144378a Mon Sep 17 00:00:00 2001 From: Lais Andrade Date: Fri, 18 Feb 2022 14:23:38 +0000 Subject: Fix VibratorManagerService test handling scaling effects The service tests that do not validate the scaling of vibration effects should not be affected by the devide default settings or user values when asserting the expected effects are played. Fixing input device tests to not be affected by scaling on each device. Fix: 220240232 Test: VibratorManagerServiceTest Change-Id: Ic578d5051b1a93cb8b84a527c7240b59c727c270 --- .../src/com/android/server/vibrator/VibratorManagerServiceTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java index 52975ef8bfe1..ccdb1050d32c 100644 --- a/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/vibrator/VibratorManagerServiceTest.java @@ -765,6 +765,9 @@ public class VibratorManagerServiceTest { when(mIInputManagerMock.getVibratorIds(eq(1))).thenReturn(new int[]{1}); when(mIInputManagerMock.getInputDevice(eq(1))).thenReturn(createInputDeviceWithVibrator(1)); setUserSetting(Settings.System.VIBRATE_INPUT_DEVICES, 1); + // Mock alarm intensity equals to default value to avoid scaling in this test. + setUserSetting(Settings.System.ALARM_VIBRATION_INTENSITY, + mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_ALARM)); VibratorManagerService service = createSystemReadyService(); CombinedVibration effect = CombinedVibration.createParallel( @@ -804,6 +807,9 @@ public class VibratorManagerServiceTest { mockVibrators(1, 2); mVibratorProviders.get(1).setCapabilities(IVibrator.CAP_COMPOSE_EFFECTS); mVibratorProviders.get(2).setCapabilities(IVibrator.CAP_COMPOSE_EFFECTS); + // Mock alarm intensity equals to default value to avoid scaling in this test. + setUserSetting(Settings.System.ALARM_VIBRATION_INTENSITY, + mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_ALARM)); VibratorManagerService service = createSystemReadyService(); // The native callback will be dispatched manually in this test. mTestLooper.stopAutoDispatchAndIgnoreExceptions(); -- cgit v1.2.3-59-g8ed1b