use of com.android.settings.dashboard.DashboardFeatureProviderImpl in project platform_packages_apps_Settings by BlissRoms.
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");
}
use of com.android.settings.dashboard.DashboardFeatureProviderImpl in project android_packages_apps_Settings by omnirom.
the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent.
@Test
public void refreshDashboardTiles_HasAccountType_shouldAddAccountNameToIntent() {
final DashboardFeatureProviderImpl dashboardFeatureProvider = new DashboardFeatureProviderImpl(mContext);
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 ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT);
mActivityInfo.metaData.putString(METADATA_ACCOUNT_TYPE, "com.abc");
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_TITLE, "summary");
mActivityInfo.metaData.putString("com.android.settings.intent.action", Intent.ACTION_ASSIST);
tile.userHandle = null;
mFragment.displayTile(tile);
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final Preference preference = new Preference(mContext);
dashboardFeatureProvider.bindPreferenceToTileAndGetObservers(activity, false, /* forceRoundedIcon */
MetricsProto.MetricsEvent.DASHBOARD_SUMMARY, preference, tile, null, /* key */
Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
preference.performClick();
final Intent intent = Shadows.shadowOf(activity).getNextStartedActivityForResult().intent;
assertThat(intent.getStringExtra("extra.accountName")).isEqualTo("name1@abc.com");
}
Aggregations