Search in sources :

Example 46 with PreferenceManager

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

the class TrustAgentsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mPackageManager = (ShadowApplicationPackageManager) Shadows.shadowOf(mContext.getPackageManager());
    mController = new TrustAgentsPreferenceController(mContext, "pref_key");
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mPreferenceScreen.setKey("pref_key");
}
Also used : PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 47 with PreferenceManager

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

the class BluetoothDetailsControllerTestBase method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    mDeviceConfig = makeDefaultDeviceConfig();
    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);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = spy(new Lifecycle(mLifecycleOwner));
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
}
Also used : BluetoothManager(android.bluetooth.BluetoothManager) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 48 with PreferenceManager

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

the class UsbDetailsPowerRoleControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = 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);
    mDetailsPowerRoleController = new UsbDetailsPowerRoleController(mContext, mFragment, mUsbBackend);
    mPreference = new PreferenceCategory(mContext);
    mPreference.setKey(mDetailsPowerRoleController.getPreferenceKey());
    mScreen.addPreference(mPreference);
    mDetailsPowerRoleController.mHandler = mHandler;
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 49 with PreferenceManager

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

the class GameDriverAppPreferenceControllerTest method loadConfig.

private void loadConfig(String optIn, String prereleaseOptIn, String optOut) {
    Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_IN_APPS, optIn);
    Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_PRERELEASE_OPT_IN_APPS, prereleaseOptIn);
    Settings.Global.putString(mResolver, Settings.Global.GAME_DRIVER_OPT_OUT_APPS, optOut);
    mController = new GameDriverAppPreferenceController(mContext, "testKey");
    mGroup = spy(new PreferenceCategory(mContext));
    final PreferenceManager preferenceManager = new PreferenceManager(mContext);
    when(mGroup.getContext()).thenReturn(mContext);
    when(mGroup.getPreferenceManager()).thenReturn(preferenceManager);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mGroup);
    mController.displayPreference(mScreen);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) PreferenceManager(androidx.preference.PreferenceManager)

Example 50 with PreferenceManager

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

the class InstantAppButtonsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    final PackageInfo packageInfo = mock(PackageInfo.class);
    packageInfo.applicationInfo = mAppInfo;
    when(mFragment.getPackageInfo()).thenReturn(packageInfo);
    mPreferenceManager = new PreferenceManager(mContext);
    mScreen = mPreferenceManager.createPreferenceScreen(mContext);
    when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
    final View buttons = View.inflate(RuntimeEnvironment.application, R.layout.instant_app_buttons, null);
    mLaunchButton = buttons.findViewById(R.id.launch);
    mInstallButton = buttons.findViewById(R.id.install);
    mClearAppButton = buttons.findViewById(R.id.clear_data);
    mController = spy(new InstantAppButtonsPreferenceController(mContext, mFragment, TEST_AIA_PACKAGE_NAME, null));
    when(mPreference.getKey()).thenReturn("instant_app_buttons");
    mScreen.addPreference(mPreference);
    when(mPreference.findViewById(R.id.instant_app_button_container)).thenReturn(buttons);
}
Also used : PackageInfo(android.content.pm.PackageInfo) PreferenceManager(androidx.preference.PreferenceManager) View(android.view.View) 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