Further refactoring on ActionDisabledByAdminDialog classes.

Bug: 184107103
Bug: 188836559

Test: m -j RunSettingsRoboTests ROBOTEST_FILTER=ActionDisabledByAdminDialogHelperTest
Test: atest ActionDisabledLearnMoreButtonLauncherImplTest
Test: adb shell am start -e android.app.extra.RESTRICTION no_install_unknown-sources -a android.settings.SHOW_ADMIN_SUPPORT_DETAILS
Test: manual verification with CtsVerifier

Change-Id: I3c4056d82834b5e2a4afbd958be7c9d0b9af543e
This commit is contained in:
Felipe Leme
2021-05-24 19:06:53 -07:00
parent 8e67634830
commit e89c2fd4b8
4 changed files with 126 additions and 151 deletions

View File

@@ -200,24 +200,21 @@ public class ActionDisabledByAdminDialogHelperTest {
@Test
public void testMaybeSetLearnMoreButton() {
final UserManager userManager = RuntimeEnvironment.application.getSystemService(
UserManager.class);
final ShadowUserManager userManagerShadow = Shadow.extract(userManager);
mHelper.prepareDialogBuilder(
/* restriction= */ null, ENFORCED_ADMIN);
UserManager userManager = RuntimeEnvironment.application
.getSystemService(UserManager.class);
ShadowUserManager userManagerShadow = Shadow.extract(userManager);
// Set up for shadow call.
userManagerShadow.getSameProfileGroupIds().put(USER_ID, 0);
// Test that the button is shown when user IDs are in the same profile group
AlertDialog.Builder builder = mock(AlertDialog.Builder.class);
mHelper.maybeSetLearnMoreButton(builder);
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
verify(builder).setNeutralButton(anyInt(), any());
// Test that the button is not shown when user IDs are not in the same profile group
userManagerShadow.getSameProfileGroupIds().clear();
builder = mock(AlertDialog.Builder.class);
mHelper.maybeSetLearnMoreButton(builder);
mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN);
verify(builder, never()).setNeutralButton(anyInt(), any());
}