From e3f5f579993845d1fce26c1449adff40262677e5 Mon Sep 17 00:00:00 2001 From: Ahmad Khalil Date: Mon, 24 Jul 2023 16:27:25 +0000 Subject: [PATCH] Fix flaky test case: com.android.server.vibrator.VibratorManagerServiceTest#vibrate_withIntensitySettings_appliesSettingsToScaleVibrations We're canceling all vibrations at the end of test, because there are cases where the vibrator clean-up step (TurnOffVibratorStep) is taking longer than the clean-up timeout in the teardown. Fix: 292208387 Test: atest VibratorManagerServiceTest Change-Id: Ic5f868ab6e99e6fc35d5232c7cb3234cd3271bd5 --- .../android/server/vibrator/VibratorManagerServiceTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java index c6cd07844ffea..4e3a893954a25 100644 --- a/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java +++ b/services/tests/vibrator/src/com/android/server/vibrator/VibratorManagerServiceTest.java @@ -509,7 +509,7 @@ public class VibratorManagerServiceTest { verify(listeners[0]).onVibrating(eq(true)); verify(listeners[1]).onVibrating(eq(true)); verify(listeners[2], never()).onVibrating(eq(true)); - cancelVibrate(service); + cancelVibrate(service); // Clean up long-ish effect. } @Test @@ -1333,6 +1333,8 @@ public class VibratorManagerServiceTest { // Alarm vibration will be scaled with SCALE_NONE. assertEquals(1f, ((PrimitiveSegment) fakeVibrator.getAllEffectSegments().get(2)).getScale(), 1e-5); + + cancelVibrate(service); // Clean up long-ish effect. } @Test @@ -1368,7 +1370,7 @@ public class VibratorManagerServiceTest { // Vibration is not stopped nearly after updating service. assertFalse(waitUntil(s -> !s.isVibrating(1), service, 50)); - cancelVibrate(service); + cancelVibrate(service); // Clean up long effect. } @Test