Search in sources :

Example 11 with DashboardCategory

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

the class SummaryLoaderTest method SetUp.

@Before
public void SetUp() {
    MockitoAnnotations.initMocks(this);
    mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
    mTile = new Tile();
    mTile.summary = SUMMARY_1;
    mCallbackInvoked = false;
    final Activity activity = Robolectric.buildActivity(Activity.class).get();
    final List<DashboardCategory> categories = new ArrayList<>();
    mSummaryLoader = new SummaryLoader(activity, categories);
    mSummaryLoader.setSummaryConsumer(new SummaryLoader.SummaryConsumer() {

        @Override
        public void notifySummaryChanged(Tile tile) {
            mCallbackInvoked = true;
        }
    });
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Activity(android.app.Activity) Before(org.junit.Before)

Example 12 with DashboardCategory

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

the class SummaryLoaderTest method SetUp.

@Before
public void SetUp() {
    MockitoAnnotations.initMocks(this);
    mFeatureFactory = FakeFeatureFactory.setupForTest(mContext);
    mTile = new Tile();
    mTile.summary = SUMMARY_1;
    mCallbackInvoked = false;
    final Activity activity = Robolectric.buildActivity(Activity.class).get();
    final List<DashboardCategory> categories = new ArrayList<>();
    mSummaryLoader = new SummaryLoader(activity, categories);
    mSummaryLoader.setSummaryConsumer(new SummaryLoader.SummaryConsumer() {

        @Override
        public void notifySummaryChanged(Tile tile) {
            mCallbackInvoked = true;
        }
    });
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Activity(android.app.Activity) Before(org.junit.Before)

Example 13 with DashboardCategory

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

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)

Example 14 with DashboardCategory

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

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

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

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)

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