Search in sources :

Example 46 with Tile

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

the class DashboardAdapterTest method testSetCategoriesAndSuggestions_iconTinted.

@Test
public void testSetCategoriesAndSuggestions_iconTinted() {
    TypedArray mockTypedArray = mock(TypedArray.class);
    doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
    doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
    List<Tile> packages = makeSuggestions("pkg1");
    Icon mockIcon = mock(Icon.class);
    packages.get(0).isIconTintable = true;
    packages.get(0).icon = mockIcon;
    mDashboardAdapter.setCategoriesAndSuggestions(null, /* category */
    packages);
    verify(mockIcon).setTint(eq(0x89000000));
}
Also used : TypedArray(android.content.res.TypedArray) Tile(com.android.settingslib.drawer.Tile) Icon(android.graphics.drawable.Icon) Test(org.junit.Test)

Example 47 with Tile

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

the class DashboardDataTest method testGetPositionByTile_equalTitle_returnPositionFound.

@Test
public void testGetPositionByTile_equalTitle_returnPositionFound() {
    final Tile tile = mock(Tile.class);
    tile.title = TEST_CATEGORY_TILE_TITLE;
    final int position = mDashboardDataWithOneConditions.getPositionByTile(tile);
    assertThat(position).isNotEqualTo(DashboardData.POSITION_NOT_FOUND);
}
Also used : Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 48 with Tile

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

the class DashboardDataTest method testDiffUtil_typeSuggestedContainer_ResultDataNothingChanged.

@Test
public void testDiffUtil_typeSuggestedContainer_ResultDataNothingChanged() {
    // Build testResultData
    final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
    testResultData.add(new ListUpdateResult.ResultData(ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 0, 1));
    Tile tile = new Tile();
    tile.remoteViews = mock(RemoteViews.class);
    DashboardData prevData = new DashboardData.Builder().setConditions(null).setCategory(null).setSuggestions(Arrays.asList(tile)).build();
    DashboardData currentData = new DashboardData.Builder().setConditions(null).setCategory(null).setSuggestions(Arrays.asList(tile)).build();
    testDiffUtil(prevData, currentData, testResultData);
}
Also used : RemoteViews(android.widget.RemoteViews) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 49 with Tile

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

the class SiteMapManagerTest method buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp.

@Test
public void buildBreadCrumb_fromSiteMapDbAndDashboardProvider_breadcrumbShouldLinkUp() {
    final String iaClass = SystemDashboardFragment.class.getName();
    final String iaTitle = "ia_title";
    ContentValues index = new ContentValues();
    index.put(IndexDatabaseHelper.IndexColumns.CLASS_NAME, iaClass);
    index.put(IndexDatabaseHelper.IndexColumns.SCREEN_TITLE, iaTitle);
    mDb.replaceOrThrow(IndexDatabaseHelper.Tables.TABLE_PREFS_INDEX, null, index);
    final DashboardCategory category = new DashboardCategory();
    category.key = CategoryKey.CATEGORY_SYSTEM;
    category.tiles.add(new Tile());
    category.tiles.get(0).title = TITLE_PREFIX + STATIC_DB_DEPTH;
    category.tiles.get(0).metaData = new Bundle();
    category.tiles.get(0).metaData.putString(SettingsActivity.META_DATA_KEY_FRAGMENT_CLASS, CLASS_PREFIX + STATIC_DB_DEPTH);
    when(mFeatureFactory.dashboardFeatureProvider.getAllCategories()).thenReturn(Arrays.asList(category));
    final List<String> breadcrumb = mSiteMapManager.buildBreadCrumb(mContext, CLASS_PREFIX + 0, TITLE_PREFIX + 0);
    assertThat(breadcrumb.size()).isEqualTo(STATIC_DB_DEPTH + 2);
    assertThat(breadcrumb.get(0)).isEqualTo(iaTitle);
}
Also used : ContentValues(android.content.ContentValues) DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Bundle(android.os.Bundle) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 50 with Tile

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

the class SecurityFeatureProviderImplTest method updateTilesData_shouldNotProcessNonMatchingPreference.

@Test
public void updateTilesData_shouldNotProcessNonMatchingPreference() {
    DashboardCategory dashboardCategory = new DashboardCategory();
    dashboardCategory.addTile(new Tile());
    mImpl.updatePreferencesToRunOnWorkerThread(mContext, getPreferenceScreen(), dashboardCategory);
    ShadowLooper.runUiThreadTasks();
    verifyNoMoreInteractions(mPackageManager);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

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