use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadata_shouldBindIntent.
@Test
public void bindPreference_noFragmentMetadata_shouldBindIntent() {
final Preference preference = new Preference(ShadowApplication.getInstance().getApplicationContext());
final Tile tile = new Tile();
tile.metaData = new Bundle();
tile.priority = 10;
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
assertThat(preference.getFragment()).isNull();
assertThat(preference.getOnPreferenceClickListener()).isNotNull();
assertThat(preference.getOrder()).isEqualTo(-tile.priority);
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent.
@Test
public void bindPreference_noFragmentMetadataSingleUser_shouldBindToDirectLaunchIntent() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile();
tile.metaData = new Bundle();
tile.userHandle = new ArrayList<>();
tile.userHandle.add(mock(UserHandle.class));
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.getOnPreferenceClickListener().onPreferenceClick(null);
verify(mFeatureFactory.metricsFeatureProvider).logDashboardStartIntent(any(Context.class), any(Intent.class), eq(MetricsProto.MetricsEvent.SETTINGS_GESTURES));
verify(mActivity).startActivityForResultAsUser(any(Intent.class), anyInt(), any(UserHandle.class));
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method getPreferences_hasTileForCategory_shouldReturnPrefList.
@Test
public void getPreferences_hasTileForCategory_shouldReturnPrefList() {
mImpl = new DashboardFeatureProviderImpl(mActivity);
ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
final DashboardCategory category = new DashboardCategory();
category.tiles.add(new Tile());
when(mCategoryManager.getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE))).thenReturn(category);
assertThat(mImpl.getPreferencesForCategory(mActivity, ShadowApplication.getInstance().getApplicationContext(), MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE).isEmpty()).isFalse();
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method bindPreference_withNullKeyTileKey_shouldUseTileKey.
@Test
public void bindPreference_withNullKeyTileKey_shouldUseTileKey() {
final Preference preference = new Preference(RuntimeEnvironment.application);
final Tile tile = new Tile();
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN, preference, tile, null, /* key */
Preference.DEFAULT_ORDER);
assertThat(preference.getKey()).isEqualTo(tile.key);
}
use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method clickPreference_withUnresolvableIntent_shouldNotLaunchAnything.
@Test
public void clickPreference_withUnresolvableIntent_shouldNotLaunchAnything() {
ReflectionHelpers.setField(mImpl, "mPackageManager", RuntimeEnvironment.getPackageManager());
Activity activity = Robolectric.buildActivity(Activity.class).get();
final ShadowApplication application = ShadowApplication.getInstance();
final Preference preference = new Preference(application.getApplicationContext());
final Tile tile = new Tile();
tile.key = "key";
tile.intent = new Intent();
tile.intent.setComponent(new ComponentName("pkg", "class"));
tile.metaData = new Bundle();
tile.metaData.putString("com.android.settings.intent.action", "TestAction");
tile.userHandle = null;
mImpl.bindPreferenceToTile(activity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
preference.performClick();
final ShadowActivity.IntentForResult launchIntent = shadowOf(activity).getNextStartedActivityForResult();
assertThat(launchIntent).isNull();
}
Aggregations