Search in sources :

Example 26 with Tile

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

the class DashboardFeatureProviderImplTest method bindPreference_withBaseOrder_shouldOffsetPriority.

@Test
public void bindPreference_withBaseOrder_shouldOffsetPriority() {
    final int baseOrder = 100;
    final Preference preference = new Preference(RuntimeEnvironment.application);
    final Tile tile = new Tile();
    tile.metaData = new Bundle();
    tile.priority = 10;
    mImpl.bindPreferenceToTile(mActivity, MetricsProto.MetricsEvent.VIEW_UNKNOWN, preference, tile, "123", baseOrder);
    assertThat(preference.getOrder()).isEqualTo(-tile.priority + baseOrder);
}
Also used : Preference(android.support.v7.preference.Preference) Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 27 with Tile

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

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 28 with Tile

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

the class DashboardFragmentTest method tintTileIcon_hasMetadata_shouldReturnIconTintableMetadata.

@Test
public void tintTileIcon_hasMetadata_shouldReturnIconTintableMetadata() {
    final Tile tile = new Tile();
    tile.icon = mock(Icon.class);
    final Bundle metaData = new Bundle();
    tile.metaData = metaData;
    metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, false);
    assertThat(mTestFragment.tintTileIcon(tile)).isFalse();
    metaData.putBoolean(TileUtils.META_DATA_PREFERENCE_ICON_TINTABLE, true);
    assertThat(mTestFragment.tintTileIcon(tile)).isTrue();
}
Also used : Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Icon(android.graphics.drawable.Icon) Test(org.junit.Test)

Example 29 with Tile

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

the class SummaryLoaderTest method testUpdateSummaryToCache_hasCache_shouldUpdate.

@Test
public void testUpdateSummaryToCache_hasCache_shouldUpdate() {
    final String testSummary = "test_summary";
    final DashboardCategory category = new DashboardCategory();
    final Tile tile = new Tile();
    tile.key = "123";
    tile.intent = new Intent();
    category.addTile(tile);
    when(mFeatureFactory.dashboardFeatureProvider.getDashboardKeyForTile(tile)).thenReturn(tile.key);
    mSummaryLoader.updateSummaryIfNeeded(tile, testSummary);
    tile.summary = null;
    mSummaryLoader.updateSummaryToCache(category);
    assertThat(tile.summary).isEqualTo(testSummary);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) Test(org.junit.Test)

Example 30 with Tile

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

the class SummaryLoaderTest method SetUp.

@Before
public void SetUp() {
    MockitoAnnotations.initMocks(this);
    mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
    mTile = new Tile();
    mTile.summary = SUMMARY_1;
    mCallbackInvoked = false;
    final Activity activity = Robolectric.buildActivity(Activity.class).get();
    final List<DashboardCategory> categories = new ArrayList<>();
    mSummaryLoader = new SummaryLoader(activity, categories);
    mSummaryLoader.setSummaryConsumer(new SummaryLoader.SummaryConsumer() {

        @Override
        public void notifySummaryChanged(Tile tile) {
            mCallbackInvoked = true;
        }
    });
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Activity(android.app.Activity) Before(org.junit.Before)

Aggregations

Tile (com.android.settingslib.drawer.Tile)466 Test (org.junit.Test)309 Intent (android.content.Intent)158 Bundle (android.os.Bundle)117 Preference (android.support.v7.preference.Preference)108 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)102 ComponentName (android.content.ComponentName)98 ArrayList (java.util.ArrayList)79 Context (android.content.Context)71 UserHandle (android.os.UserHandle)32 Activity (android.app.Activity)31 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 VisibleForTesting (android.support.annotation.VisibleForTesting)30 PackageManager (android.content.pm.PackageManager)25 TypedArray (android.content.res.TypedArray)24 ViewGroup (android.view.ViewGroup)24 RemoteViews (android.widget.RemoteViews)24 SettingsActivity (com.android.settings.SettingsActivity)24