Search in sources :

Example 41 with PreferenceManager

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

the class ControllerFutureTaskTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mTestController = new TestPreferenceController(mContext, KEY);
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    mScreen = preferenceManager.createPreferenceScreen(mContext);
}
Also used : PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 42 with PreferenceManager

use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 43 with PreferenceManager

use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 44 with PreferenceManager

use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ChooseAccountPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = spy(new ChooseAccountPreferenceController(mContext, "controller_key"));
    mActivity = Robolectric.setupActivity(FragmentActivity.class);
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 45 with PreferenceManager

use of androidx.preference.PreferenceManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsbDetailsHeaderControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    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);
    ShadowEntityHeaderController.setUseMock(mHeaderController);
    mDetailsHeaderController = new UsbDetailsHeaderController(mContext, mFragment, mUsbBackend);
    mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
    mPreference.setKey(mDetailsHeaderController.getPreferenceKey());
    mScreen.addPreference(mPreference);
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) 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