Search in sources :

Example 31 with FakeFeatureFactory

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

the class WalletPrivacyPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mContentResolver = mContext.getContentResolver();
    FakeFeatureFactory featureFactory = FakeFeatureFactory.setupForTest();
    when(featureFactory.securityFeatureProvider.getLockPatternUtils(mContext)).thenReturn(mLockPatternUtils);
    when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
    when(mClient.isWalletServiceAvailable()).thenReturn(true);
    mController = new WalletPrivacyPreferenceController(mContext, TEST_KEY) {

        @Override
        QuickAccessWalletClient initWalletClient() {
            return mClient;
        }
    };
}
Also used : QuickAccessWalletClient(android.service.quickaccesswallet.QuickAccessWalletClient) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 32 with FakeFeatureFactory

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

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 = 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(new SearchIndexableData(FakeIndexProvider.class, FakeIndexProvider.SEARCH_INDEX_DATA_PROVIDER));
    final SlicesDatabaseAccessor accessor = new SlicesDatabaseAccessor(mContext);
    final List<Uri> keys = accessor.getSliceUris(SettingsSliceProvider.SLICE_AUTHORITY, true);
    assertThat(keys).isNotEmpty();
}
Also used : Locale(java.util.Locale) SearchFeatureProviderImpl(com.android.settings.search.SearchFeatureProviderImpl) SearchIndexableData(com.android.settingslib.search.SearchIndexableData) SearchFeatureProvider(com.android.settings.search.SearchFeatureProvider) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Uri(android.net.Uri) FakeIndexProvider(com.android.settings.testutils.FakeIndexProvider) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 33 with FakeFeatureFactory

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

the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent.

@Test
public void refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent() {
    FakeFeatureFactory.setupForTest(mActivity);
    final FakeFeatureFactory featureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
    final DashboardFeatureProviderImpl dashboardFeatureProvider = new DashboardFeatureProviderImpl(mActivity);
    final PackageManager packageManager = mock(PackageManager.class);
    ReflectionHelpers.setField(dashboardFeatureProvider, "mPackageManager", packageManager);
    when(packageManager.resolveActivity(any(Intent.class), anyInt())).thenReturn(mock(ResolveInfo.class));
    final Tile tile = new Tile();
    tile.key = "key";
    tile.metaData = new Bundle();
    tile.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
    tile.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
    tile.metaData.putString("com.android.settings.intent.action", Intent.ACTION_ASSIST);
    tile.intent = new Intent();
    tile.userHandle = null;
    mFragment.displayTile(tile);
    final Activity activity = Robolectric.buildActivity(Activity.class).get();
    final Preference preference = new Preference(mContext);
    dashboardFeatureProvider.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, "key", Preference.DEFAULT_ORDER);
    preference.performClick();
    final Intent intent = shadowOf(activity).getNextStartedActivityForResult().intent;
    assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle) DashboardFeatureProviderImpl(com.android.settings.dashboard.DashboardFeatureProviderImpl) Tile(com.android.settingslib.drawer.Tile) Activity(android.app.Activity) Intent(android.content.Intent) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test)

Example 34 with FakeFeatureFactory

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

the class InstalledAppResultLoaderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest(mContext);
    when(factory.searchFeatureProvider.getSiteMapManager()).thenReturn(mSiteMapManager);
    final List<UserInfo> infos = new ArrayList<>();
    infos.add(new UserInfo(1, "user 1", 0));
    when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
    when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
    when(mContext.getString(R.string.applications_settings)).thenReturn("app");
    when(mPackageManagerWrapper.getInstalledApplicationsAsUser(anyInt(), anyInt())).thenReturn(Arrays.asList(ApplicationTestUtils.buildInfo(0, /* uid */
    "app1", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
    "app2", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
    "app3", FLAG_SYSTEM, 0), ApplicationTestUtils.buildInfo(0, /* uid */
    "app4", 0, /* flags */
    0), ApplicationTestUtils.buildInfo(0, /* uid */
    "app", 0, /* flags */
    0), ApplicationTestUtils.buildInfo(0, /* uid */
    "appBuffer", 0, /* flags */
    0)));
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 35 with FakeFeatureFactory

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

the class GesturesSettingsPreferenceControllerTest method updateState_sensorNotAvailable_shouldSetToEmptyStatus.

@Test
@Config(shadows = { ShadowSecureSettings.class })
public void updateState_sensorNotAvailable_shouldSetToEmptyStatus() {
    final FakeFeatureFactory featureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mActivity);
    when(featureFactory.assistGestureFeatureProvider.isSensorAvailable(any(Context.class))).thenReturn(false);
    mController.updateState(mPreference);
    verify(mPreference).setSummary("");
}
Also used : Context(android.content.Context) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

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