Fix PowerKeyGestureTests#testPowerSinglePress

In ag/23249820, we moved the code to fetch power key behaviors from
PhoneWindowManager#init to PhoneWindowManager#updateSettings. Since the
PowerKeyGestureTests mocks out the updateSettings method, the key
behaviors were not being read properly.

This CL fixes the issue by explicitly setting the power button short
press behavior (which used to be implicitly assumed in the specific test
case).

Bug: 287561423
Test: atest com.android.server.policy.PowerKeyGestureTests#testPowerSinglePress
Change-Id: I446efafb5695d8fc76aa75d2338d8862e538cb01
This commit is contained in:
Yeabkal Wubshit
2023-06-16 23:25:40 -07:00
parent 44a9993e06
commit 5ea4cc204f

View File

@@ -21,6 +21,7 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP;
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT;
import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS;
import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_DREAM_OR_SLEEP;
import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_GO_TO_SLEEP;
import android.provider.Settings;
import android.view.Display;
@@ -39,6 +40,7 @@ public class PowerKeyGestureTests extends ShortcutKeyTestBase {
*/
@Test
public void testPowerSinglePress() {
mPhoneWindowManager.overrideShortPressOnPower(SHORT_PRESS_POWER_GO_TO_SLEEP);
sendKey(KEYCODE_POWER);
mPhoneWindowManager.assertPowerSleep();