use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.
@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.application.getPackageManager());
FragmentActivity activity = Robolectric.buildActivity(FragmentActivity.class).get();
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
mActivityInfo.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTileAndGetObservers(activity, mForceRoundedIcon, MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
final ShadowActivity.IntentForResult launchIntent = Shadows.shadowOf(activity).getNextStartedActivityForResult();
assertThat(launchIntent).isNull();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method openTileIntent_profileSelectionDialog_shouldShow.
@Test
public void openTileIntent_profileSelectionDialog_shouldShow() {
ShadowUserManager.getShadow().addUser(10, "Someone", 0);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
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()).startActivityForResult(any(Intent.class), eq(0));
verify(mActivity).getSupportFragmentManager();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_noSummary_shouldSetNullSummary.
@Test
public void bindPreference_noSummary_shouldSetNullSummary() {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.metaData.remove(META_DATA_PREFERENCE_SUMMARY);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /*key */
Preference.DEFAULT_ORDER);
assertThat(preference.getSummary()).isNull();
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyTileKey_shouldUseTileKey.
@Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
final Preference preference = new Preference(RuntimeEnvironment.application);
mActivityInfo.metaData.putString(META_DATA_PREFERENCE_KEYHINT, "key");
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /* key */
Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isEqualTo(tile.getKey(mContext));
}
use of com.android.settingslib.drawer.ActivityTile in project android_packages_apps_Settings by omnirom.
the class DashboardFeatureProviderImplTest method bindPreference_invalidOrderMetadata_shouldIgnore.
@Test
public void bindPreference_invalidOrderMetadata_shouldIgnore() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
mActivityInfo.metaData.putString(META_DATA_KEY_ORDER, "hello");
mImpl.bindPreferenceToTileAndGetObservers(mActivity, mForceRoundedIcon, MetricsEvent.VIEW_UNKNOWN, preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getOrder()).isEqualTo(Preference.DEFAULT_ORDER);
}
Aggregations