Search in sources :

Example 56 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class RestrictedAppDetailsTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mRestrictedAppDetails = spy(new RestrictedAppDetails());
    mAppInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME).setUid(UID).build();
    mPreferenceManager = new PreferenceManager(mContext);
    doReturn(mPreferenceManager).when(mRestrictedAppDetails).getPreferenceManager();
    doReturn(mContext).when(mFragment).getContext();
    doReturn(mContext).when(mRestrictedAppDetails).getContext();
    mRestrictedAppDetails.mPackageManager = mPackageManager;
    mRestrictedAppDetails.mIconDrawableFactory = mIconDrawableFactory;
    mRestrictedAppDetails.mAppInfos = new ArrayList<>();
    mRestrictedAppDetails.mAppInfos.add(mAppInfo);
    mRestrictedAppDetails.mRestrictedAppListGroup = spy(new PreferenceCategory(mContext));
    mRestrictedAppDetails.mBatteryUtils = spy(new BatteryUtils(mContext));
    mRestrictedAppDetails.mBatteryDatabaseManager = mBatteryDatabaseManager;
    doReturn(mPreferenceManager).when(mRestrictedAppDetails.mRestrictedAppListGroup).getPreferenceManager();
    mCheckBoxPreference = new CheckBoxPreference(mContext);
    mCheckBoxPreference.setKey(mRestrictedAppDetails.getKeyFromAppInfo(mAppInfo));
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) CheckBoxPreference(androidx.preference.CheckBoxPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 57 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class HardwareInfoPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = new HardwareInfoPreferenceController(mContext, KEY);
    mPreference = new Preference(mContext);
    mPreference.setKey(KEY);
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = preferenceManager.createPreferenceScreen(mContext);
    mPreferenceScreen.addPreference(mPreference);
}
Also used : HardwareInfoPreferenceController(com.android.settings.deviceinfo.HardwareInfoPreferenceController) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 58 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class ControllerTaskTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
    mTestController = spy(new TestPreferenceController(mContext));
    mControllerTask = new ControllerTask(mTestController, mScreen, null, /* metricsFeature */
    METRICS_CATEGORY_UNKNOWN);
}
Also used : PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 59 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class AccountTypePreferenceLoaderTest method updatePreferenceIntents_shouldRunRecursively.

@Test
@Config(shadows = { ShadowAccountManager.class, ShadowContentResolver.class })
public void updatePreferenceIntents_shouldRunRecursively() {
    final PreferenceManager preferenceManager = mock(PreferenceManager.class);
    // Top level
    PreferenceGroup prefRoot = spy(new PreferenceScreen(mContext, null));
    when(prefRoot.getPreferenceManager()).thenReturn(preferenceManager);
    Preference pref1 = mock(Preference.class);
    PreferenceGroup prefGroup2 = spy(new PreferenceScreen(mContext, null));
    when(prefGroup2.getPreferenceManager()).thenReturn(preferenceManager);
    Preference pref3 = mock(Preference.class);
    PreferenceGroup prefGroup4 = spy(new PreferenceScreen(mContext, null));
    when(prefGroup4.getPreferenceManager()).thenReturn(preferenceManager);
    prefRoot.addPreference(pref1);
    prefRoot.addPreference(prefGroup2);
    prefRoot.addPreference(pref3);
    prefRoot.addPreference(prefGroup4);
    // 2nd level
    Preference pref21 = mock(Preference.class);
    Preference pref22 = mock(Preference.class);
    prefGroup2.addPreference(pref21);
    prefGroup2.addPreference(pref22);
    PreferenceGroup prefGroup41 = spy(new PreferenceScreen(mContext, null));
    when(prefGroup41.getPreferenceManager()).thenReturn(preferenceManager);
    Preference pref42 = mock(Preference.class);
    prefGroup4.addPreference(prefGroup41);
    prefGroup4.addPreference(pref42);
    // 3rd level
    Preference pref411 = mock(Preference.class);
    Preference pref412 = mock(Preference.class);
    prefGroup41.addPreference(pref411);
    prefGroup41.addPreference(pref412);
    final String acctType = "testType";
    mPrefLoader.updatePreferenceIntents(prefRoot, acctType, mAccount);
    verify(mPrefLoader).updatePreferenceIntents(prefGroup2, acctType, mAccount);
    verify(mPrefLoader).updatePreferenceIntents(prefGroup4, acctType, mAccount);
    verify(mPrefLoader).updatePreferenceIntents(prefGroup41, acctType, mAccount);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) PreferenceGroup(androidx.preference.PreferenceGroup) PreferenceManager(androidx.preference.PreferenceManager) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 60 with PreferenceManager

use of androidx.preference.PreferenceManager in project android_packages_apps_Settings by omnirom.

the class UsbDetailsFunctionsControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mLifecycle = new Lifecycle(() -> mLifecycle);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mActivity.getApplicationContext()).thenReturn(mContext);
    when(mFragment.getContext()).thenReturn(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
    when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
    mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment, mUsbBackend);
    mPreferenceCategory = new PreferenceCategory(mContext);
    mPreferenceCategory.setKey(mDetailsFunctionsController.getPreferenceKey());
    mScreen.addPreference(mPreferenceCategory);
    mDetailsFunctionsController.displayPreference(mScreen);
    mRadioButtonPreference = new RadioButtonPreference(mContext);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Before(org.junit.Before)

Aggregations

PreferenceManager (androidx.preference.PreferenceManager)87 Before (org.junit.Before)67 Preference (androidx.preference.Preference)23 PreferenceCategory (androidx.preference.PreferenceCategory)22 PreferenceScreen (androidx.preference.PreferenceScreen)19 Test (org.junit.Test)18 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)15 Context (android.content.Context)5 LifecycleRegistry (androidx.lifecycle.LifecycleRegistry)5 ArrayList (java.util.ArrayList)5 NotificationChannel (android.app.NotificationChannel)4 ShortcutInfo (android.content.pm.ShortcutInfo)4 View (android.view.View)4 NotificationChannelGroup (android.app.NotificationChannelGroup)3 ConversationChannel (android.app.people.ConversationChannel)3 PackageInfo (android.content.pm.PackageInfo)3 PersistableBundle (android.os.PersistableBundle)3 BluetoothManager (android.bluetooth.BluetoothManager)2 SoftApConfiguration (android.net.wifi.SoftApConfiguration)2 WifiManager (android.net.wifi.WifiManager)2