From f13fe0cceaa2227b069947a2049fd4bfb28c105c Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Thu, 15 Jul 2021 11:04:10 -0600 Subject: [PATCH] Fix failing GameManagerServiceTests The following tests are currently failing: - com.android.server.app.GameManagerServiceTests#testDeviceConfigInvalid - com.android.server.app.GameManagerServiceTests#testSetGameModePermissionDenied - This is actually flaky, rather than consistently failing. testDeviceConfigInvalid is failing because the current config string is actually valid. This test is fixed by updating the string to actually be invalid by making it empty. testSetGameModePermissionDenied is failing because the test package doesn't have any valid configs, so the call to getGameMode() returns GAME_MODE_UNSUPPORTED rather than GAME_MODE_STANDARD. This is fixed by calling mockDeviceConfigAll() at the start of the test. Test: GameManagerServiceTests#testDeviceConfigInvalid Test: GameManagerServiceTests#testSetGameModePermissionDenied Bug: b/193794028 Change-Id: I4d4581c37c31f6234b825f6b557b1e7dd4ce1c77 --- .../src/com/android/server/app/GameManagerServiceTests.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/tests/mockingservicestests/src/com/android/server/app/GameManagerServiceTests.java b/services/tests/mockingservicestests/src/com/android/server/app/GameManagerServiceTests.java index 4d86c8716bf1f..a6b6f9cbc0d96 100644 --- a/services/tests/mockingservicestests/src/com/android/server/app/GameManagerServiceTests.java +++ b/services/tests/mockingservicestests/src/com/android/server/app/GameManagerServiceTests.java @@ -200,7 +200,7 @@ public class GameManagerServiceTests { } private void mockDeviceConfigInvalid() { - String configString = "mode=2,downscaleFactor=0.55"; + String configString = ""; when(DeviceConfig.getProperty(anyString(), anyString())) .thenReturn(configString); } @@ -340,11 +340,12 @@ public class GameManagerServiceTests { */ @Test public void testSetGameModePermissionDenied() { + mockModifyGameModeGranted(); + mockDeviceConfigAll(); GameManagerService gameManagerService = new GameManagerService(mMockContext); gameManagerService.onUserStarting(USER_ID_1); // Update the game mode so we can read back something valid. - mockModifyGameModeGranted(); gameManagerService.setGameMode(mPackageName, GameManager.GAME_MODE_STANDARD, USER_ID_1); assertEquals(GameManager.GAME_MODE_STANDARD, gameManagerService.getGameMode(mPackageName, USER_ID_1));