Search in sources :

Example 6 with DashboardCategory

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
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ArrayList(java.util.ArrayList) SuggestionAdapter(com.android.settings.dashboard.suggestions.SuggestionAdapter) 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 7 with DashboardCategory

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));
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Bundle(android.os.Bundle) Test(org.junit.Test)

Example 8 with DashboardCategory

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();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Test(org.junit.Test)

Example 9 with DashboardCategory

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();
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Context(android.content.Context) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 10 with DashboardCategory

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);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

DashboardCategory (com.android.settingslib.drawer.DashboardCategory)449 Tile (com.android.settingslib.drawer.Tile)302 Test (org.junit.Test)225 ProviderTile (com.android.settingslib.drawer.ProviderTile)184 ActivityTile (com.android.settingslib.drawer.ActivityTile)179 Bundle (android.os.Bundle)77 ArrayList (java.util.ArrayList)71 VisibleForTesting (androidx.annotation.VisibleForTesting)52 ActivityInfo (android.content.pm.ActivityInfo)41 Intent (android.content.Intent)32 ComponentName (android.content.ComponentName)31 Context (android.content.Context)31 Before (org.junit.Before)30 Activity (android.app.Activity)27 View (android.view.View)27 PreferenceScreen (android.support.v7.preference.PreferenceScreen)26 List (java.util.List)26 ProviderInfo (android.content.pm.ProviderInfo)23 HashMap (java.util.HashMap)20 TestConfig (com.android.settings.TestConfig)18