Search in sources :

Example 71 with Tile

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

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

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

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)

Example 73 with Tile

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

the class DashboardAdapterTest method testSetCategories_iconTinted.

@Test
public void testSetCategories_iconTinted() {
    TypedArray mockTypedArray = mock(TypedArray.class);
    doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
    doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
    final DashboardCategory category = mock(DashboardCategory.class);
    final List<Tile> tiles = new ArrayList<>();
    final Icon mockIcon = mock(Icon.class);
    final Tile tile = new Tile();
    tile.isIconTintable = true;
    tile.icon = mockIcon;
    tiles.add(tile);
    category.tiles = tiles;
    mDashboardAdapter.setCategory(category);
    verify(mockIcon).setTint(eq(0x89000000));
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) TypedArray(android.content.res.TypedArray) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Icon(android.graphics.drawable.Icon) Test(org.junit.Test)

Example 74 with Tile

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

the class DashboardAdapterTest method testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly.

@Test
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
    final DashboardAdapter adapter = spy(new DashboardAdapter(mContext, null, null, null, null));
    final List<Tile> suggestions = makeSuggestions("pkg1", "pkg2", "pkg3");
    adapter.setCategoriesAndSuggestions(null, /* category */
    suggestions);
    final RecyclerView data = mock(RecyclerView.class);
    when(data.getResources()).thenReturn(mResources);
    when(data.getContext()).thenReturn(mContext);
    when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
    final View itemView = mock(View.class);
    when(itemView.findViewById(R.id.data)).thenReturn(data);
    final DashboardAdapter.SuggestionAndConditionContainerHolder holder = new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
    adapter.onBindConditionAndSuggestion(holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
    final DashboardData dashboardData = adapter.mDashboardData;
    // clear interactions tracking
    reset(adapter);
    final Tile suggestionToRemove = suggestions.get(1);
    adapter.onSuggestionDismissed(suggestionToRemove);
    assertThat(adapter.mDashboardData).isEqualTo(dashboardData);
    assertThat(suggestions.size()).isEqualTo(2);
    assertThat(suggestions.contains(suggestionToRemove)).isFalse();
    verify(adapter, never()).notifyDashboardDataChanged(any());
}
Also used : Tile(com.android.settingslib.drawer.Tile) RecyclerView(android.support.v7.widget.RecyclerView) DisplayMetrics(android.util.DisplayMetrics) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Test(org.junit.Test)

Example 75 with Tile

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

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)

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