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

Commit ac3b3293 authored by Fan Zhang's avatar Fan Zhang Committed by Android (Google) Code Review
Browse files

Merge "Fix a memory leak caused by dashboard freature provider."

parents 27ffe047 d69b443e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -51,13 +51,13 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
    private final CategoryManager mCategoryManager;

    public DashboardFeatureProviderImpl(Context context) {
        mContext = context;
        mContext = context.getApplicationContext();
        mCategoryManager = CategoryManager.get(context, getExtraIntentAction());
    }

    @VisibleForTesting
    DashboardFeatureProviderImpl(Context context, CategoryManager categoryManager) {
        mContext = context;
        mContext = context.getApplicationContext();
        mCategoryManager = categoryManager;
    }

+10 −2
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import org.robolectric.shadows.ShadowApplication;
import java.util.ArrayList;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@@ -74,6 +76,11 @@ public class DashboardFeatureProviderImplTest {
        mImpl = new DashboardFeatureProviderImpl(mActivity);
    }

    @Test
    public void shouldHoldAppContext() {
        assertThat(mImpl.mContext).isEqualTo(mActivity.getApplicationContext());
    }

    @Test
    public void bindPreference_shouldBindAllData() {
        final Preference preference = new Preference(
@@ -234,7 +241,8 @@ public class DashboardFeatureProviderImplTest {
        when(mSpy.isEnabled()).thenReturn(true);
        final DashboardCategory category = new DashboardCategory();
        category.tiles.add(new Tile());
        when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
        when(mCategoryManager
                .getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
                .thenReturn(category);

        assertThat(mSpy.getPreferencesForCategory(mActivity,