Search in sources :

Example 81 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFeatureProviderImplTest method bindPreference_shouldBindAllData.

@Test
public void bindPreference_shouldBindAllData() {
    final Preference preference = new Preference(ShadowApplication.getInstance().getApplicationContext());
    final Tile tile = new Tile();
    tile.title = "title";
    tile.summary = "summary";
    tile.icon = Icon.createWithBitmap(Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565));
    tile.metaData = new Bundle();
    tile.metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, "HI");
    tile.priority = 10;
    mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.SETTINGS_GESTURES, preference, tile, "123", Preference.DEFAULT_ORDER);
    assertThat(preference.getTitle()).isEqualTo(tile.title);
    assertThat(preference.getSummary()).isEqualTo(tile.summary);
    assertThat(preference.getIcon()).isNotNull();
    assertThat(preference.getFragment()).isEqualTo(tile.metaData.getString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS));
    assertThat(preference.getOrder()).isEqualTo(-tile.priority);
}
Also used : Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 82 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

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();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Context(android.content.Context) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 83 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFragmentTest method tintTileIcon_noMetadata_shouldReturnPackageNameCheck.

@Test
public void tintTileIcon_noMetadata_shouldReturnPackageNameCheck() {
    final Tile tile = new Tile();
    tile.icon = mock(Icon.class);
    final Intent intent = new Intent();
    tile.intent = intent;
    intent.setComponent(new ComponentName(ShadowApplication.getInstance().getApplicationContext().getPackageName(), "TestClass"));
    assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
    intent.setComponent(new ComponentName("OtherPackage", "TestClass"));
    assertThat(mTestFragment.tintTileIcon(tile)).isTrue();
}
Also used : Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon) Test(org.junit.Test)

Example 84 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardFragmentTest method tintTileIcon_noIcon_shouldReturnFalse.

@Test
public void tintTileIcon_noIcon_shouldReturnFalse() {
    final Tile tile = new Tile();
    final Bundle metaData = new Bundle();
    tile.metaData = metaData;
    assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
}
Also used : Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 85 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by crdroidandroid.

the class DashboardItemAnimatorTest method SetUp.

@Before
public void SetUp() {
    final Context context = ShadowApplication.getInstance().getApplicationContext();
    mDashboardItemAnimator = new DashboardItemAnimator();
    mViewHolder = new ViewHolder(new TextView(context));
    mViewHolder.itemView.setTag(new Tile());
}
Also used : Context(android.content.Context) ViewHolder(com.android.settings.dashboard.SupportItemAdapter.ViewHolder) Tile(com.android.settingslib.drawer.Tile) TextView(android.widget.TextView) Before(org.junit.Before)

Aggregations

Tile (com.android.settingslib.drawer.Tile)506 Test (org.junit.Test)345 Intent (android.content.Intent)160 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)117 Bundle (android.os.Bundle)108 Preference (android.support.v7.preference.Preference)98 ComponentName (android.content.ComponentName)93 ArrayList (java.util.ArrayList)87 Context (android.content.Context)70 ActivityTile (com.android.settingslib.drawer.ActivityTile)50 ProviderTile (com.android.settingslib.drawer.ProviderTile)45 UserHandle (android.os.UserHandle)39 Preference (androidx.preference.Preference)39 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 Activity (android.app.Activity)29 VisibleForTesting (android.support.annotation.VisibleForTesting)29 PackageManager (android.content.pm.PackageManager)25 ViewGroup (android.view.ViewGroup)24