Settings: don't try to allow NLSes with too-long component names am: f0367c98d0

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23712724

Change-Id: I51744909a3ef6fcb1406dcc24d857d9b9eb88057
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matías Hernández
2023-06-29 09:29:06 +00:00
committed by Automerger Merge Worker
4 changed files with 27 additions and 3 deletions

View File

@@ -77,6 +77,25 @@ public class ApprovalPreferenceControllerTest {
mController.setPkgInfo(mPkgInfo);
}
@Test
public void updateState_enabled() {
SwitchPreference pref = new SwitchPreference(mContext);
mController.updateState(pref);
assertThat(pref.isEnabled()).isTrue();
}
@Test
public void updateState_invalidCn_disabled() {
ComponentName longCn = new ComponentName("com.example.package",
com.google.common.base.Strings.repeat("Blah", 150));
mController.setCn(longCn);
SwitchPreference pref = new SwitchPreference(mContext);
mController.updateState(pref);
assertThat(pref.isEnabled()).isFalse();
}
@Test
public void updateState_checked() {
when(mNm.isNotificationListenerAccessGranted(mCn)).thenReturn(true);