Search in sources :

Example 66 with PreferenceScreen

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

the class AudioOutputSwitchPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mAudioManager = mContext.getSystemService(AudioManager.class);
    mShadowAudioManager = ShadowAudioManager.getShadow();
    ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
    mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
    when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
    when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
    when(mLocalBluetoothProfileManager.getA2dpProfile()).thenReturn(mA2dpProfile);
    when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
    when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
    mPackageManager = Shadow.extract(mContext.getPackageManager());
    mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
    when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
    when(mBluetoothDevice.isConnected()).thenReturn(true);
    mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
    when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
    mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
    when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
    mController = new AudioSwitchPreferenceControllerTestable(mContext, TEST_KEY);
    mScreen = spy(new PreferenceScreen(mContext, null));
    mPreference = new ListPreference(mContext);
    mProfileConnectedDevices = new ArrayList<>();
    mHearingAidActiveDevices = new ArrayList<>(2);
    mEmptyDevices = new ArrayList<>(2);
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    when(mScreen.getContext()).thenReturn(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mScreen.addPreference(mPreference);
    mController.displayPreference(mScreen);
}
Also used : AudioManager(android.media.AudioManager) ShadowAudioManager(com.android.settings.testutils.shadow.ShadowAudioManager) PreferenceScreen(androidx.preference.PreferenceScreen) BluetoothManager(android.bluetooth.BluetoothManager) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 67 with PreferenceScreen

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

the class HandsFreeProfileOutputPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mAudioManager = mContext.getSystemService(AudioManager.class);
    mShadowAudioManager = ShadowAudioManager.getShadow();
    ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
    mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
    when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
    when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
    when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
    when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
    mBluetoothManager = new BluetoothManager(mContext);
    mBluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
    when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
    when(mBluetoothDevice.isConnected()).thenReturn(true);
    mSecondBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
    when(mSecondBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_2);
    when(mSecondBluetoothDevice.isConnected()).thenReturn(true);
    mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
    when(mLeftBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_1);
    when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
    mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_4));
    when(mRightBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_2);
    when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
    mController = new HandsFreeProfileOutputPreferenceController(mContext, TEST_KEY);
    mScreen = spy(new PreferenceScreen(mContext, null));
    mPreference = new ListPreference(mContext);
    mProfileConnectedDevices = new ArrayList<>();
    mHearingAidActiveDevices = new ArrayList<>(2);
    when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
    when(mScreen.getContext()).thenReturn(mContext);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    mScreen.addPreference(mPreference);
    mController.displayPreference(mScreen);
    mController.setCallback(mAudioSwitchPreferenceCallback);
}
Also used : AudioManager(android.media.AudioManager) ShadowAudioManager(com.android.settings.testutils.shadow.ShadowAudioManager) PreferenceScreen(androidx.preference.PreferenceScreen) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) BluetoothManager(android.bluetooth.BluetoothManager) ListPreference(androidx.preference.ListPreference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 68 with PreferenceScreen

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

the class HighlightablePreferenceGroupAdapterTest method adjustInitialExpandedChildCount_hasHightlightKey_shouldExpandAllChildren.

@Test
public void adjustInitialExpandedChildCount_hasHightlightKey_shouldExpandAllChildren() {
    final Bundle args = new Bundle();
    when(mFragment.getArguments()).thenReturn(args);
    args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, "testkey");
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    when(mFragment.getPreferenceScreen()).thenReturn(screen);
    HighlightablePreferenceGroupAdapter.adjustInitialExpandedChildCount(mFragment);
    verify(screen).setInitialExpandedChildrenCount(Integer.MAX_VALUE);
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) Test(org.junit.Test)

Example 69 with PreferenceScreen

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

the class WifiNetworkDetailsFragmentTest method restrictUi_shouldShowRestrictedText.

@Test
public void restrictUi_shouldShowRestrictedText() {
    final WifiNetworkDetailsFragmentTest.FakeFragment fragment = spy(new WifiNetworkDetailsFragmentTest.FakeFragment());
    final PreferenceScreen screen = mock(PreferenceScreen.class);
    final TextView restrictedText = mock(TextView.class);
    doReturn(screen).when(fragment).getPreferenceScreen();
    doReturn(false).when(fragment).isUiRestrictedByOnlyAdmin();
    doReturn(restrictedText).when(fragment).getEmptyTextView();
    fragment.restrictUi();
    verify(restrictedText).setText(anyInt());
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) TextView(android.widget.TextView) Test(org.junit.Test)

Example 70 with PreferenceScreen

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

the class AccountDetailDashboardFragment method updateUi.

@VisibleForTesting
void updateUi() {
    final Context context = getContext();
    UserHandle userHandle = null;
    Bundle args = getArguments();
    if (args != null && args.containsKey(KEY_USER_HANDLE)) {
        userHandle = args.getParcelable(KEY_USER_HANDLE);
    }
    final AuthenticatorHelper helper = new AuthenticatorHelper(context, userHandle, null);
    final AccountTypePreferenceLoader accountTypePreferenceLoader = new AccountTypePreferenceLoader(this, helper, userHandle);
    PreferenceScreen prefs = accountTypePreferenceLoader.addPreferencesForType(mAccountType, getPreferenceScreen());
    if (prefs != null) {
        accountTypePreferenceLoader.updatePreferenceIntents(prefs, mAccountType, mAccount);
    }
}
Also used : Context(android.content.Context) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

PreferenceScreen (androidx.preference.PreferenceScreen)244 Preference (androidx.preference.Preference)81 Test (org.junit.Test)60 Context (android.content.Context)36 PreferenceManager (androidx.preference.PreferenceManager)36 ContentResolver (android.content.ContentResolver)25 PreferenceCategory (androidx.preference.PreferenceCategory)24 Bundle (android.os.Bundle)20 ArrayList (java.util.ArrayList)20 SwitchPreference (androidx.preference.SwitchPreference)19 Resources (android.content.res.Resources)18 Before (org.junit.Before)17 ListPreference (androidx.preference.ListPreference)14 PackageManager (android.content.pm.PackageManager)13 PreferenceGroup (androidx.preference.PreferenceGroup)13 ApplicationInfo (android.content.pm.ApplicationInfo)9 VisibleForTesting (androidx.annotation.VisibleForTesting)9 List (java.util.List)9 UserManager (android.os.UserManager)8 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)8