use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class ProfileSelectDialogTest method updateUserHandlesIfNeeded_Remove.
@Test
public void updateUserHandlesIfNeeded_Remove() {
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle.add(REMOVED_USER);
tile.userHandle.add(NORMAL_USER);
tile.userHandle.add(REMOVED_USER);
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
assertThat(tile.userHandle).hasSize(1);
assertThat(tile.userHandle.get(0).getIdentifier()).isEqualTo(NORMAL_USER.getIdentifier());
verify(mUserManager, times(1)).getUserInfo(NORMAL_USER.getIdentifier());
verify(mUserManager, times(2)).getUserInfo(REMOVED_USER.getIdentifier());
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindIcon_withStaticIconAndIconUri_shouldLoadIconFromContentProvider.
@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindIcon_withStaticIconAndIconUri_shouldLoadIconFromContentProvider() {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON, R.drawable.ic_add_40dp);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_ICON_URI, "content://com.android.settings/tile_icon");
mImpl.bindIcon(preference, tile, false);
final Bitmap preferenceBmp = Utils.createIconWithDrawable(preference.getIcon()).getBitmap();
final Drawable staticIcon = Icon.createWithResource(mActivityInfo.packageName, R.drawable.ic_add_40dp).loadDrawable(preference.getContext());
final Bitmap staticIconBmp = Utils.createIconWithDrawable(staticIcon).getBitmap();
assertThat(preferenceBmp.sameAs(staticIconBmp)).isFalse();
final Pair<String, Integer> iconInfo = TileUtils.getIconFromUri(mContext, "pkg", null, /* uri */
null);
final Drawable iconFromUri = Icon.createWithResource(iconInfo.first, iconInfo.second).loadDrawable(preference.getContext());
final Bitmap iconBmpFromUri = Utils.createIconWithDrawable(iconFromUri).getBitmap();
assertThat(preferenceBmp.sameAs(iconBmpFromUri)).isTrue();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_withOrderMetadata_shouldUseOrderInMetadata.
@Test
public void bindPreference_withOrderMetadata_shouldUseOrderInMetadata() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final int testOrder = -30;
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, testOrder);
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getOrder()).isEqualTo(testOrder);
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_validUserHandleShouldNotShow.
@Test
public void openTileIntent_profileSelectionDialog_validUserHandleShouldNotShow() {
final int userId = 10;
ShadowUserManager.getShadow().addUser(userId, "Someone", 0);
final UserHandle userHandle = new UserHandle(userId);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.getIntent().putExtra(EXTRA_USER, userHandle);
final ArrayList<UserHandle> handles = new ArrayList<>();
handles.add(new UserHandle(0));
handles.add(userHandle);
tile.userHandle = handles;
mImpl.openTileIntent(mActivity, tile);
final ArgumentCaptor<UserHandle> argument = ArgumentCaptor.forClass(UserHandle.class);
verify(mActivity).startActivityForResultAsUser(any(Intent.class), anyInt(), argument.capture());
assertThat(argument.getValue().getIdentifier()).isEqualTo(userId);
verify(mActivity, never()).getSupportFragmentManager();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProviderAndHaveObserver.
@Test
@Config(shadows = { ShadowTileUtils.class })
public void bindPreference_hasSummaryUri_shouldLoadSummaryFromContentProviderAndHaveObserver() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
final String uriString = "content://com.android.settings/tile_summary";
mActivityInfo.metaData.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, uriString);
final List<DynamicDataObserver> observers = mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
Preference.DEFAULT_ORDER);
assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
assertThat(observers.get(0).getUri().toString()).isEqualTo(uriString);
}
Aggregations