Search in sources :

Example 1 with NAMESPACE_APP_HIBERNATION

use of android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION in project android_packages_apps_Settings by omnirom.

the class HibernatedAppsPreferenceControllerTest method setUp.

@Before
public void setUp() {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    MockitoAnnotations.initMocks(this);
    DeviceConfig.setProperty(NAMESPACE_APP_HIBERNATION, PROPERTY_APP_HIBERNATION_ENABLED, "true", false);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getPackageManager()).thenReturn(mPackageManager);
    when(mContext.getSystemService(AppHibernationManager.class)).thenReturn(mAppHibernationManager);
    when(mContext.getSystemService(UsageStatsManager.class)).thenReturn(new UsageStatsManager(mContext, mIUsageStatsManager));
    PreferenceManager manager = new PreferenceManager(mContext);
    mPreferenceScreen = manager.createPreferenceScreen(mContext);
    Preference preference = mock(Preference.class);
    when(preference.getKey()).thenReturn(KEY);
    mPreferenceScreen.addPreference(preference);
    mController = new HibernatedAppsPreferenceController(mContext, KEY, command -> command.run(), command -> command.run());
}
Also used : Context(android.content.Context) Arrays(java.util.Arrays) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) PackageManager(android.content.pm.PackageManager) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) AppHibernationManager(android.apphibernation.AppHibernationManager) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) RemoteException(android.os.RemoteException) Mockito.spy(org.mockito.Mockito.spy) PackageInfo(android.content.pm.PackageInfo) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) AVAILABLE(com.android.settings.core.BasePreferenceController.AVAILABLE) ApplicationProvider(androidx.test.core.app.ApplicationProvider) IUsageStatsManager(android.app.usage.IUsageStatsManager) MockitoAnnotations(org.mockito.MockitoAnnotations) UsageStats(android.app.usage.UsageStats) Looper(android.os.Looper) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) PreferenceScreen(androidx.preference.PreferenceScreen) ParceledListSlice(android.content.pm.ParceledListSlice) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Truth.assertThat(com.google.common.truth.Truth.assertThat) Preference(androidx.preference.Preference) Mockito.verify(org.mockito.Mockito.verify) UsageStatsManager(android.app.usage.UsageStatsManager) NAMESPACE_APP_HIBERNATION(android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION) PreferenceManager(androidx.preference.PreferenceManager) DeviceConfig(android.provider.DeviceConfig) PROPERTY_APP_HIBERNATION_ENABLED(com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) Resources(android.content.res.Resources) Preference(androidx.preference.Preference) IUsageStatsManager(android.app.usage.IUsageStatsManager) UsageStatsManager(android.app.usage.UsageStatsManager) PreferenceManager(androidx.preference.PreferenceManager) Before(org.junit.Before)

Aggregations

IUsageStatsManager (android.app.usage.IUsageStatsManager)1 UsageStats (android.app.usage.UsageStats)1 UsageStatsManager (android.app.usage.UsageStatsManager)1 AppHibernationManager (android.apphibernation.AppHibernationManager)1 Context (android.content.Context)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 ParceledListSlice (android.content.pm.ParceledListSlice)1 Resources (android.content.res.Resources)1 Looper (android.os.Looper)1 RemoteException (android.os.RemoteException)1 DeviceConfig (android.provider.DeviceConfig)1 NAMESPACE_APP_HIBERNATION (android.provider.DeviceConfig.NAMESPACE_APP_HIBERNATION)1 Preference (androidx.preference.Preference)1 PreferenceManager (androidx.preference.PreferenceManager)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 ApplicationProvider (androidx.test.core.app.ApplicationProvider)1 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 PROPERTY_APP_HIBERNATION_ENABLED (com.android.settings.Utils.PROPERTY_APP_HIBERNATION_ENABLED)1 AVAILABLE (com.android.settings.core.BasePreferenceController.AVAILABLE)1