Fix a NPE from incorrect assumption of operation pecedence.
Change-Id: I13d01c39bd3afcfbc7b680b96e0c7eb341fbc584 Fixes: 123709444 Test: robotest
This commit is contained in:
@@ -128,8 +128,10 @@ public class LegacySuggestionContextualCardController implements ContextualCardC
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
|
final List<Suggestion> suggestions = mSuggestionController.getSuggestions();
|
||||||
Log.d(TAG, "Loaded suggests: "
|
final String suggestionCount = suggestions == null
|
||||||
+ suggestions == null ? "null" : String.valueOf(suggestions.size()));
|
? "null"
|
||||||
|
: String.valueOf(suggestions.size());
|
||||||
|
Log.d(TAG, "Loaded suggests: " + suggestionCount);
|
||||||
|
|
||||||
final List<ContextualCard> cards = new ArrayList<>();
|
final List<ContextualCard> cards = new ArrayList<>();
|
||||||
if (suggestions != null) {
|
if (suggestions != null) {
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.homepage.contextualcards.legacysuggestion;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@@ -84,8 +85,10 @@ public class LegacySuggestionContextualCardControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onServiceConnected_shouldLoadSuggestion() {
|
public void onServiceConnected_shouldLoadSuggestion() {
|
||||||
|
when(mSuggestionController.getSuggestions()).thenReturn(null);
|
||||||
mController.mSuggestionController = mSuggestionController;
|
mController.mSuggestionController = mSuggestionController;
|
||||||
mController.setCardUpdateListener(mCardUpdateListener);
|
mController.setCardUpdateListener(mCardUpdateListener);
|
||||||
|
|
||||||
mController.onServiceConnected();
|
mController.onServiceConnected();
|
||||||
|
|
||||||
verify(mSuggestionController).getSuggestions();
|
verify(mSuggestionController).getSuggestions();
|
||||||
|
Reference in New Issue
Block a user