Merge "Fix a memory leak caused by dashboard freature provider."
This commit is contained in:
@@ -51,13 +51,13 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
private final CategoryManager mCategoryManager;
|
private final CategoryManager mCategoryManager;
|
||||||
|
|
||||||
public DashboardFeatureProviderImpl(Context context) {
|
public DashboardFeatureProviderImpl(Context context) {
|
||||||
mContext = context;
|
mContext = context.getApplicationContext();
|
||||||
mCategoryManager = CategoryManager.get(context, getExtraIntentAction());
|
mCategoryManager = CategoryManager.get(context, getExtraIntentAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
DashboardFeatureProviderImpl(Context context, CategoryManager categoryManager) {
|
DashboardFeatureProviderImpl(Context context, CategoryManager categoryManager) {
|
||||||
mContext = context;
|
mContext = context.getApplicationContext();
|
||||||
mCategoryManager = categoryManager;
|
mCategoryManager = categoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,6 +49,8 @@ import org.robolectric.shadows.ShadowApplication;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
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.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -74,6 +76,11 @@ public class DashboardFeatureProviderImplTest {
|
|||||||
mImpl = new DashboardFeatureProviderImpl(mActivity);
|
mImpl = new DashboardFeatureProviderImpl(mActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldHoldAppContext() {
|
||||||
|
assertThat(mImpl.mContext).isEqualTo(mActivity.getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindPreference_shouldBindAllData() {
|
public void bindPreference_shouldBindAllData() {
|
||||||
final Preference preference = new Preference(
|
final Preference preference = new Preference(
|
||||||
@@ -234,7 +241,8 @@ public class DashboardFeatureProviderImplTest {
|
|||||||
when(mSpy.isEnabled()).thenReturn(true);
|
when(mSpy.isEnabled()).thenReturn(true);
|
||||||
final DashboardCategory category = new DashboardCategory();
|
final DashboardCategory category = new DashboardCategory();
|
||||||
category.tiles.add(new Tile());
|
category.tiles.add(new Tile());
|
||||||
when(mCategoryManager.getTilesByCategory(mActivity, CategoryKey.CATEGORY_HOMEPAGE))
|
when(mCategoryManager
|
||||||
|
.getTilesByCategory(any(Context.class), eq(CategoryKey.CATEGORY_HOMEPAGE)))
|
||||||
.thenReturn(category);
|
.thenReturn(category);
|
||||||
|
|
||||||
assertThat(mSpy.getPreferencesForCategory(mActivity,
|
assertThat(mSpy.getPreferencesForCategory(mActivity,
|
||||||
|
Reference in New Issue
Block a user