Search in sources :

Example 16 with DashboardCategory

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

the class SecurityFeatureProviderImplTest method updateTilesData_shouldNotUpdateAlreadyUpdatedPreference.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void updateTilesData_shouldNotUpdateAlreadyUpdatedPreference() {
    Bundle bundle = new Bundle();
    bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
    bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
    PreferenceScreen screen = getPreferenceScreen();
    when(screen.findPreference(MOCK_KEY).getSummary()).thenReturn(MOCK_SUMMARY);
    when(screen.findPreference(MOCK_KEY).getIcon()).thenReturn(mMockDrawable);
    DashboardCategory dashboardCategory = getDashboardCategory();
    dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
    dashboardCategory.getTile(0).metaData = bundle;
    mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
    ShadowLooper.runUiThreadTasks();
    verify(screen.findPreference(MOCK_KEY), never()).setSummary(anyString());
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

Example 17 with DashboardCategory

use of com.android.settingslib.drawer.DashboardCategory 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)

Example 18 with DashboardCategory

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

the class SecurityFeatureProviderImplTest method updateTilesData_shouldUpdateMatchingPreference.

@Test
@Config(shadows = { ShadowTileUtils.class })
public void updateTilesData_shouldUpdateMatchingPreference() {
    Bundle bundle = new Bundle();
    bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
    bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
    PreferenceScreen screen = getPreferenceScreen();
    DashboardCategory dashboardCategory = getDashboardCategory();
    dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
    dashboardCategory.getTile(0).metaData = bundle;
    mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
    ShadowLooper.runUiThreadTasks();
    verify(screen.findPreference(MOCK_KEY)).setIcon(mMockDrawable);
    verify(screen.findPreference(MOCK_KEY)).setSummary(MOCK_SUMMARY);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test) Config(org.robolectric.annotation.Config) TestConfig(com.android.settings.TestConfig)

Example 19 with DashboardCategory

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

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 20 with DashboardCategory

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

the class DashboardSummary method updateCategoryAndSuggestion.

@VisibleForTesting
void updateCategoryAndSuggestion(List<Tile> suggestions) {
    final Activity activity = getActivity();
    if (activity == null) {
        return;
    }
    final DashboardCategory category = mDashboardFeatureProvider.getTilesForCategory(CategoryKey.CATEGORY_HOMEPAGE);
    mSummaryLoader.updateSummaryToCache(category);
    if (suggestions != null) {
        mAdapter.setCategoriesAndSuggestions(category, suggestions);
    } else {
        mAdapter.setCategory(category);
    }
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) SettingsActivity(com.android.settings.SettingsActivity) SettingsDrawerActivity(com.android.settingslib.drawer.SettingsDrawerActivity) Activity(android.app.Activity) VisibleForTesting(android.support.annotation.VisibleForTesting)

Aggregations

DashboardCategory (com.android.settingslib.drawer.DashboardCategory)449 Tile (com.android.settingslib.drawer.Tile)303 Test (org.junit.Test)225 ProviderTile (com.android.settingslib.drawer.ProviderTile)185 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