use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_shouldBindAllData.
@Test
public void bindPreference_shouldBindAllData() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = spy(new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
mActivityInfo.metaData.putInt(META_DATA_KEY_ORDER, 10);
doReturn(Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565))).when(tile).getIcon(any(Context.class));
mActivityInfo.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getTitle()).isEqualTo(mContext.getText(R.string.settings_label));
assertThat(preference.getSummary()).isEqualTo(mContext.getText(R.string.about_settings_summary));
assertThat(preference.getIcon()).isNotNull();
assertThat(preference.getFragment()).isEqualTo(mActivityInfo.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS));
assertThat(preference.getOrder()).isEqualTo(tile.getOrder());
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindIcon_withStaticIcon_shouldLoadStaticIcon.
@Test
public void bindIcon_withStaticIcon_shouldLoadStaticIcon() {
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);
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)).isTrue();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_invalidUserHandleShouldShow.
@Test
public void openTileIntent_profileSelectionDialog_invalidUserHandleShouldShow() {
ShadowUserManager.getShadow().addUser(10, "Someone", 0);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.getIntent().putExtra(EXTRA_USER, new UserHandle(30));
final ArrayList<UserHandle> handles = new ArrayList<>();
handles.add(new UserHandle(0));
handles.add(new UserHandle(10));
tile.userHandle = handles;
mImpl.openTileIntent(mActivity, tile);
verify(mActivity, never()).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
verify(mActivity).getSupportFragmentManager();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog.
@Test
public void bindPreference_toInternalSettingActivity_shouldBindToDirectLaunchIntentAndNotLog() {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.packageName = RuntimeEnvironment.application.getPackageName();
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logStartedIntent(any(Intent.class), anyInt());
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 DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_unresolvableWorkProfileIntentShouldNotShow.
@Test
public void openTileIntent_profileSelectionDialog_unresolvableWorkProfileIntentShouldNotShow() {
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);
final ArrayList<UserHandle> handles = new ArrayList<>();
handles.add(new UserHandle(0));
handles.add(userHandle);
tile.userHandle = handles;
when(mPackageManager.resolveActivityAsUser(any(Intent.class), anyInt(), eq(0))).thenReturn(new ResolveInfo());
when(mPackageManager.resolveActivityAsUser(any(Intent.class), anyInt(), eq(userId))).thenReturn(null);
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(0);
verify(mActivity, never()).getSupportFragmentManager();
}
Aggregations