Search in sources :

Example 26 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SlicesDatabaseAccessorTest method getSliceKeys_indexesDatabase.

@Test
@Config(qualifiers = "mcc999")
public void getSliceKeys_indexesDatabase() {
    // Force new indexing
    Locale.setDefault(new Locale("ca"));
    final SearchFeatureProvider provider = new SearchFeatureProviderImpl();
    final SlicesFeatureProvider sliceProvider = spy(new SlicesFeatureProviderImpl());
    final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
    factory.searchFeatureProvider = provider;
    factory.slicesFeatureProvider = sliceProvider;
    // Fake the indexable list.
    provider.getSearchIndexableResources().getProviderValues().clear();
    provider.getSearchIndexableResources().getProviderValues().add(FakeIndexProvider.class);
    final SlicesDatabaseAccessor accessor = new SlicesDatabaseAccessor(mContext);
    final List<String> keys = accessor.getSliceKeys(true);
    assertThat(keys).isNotEmpty();
}
Also used : Locale(java.util.Locale) SearchFeatureProviderImpl(com.android.settings.search.SearchFeatureProviderImpl) SearchFeatureProvider(com.android.settings.search.SearchFeatureProvider) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 27 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.

the class SecurityDashboardActivityTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
    mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
    mDefaultIntent = new Intent();
    mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
    mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(), Settings.SecurityDashboardActivity.class);
    mDefaultIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT_CLASSNAME);
    InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
        try {
            mActivity = (Settings.SecurityDashboardActivity) InstrumentationRegistry.getInstrumentation().newActivity(getClass().getClassLoader(), Settings.SecurityDashboardActivity.class.getName(), mDefaultIntent);
        } catch (Exception e) {
            // nothing to do
            throw new RuntimeException(e);
        }
    });
}
Also used : Intent(android.content.Intent) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Settings(com.android.settings.Settings) Before(org.junit.Before)

Example 28 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.

the class SecuritySettingsTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mContext = ApplicationProvider.getApplicationContext();
    FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
    mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
    SecurityFeatureProvider mSecurityFeatureProvider = mFeatureFactory.getSecurityFeatureProvider();
    when(mSecurityFeatureProvider.getTrustAgentManager()).thenReturn(mTrustAgentManager);
}
Also used : FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 29 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.

the class ControlsPrivacyPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
    mContentResolver = mContext.getContentResolver();
    FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
    when(featureFactory.securityFeatureProvider.getLockPatternUtils(mContext)).thenReturn(mLockPatternUtils);
    when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
    mController = new ControlsPrivacyPreferenceController(mContext, TEST_KEY);
}
Also used : FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 30 with FakeFeatureFactory

use of com.android.settings.testutils.FakeFeatureFactory in project android_packages_apps_Settings by omnirom.

the class SetNewPasswordActivityTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mockMetricsProvider = fakeFeatureFactory.getMetricsFeatureProvider();
    when(mockMetricsProvider.getAttribution(any())).thenReturn(SettingsEnums.PAGE_UNKNOWN);
    mProvisioned = Settings.Global.getInt(RuntimeEnvironment.application.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
}
Also used : FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Aggregations

FakeFeatureFactory (com.android.settings.testutils.FakeFeatureFactory)58 Test (org.junit.Test)35 Before (org.junit.Before)28 Context (android.content.Context)26 Config (org.robolectric.annotation.Config)22 TestConfig (com.android.settings.TestConfig)17 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Activity (android.app.Activity)10 PackageManager (android.content.pm.PackageManager)10 Preference (android.support.v7.preference.Preference)10 ContentResolver (android.content.ContentResolver)7 AppOpsManager (android.app.AppOpsManager)5 Fragment (android.app.Fragment)5 LoaderManager (android.app.LoaderManager)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 Drawable (android.graphics.drawable.Drawable)5 BatteryStats (android.os.BatteryStats)5 UserHandle (android.os.UserHandle)5 RecyclerView (android.support.v7.widget.RecyclerView)5