Merge "Fix null pointer on dismissing suggestion."
This commit is contained in:
@@ -83,7 +83,8 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
|
||||
@Override
|
||||
public String getSuggestionIdentifier(Context context, Tile suggestion) {
|
||||
if (suggestion.intent == null || suggestion.intent.getComponent() == null) {
|
||||
if (suggestion.intent == null || suggestion.intent.getComponent() == null
|
||||
|| context == null) {
|
||||
return "unknown_suggestion";
|
||||
}
|
||||
String packageName = suggestion.intent.getComponent().getPackageName();
|
||||
|
@@ -107,6 +107,15 @@ public class SuggestionFeatureProviderImplTest {
|
||||
.isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSuggestionIdentifier_nullContext_shouldNotCrash() {
|
||||
final Tile suggestion = new Tile();
|
||||
suggestion.intent = new Intent()
|
||||
.setClassName(RuntimeEnvironment.application.getPackageName(), "123");
|
||||
assertThat(mProvider.getSuggestionIdentifier(null, suggestion))
|
||||
.isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dismissSuggestion_hasMoreDismissCount_shouldNotDisableComponent() {
|
||||
when(mSuggestionParser.dismissSuggestion(any(Tile.class), anyBoolean()))
|
||||
@@ -120,7 +129,6 @@ public class SuggestionFeatureProviderImplTest {
|
||||
verify(mContext, never()).getPackageManager();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void dismissSuggestion_noContext_shouldDoNothing() {
|
||||
mProvider.dismissSuggestion(null, mSuggestionParser, mSuggestion);
|
||||
|
Reference in New Issue
Block a user