use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent.
@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logStartedIntent(any(Intent.class), eq(MetricsEvent.SETTINGS_GESTURES));
verify(mActivity).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class ProfileSelectDialogTest method updateUserHandlesIfNeeded_Normal.
@Test
public void updateUserHandlesIfNeeded_Normal() {
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle.add(NORMAL_USER);
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
assertThat(tile.userHandle).hasSize(1);
assertThat(tile.userHandle.get(0).getIdentifier()).isEqualTo(NORMAL_USER.getIdentifier());
verify(mUserManager, never()).getUserInfo(NORMAL_USER.getIdentifier());
}
use of com.android.settingslib.drawer.ActivityTile 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");
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class AccountDetailDashboardFragmentTest method refreshDashboardTiles_NoAccountType_shouldNotDisplay.
@Test
public void refreshDashboardTiles_NoAccountType_shouldNotDisplay() {
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
mActivityInfo.metaData.putString(METADATA_CATEGORY, CategoryKey.CATEGORY_ACCOUNT_DETAIL);
assertThat(mFragment.displayTile(tile)).isFalse();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class CategoryManagerTest method backwardCompatCleanupForCategory_shouldNotChangeCategoryForNewKeys.
@Test
public void backwardCompatCleanupForCategory_shouldNotChangeCategoryForNewKeys() {
final Tile tile1 = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
final Tile tile2 = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_ACCOUNT);
final DashboardCategory category = new DashboardCategory(CategoryKey.CATEGORY_ACCOUNT);
category.addTile(tile1);
category.addTile(tile2);
mCategoryByKeyMap.put(CategoryKey.CATEGORY_ACCOUNT, category);
mTileByComponentCache.put(new Pair<>("PACKAGE", "1"), tile1);
mTileByComponentCache.put(new Pair<>("PACKAGE", "2"), tile2);
mCategoryManager.backwardCompatCleanupForCategory(mTileByComponentCache, mCategoryByKeyMap);
assertThat(mCategoryByKeyMap.size()).isEqualTo(1);
assertThat(mCategoryByKeyMap.get(CategoryKey.CATEGORY_ACCOUNT)).isNotNull();
}
Aggregations