Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39fe5308 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Set categories to the adapter if suggestion is not available."

parents da562832 845e2135
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ public class DashboardSummary extends InstrumentedFragment
        mSummaryLoader.updateSummaryToCache(category);
        mStagingCategory = category;
        if (mSuggestionControllerMixin == null) {
            mAdapter.setCategory(mStagingCategory);
            return;
        }
        if (mSuggestionControllerMixin.isSuggestionLoaded()) {
+21 −0
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ public class DashboardSummaryTest {
    private ConditionManager mConditionManager;
    @Mock
    private SummaryLoader mSummaryLoader;
    @Mock
    private SuggestionControllerMixin mSuggestionControllerMixin;

    private Context mContext;
    private DashboardSummary mSummary;
@@ -111,12 +113,31 @@ public class DashboardSummaryTest {

    @Test
    public void updateCategory_shouldGetCategoryFromFeatureProvider() {
        ReflectionHelpers.setField(mSummary, "mSuggestionControllerMixin",
                mSuggestionControllerMixin);

        when(mSuggestionControllerMixin.isSuggestionLoaded()).thenReturn(true);
        doReturn(mock(Activity.class)).when(mSummary).getActivity();
        mSummary.onAttach(mContext);
        mSummary.updateCategory();

        verify(mSummaryLoader).updateSummaryToCache(nullable(DashboardCategory.class));
        verify(mDashboardFeatureProvider).getTilesForCategory(CategoryKey.CATEGORY_HOMEPAGE);
        verify(mAdapter).setCategory(any());
    }

    @Test
    public void updateCategory_shouldGetCategoryFromFeatureProvider_evenIfSuggestionDisabled() {
        when(mFeatureFactory.suggestionsFeatureProvider.isSuggestionEnabled(any(Context.class)))
                .thenReturn(false);

        doReturn(mock(Activity.class)).when(mSummary).getActivity();
        mSummary.onAttach(mContext);
        mSummary.updateCategory();

        verify(mSummaryLoader).updateSummaryToCache(nullable(DashboardCategory.class));
        verify(mDashboardFeatureProvider).getTilesForCategory(CategoryKey.CATEGORY_HOMEPAGE);
        verify(mAdapter).setCategory(any());
    }

    @Test