Search in sources :

Example 36 with PreferenceManager

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

the class FirmwareVersionPreferenceControllerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    final Context context = RuntimeEnvironment.application;
    final PreferenceManager preferenceManager = new PreferenceManager(context);
    mController = new FirmwareVersionPreferenceController(context, KEY);
    mPreference = new Preference(context);
    mPreference.setKey(KEY);
    mScreen = preferenceManager.createPreferenceScreen(context);
    mScreen.addPreference(mPreference);
}
Also used : Context(android.content.Context) Preference(androidx.preference.Preference) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Example 37 with PreferenceManager

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

the class InstantAppButtonsPreferenceControllerTest method setUp.

@Before
public void setUp() throws PackageManager.NameNotFoundException {
    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);
    final InstallSourceInfo installSourceInfo = mock(InstallSourceInfo.class);
    when(mPackageManager.getInstallSourceInfo(TEST_AIA_PACKAGE_NAME)).thenReturn(installSourceInfo);
    when(installSourceInfo.getInstallingPackageName()).thenReturn(TEST_INSTALLER_PACKAGE_NAME);
}
Also used : PackageInfo(android.content.pm.PackageInfo) InstallSourceInfo(android.content.pm.InstallSourceInfo) PreferenceManager(androidx.preference.PreferenceManager) View(android.view.View) Before(org.junit.Before)

Example 38 with PreferenceManager

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

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

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

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)

Example 40 with PreferenceManager

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

the class UsbDetailsTranscodeMtpControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    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);
    mUnderTest = new UsbDetailsTranscodeMtpController(mContext, mFragment, mUsbBackend);
    mPreference = new PreferenceCategory(mContext);
    mPreference.setKey(mUnderTest.getPreferenceKey());
    mScreen.addPreference(mPreference);
}
Also used : PreferenceCategory(androidx.preference.PreferenceCategory) 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