From 67086319cee9049d7ecdc5f52963a55121397386 Mon Sep 17 00:00:00 2001 From: CeRRiLLo89 <56557070+CeRRiLLo89@users.noreply.github.com> Date: Mon, 3 Aug 2026 11:43:58 +0200 Subject: [PATCH] WmTests: fix natural rotation tests --- .../wm/DeviceStateAutoRotateSettingControllerTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/DeviceStateAutoRotateSettingControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/DeviceStateAutoRotateSettingControllerTests.java index 6840c05bf2577..129f514986847 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DeviceStateAutoRotateSettingControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DeviceStateAutoRotateSettingControllerTests.java @@ -476,11 +476,11 @@ public void requestAccelerometerRotationChange_withNaturalRotation_setUserRotati mTestLooper.dispatchAll(); mDeviceStateAutoRotateSettingController.requestAccelerometerRotationSettingChange( - false, getNaturalRotation, ""); + false, getNaturalRotation(), ""); mTestLooper.dispatchAll(); verify(mMockDisplayRotation).setUserRotationSetting( - eq(WindowManagerPolicy.USER_ROTATION_LOCKED), eq(getNaturalRotation), any()); + eq(WindowManagerPolicy.USER_ROTATION_LOCKED), eq(getNaturalRotation()), any()); } @Test @@ -576,6 +576,9 @@ public void foldableConfigFalse_locksRotation_usesNaturalRotation() { when(mMockResources.getBoolean( com.android.internal.R.bool.config_useCurrentRotationOnRotationLockChange)) .thenReturn(false); + // Ensure the current rotation is not eligible so the natural-rotation branch is tested. + Settings.System.putIntForUser(mMockResolver, + Settings.System.ACCELEROMETER_ROTATION_ANGLES, 0, UserHandle.USER_CURRENT); setDeviceState(FOLDED); setAccelerometerRotationSetting(ACCELEROMETER_ROTATION_ON); mAccelerometerRotationSettingObserver.getValue().onChange(false); @@ -586,7 +589,7 @@ public void foldableConfigFalse_locksRotation_usesNaturalRotation() { mTestLooper.dispatchAll(); verify(mMockDisplayRotation).setUserRotationSetting( - eq(WindowManagerPolicy.USER_ROTATION_LOCKED), eq(getNaturalRotation), any()); + eq(WindowManagerPolicy.USER_ROTATION_LOCKED), eq(getNaturalRotation()), any()); } private void setDeviceStateAutoRotateSetting(SparseIntArray deviceStateAutoRotateSetting) {