Fix CommunalPreferenceControllerTest

Migrate test to robolectric, as this test doesn't require a device to
run. This also speeds up the test, and allows for use of roboelectric
shadows.

Fixes: 337417918
Test: atest CommunalPreferenceControllerTest
Flag: EXEMPT fix broken test
Change-Id: I32b2760c98bf527b33a8ccbe46314395a03da1e0
This commit is contained in:
Lucas Silva
2024-05-28 13:18:31 -04:00
parent 8f8bf944e6
commit 8b13cd4b6d
2 changed files with 27 additions and 34 deletions

View File

@@ -309,6 +309,11 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY);
}
@Implementation
protected UserHandle getMainUser() {
return UserHandle.of(PRIMARY_USER_ID);
}
protected boolean setUserEphemeral(@UserIdInt int userId, boolean enableEphemeral) {
UserInfo userInfo = mUserProfileInfos.stream()
.filter(user -> user.id == userId)