Merge "Fix null pointer exception when logging suggestions." into oc-mr1-dev
am: d94fbbc325
Change-Id: I4c827d601b8ed20934c4671d5a7de29a3001bd0b
This commit is contained in:
@@ -329,7 +329,11 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
|
||||
private void logSuggestions() {
|
||||
for (Tile suggestion : mDashboardData.getSuggestions()) {
|
||||
final List<Tile> suggestions = mDashboardData.getSuggestions();
|
||||
if (suggestions == null) {
|
||||
return;
|
||||
}
|
||||
for (Tile suggestion : suggestions) {
|
||||
final String suggestionId = mSuggestionFeatureProvider.getSuggestionIdentifier(
|
||||
mContext, suggestion);
|
||||
if (!mSuggestionsShownLogged.contains(suggestionId)) {
|
||||
|
@@ -318,6 +318,21 @@ public class DashboardAdapterTest {
|
||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_nullSuggestionsList_shouldNotCrash() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3", "pkg4", "pkg5"));
|
||||
mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
|
||||
|
||||
// set suggestions to null
|
||||
final DashboardData prevData = mDashboardAdapter.mDashboardData;
|
||||
mDashboardAdapter.mDashboardData = new DashboardData.Builder(prevData)
|
||||
.setSuggestions(null)
|
||||
.build();
|
||||
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
// no crash
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
|
||||
final DashboardAdapter adapter =
|
||||
|
Reference in New Issue
Block a user