Add GameManagerServiceTests.testGameModeMultipleUsers()
The new test testGameModeMultipleUsers() is being added to ensure the GameManagerService correctly handles multiple users. Bug: b/178111358 Test: atest GameManagerServiceTests Change-Id: I3d84336565a0fb2a4f0ca9ac9aff1d048f488539
This commit is contained in:
@@ -235,4 +235,37 @@ public class GameManagerServiceTests {
|
||||
assertEquals(GameManager.GAME_MODE_STANDARD,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test game modes are user-specific.
|
||||
*/
|
||||
@Test
|
||||
public void testGameModeMultipleUsers() {
|
||||
GameManagerService gameManagerService = new GameManagerService(mMockContext);
|
||||
gameManagerService.onUserStarting(USER_ID_1);
|
||||
gameManagerService.onUserStarting(USER_ID_2);
|
||||
|
||||
mockModifyGameModeGranted();
|
||||
|
||||
// Set User 1 to Standard
|
||||
gameManagerService.setGameMode(mPackageName, GameManager.GAME_MODE_STANDARD, USER_ID_1);
|
||||
assertEquals(GameManager.GAME_MODE_STANDARD,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_1));
|
||||
|
||||
// Set User 2 to Performance and verify User 1 is still Standard
|
||||
gameManagerService.setGameMode(mPackageName, GameManager.GAME_MODE_PERFORMANCE,
|
||||
USER_ID_2);
|
||||
assertEquals(GameManager.GAME_MODE_PERFORMANCE,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_2));
|
||||
assertEquals(GameManager.GAME_MODE_STANDARD,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_1));
|
||||
|
||||
// Set User 1 to Battery and verify User 2 is still Performance
|
||||
gameManagerService.setGameMode(mPackageName, GameManager.GAME_MODE_BATTERY,
|
||||
USER_ID_1);
|
||||
assertEquals(GameManager.GAME_MODE_BATTERY,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_1));
|
||||
assertEquals(GameManager.GAME_MODE_PERFORMANCE,
|
||||
gameManagerService.getGameMode(mPackageName, USER_ID_2));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user