use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class DashboardAdapterTest method testBindConditionAndSuggestion_shouldSetSuggestionAdapterAndNoCrash.
@Test
public void testBindConditionAndSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
mDashboardAdapter = new DashboardAdapter(mContext, null, null, null, null);
final List<Tile> suggestions = makeSuggestions("pkg1");
final DashboardCategory category = mock(DashboardCategory.class);
final List<Tile> tiles = new ArrayList<>();
tiles.add(mock(Tile.class));
category.tiles = tiles;
mDashboardAdapter.setCategoriesAndSuggestions(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);
mDashboardAdapter.onBindConditionAndSuggestion(holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
verify(data).setAdapter(any(SuggestionAdapter.class));
// should not crash
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class SecurityFeatureProviderImplTest method initPreferences_shouldLoadDefaults.
@Test
public void initPreferences_shouldLoadDefaults() {
PreferenceScreen screen = getPreferenceScreen();
DashboardCategory dashboardCategory = getDashboardCategory();
dashboardCategory.getTile(0).metaData = new Bundle();
mImpl.initPreferences(mContext, screen, dashboardCategory);
verify(screen.findPreference(MOCK_KEY)).setIcon(SecurityFeatureProviderImpl.DEFAULT_ICON);
verify(screen.findPreference(MOCK_KEY)).setSummary(mContext.getString(R.string.summary_placeholder));
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
the class DashboardFeatureProviderImplTest method getPreferences_noTileForCategory_shouldReturnNull.
@Test
public void getPreferences_noTileForCategory_shouldReturnNull() {
mImpl = new DashboardFeatureProviderImpl(mActivity);
ReflectionHelpers.setField(mImpl, "mCategoryManager", mCategoryManager);
when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE)).thenReturn(new DashboardCategory());
assertThat(mImpl.getPreferencesForCategory(null, null, MetricsProto.MetricsEvent.SETTINGS_GESTURES, CategoryKey.CATEGORY_HOMEPAGE)).isNull();
}
use of com.android.settingslib.drawer.DashboardCategory in project android_packages_apps_Settings by LineageOS.
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();
}
use of com.android.settingslib.drawer.DashboardCategory 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);
}
Aggregations