Search in sources :

Example 1 with FooterPreferenceMixinCompat

use of com.android.settingslib.widget.FooterPreferenceMixinCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EnterpriseDisclosurePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mController = spy(new EnterpriseDisclosurePreferenceController(mContext));
    mFragment = spy(new ChooseAccountFragment());
    mFooterPreferenceMixin = new FooterPreferenceMixinCompat(mFragment, mFragment.getSettingsLifecycle());
    mPreferenceManager = new PreferenceManager(mContext);
    mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
}
Also used : FooterPreferenceMixinCompat(com.android.settingslib.widget.FooterPreferenceMixinCompat) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 2 with FooterPreferenceMixinCompat

use of com.android.settingslib.widget.FooterPreferenceMixinCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BillingCycleSettingsTest method onCreate_emptyArguments_shouldSetDefaultNetworkTemplate.

@Test
public void onCreate_emptyArguments_shouldSetDefaultNetworkTemplate() {
    final BillingCycleSettings billingCycleSettings = spy(new BillingCycleSettings());
    when(billingCycleSettings.getContext()).thenReturn(mContext);
    when(billingCycleSettings.getArguments()).thenReturn(Bundle.EMPTY);
    final FragmentActivity activity = mock(FragmentActivity.class);
    when(billingCycleSettings.getActivity()).thenReturn(activity);
    final Resources.Theme theme = mContext.getTheme();
    when(activity.getTheme()).thenReturn(theme);
    doNothing().when(billingCycleSettings).onCreatePreferences(any(Bundle.class), nullable(String.class));
    when(mContext.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(mNetworkPolicyManager);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
    final SwitchPreference preference = mock(SwitchPreference.class);
    when(billingCycleSettings.findPreference(anyString())).thenReturn(preference);
    final FooterPreferenceMixinCompat footer = mock(FooterPreferenceMixinCompat.class);
    ReflectionHelpers.setField(billingCycleSettings, "mFooterPreferenceMixin", footer);
    when(footer.createFooterPreference()).thenReturn(mock(FooterPreference.class));
    billingCycleSettings.onCreate(Bundle.EMPTY);
    assertThat(billingCycleSettings.mNetworkTemplate).isNotNull();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) SwitchPreference(androidx.preference.SwitchPreference) Bundle(android.os.Bundle) FooterPreferenceMixinCompat(com.android.settingslib.widget.FooterPreferenceMixinCompat) Resources(android.content.res.Resources) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FooterPreference(com.android.settingslib.widget.FooterPreference) Test(org.junit.Test)

Example 3 with FooterPreferenceMixinCompat

use of com.android.settingslib.widget.FooterPreferenceMixinCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class UsbDefaultFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    super.onCreatePreferences(savedInstanceState, rootKey);
    FooterPreferenceMixinCompat footer = new FooterPreferenceMixinCompat(this, this.getSettingsLifecycle());
    FooterPreference pref = footer.createFooterPreference();
    pref.setTitle(R.string.usb_default_info);
}
Also used : FooterPreferenceMixinCompat(com.android.settingslib.widget.FooterPreferenceMixinCompat) FooterPreference(com.android.settingslib.widget.FooterPreference)

Aggregations

FooterPreferenceMixinCompat (com.android.settingslib.widget.FooterPreferenceMixinCompat)3 FooterPreference (com.android.settingslib.widget.FooterPreference)2 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 FragmentActivity (androidx.fragment.app.FragmentActivity)1 PreferenceManager (androidx.preference.PreferenceManager)1 SwitchPreference (androidx.preference.SwitchPreference)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1