use of com.android.internal.compat.OverrideAllowedState in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method setUp.
@Before
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, "", false);
mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, "", false);
mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false);
mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false);
mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false);
when(mPlatformCompat.listUIChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
when(mOverrideValidator.getOverrideAllowedState(anyLong(), anyString())).thenReturn(new OverrideAllowedState(ALLOWED, -1, -1));
mContext = spy(RuntimeEnvironment.application);
mPreferenceManager = new PreferenceManager(mContext);
mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
mApplicationInfo.packageName = APP_NAME;
mDashboard = spy(new PlatformCompatDashboard());
mDashboard.mSelectedApp = APP_NAME;
doReturn(mApplicationInfo).when(mDashboard).getApplicationInfo();
doReturn(mContext).when(mDashboard).getContext();
doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
doReturn(mPackageManager).when(mContext).getPackageManager();
}
use of com.android.internal.compat.OverrideAllowedState in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method createPreferenceForChange_cannotOverride_createDisabledEntry.
@Test
public void createPreferenceForChange_cannotOverride_createDisabledEntry() throws RemoteException {
CompatibilityChangeInfo enabledChange = mChanges[0];
CompatibilityChangeConfig config = new CompatibilityChangeConfig(new ChangeConfig(new HashSet<Long>(Arrays.asList(enabledChange.getId())), new HashSet<Long>()));
when(mOverrideValidator.getOverrideAllowedState(anyLong(), anyString())).thenReturn(new OverrideAllowedState(DISABLED_NOT_DEBUGGABLE, -1, -1));
Preference preference = mDashboard.createPreferenceForChange(mContext, enabledChange, config);
SwitchPreference switchPreference = (SwitchPreference) preference;
assertThat(preference.getSummary()).isEqualTo(mChanges[0].getName());
assertThat(preference instanceof SwitchPreference).isTrue();
assertThat(switchPreference.isChecked()).isTrue();
assertThat(switchPreference.isEnabled()).isFalse();
}
Aggregations