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);
}
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);
}
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));
}
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());
}
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));
}
Aggregations