Merge "Fix layout height for suggestion tile." into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-08 05:32:25 +00:00
committed by Android (Google) Code Review
4 changed files with 34 additions and 4 deletions

View File

@@ -231,12 +231,40 @@ public class SuggestionAdapterTest {
}
@Test
public void onBindViewHolder_shouldTintIcon() throws PendingIntent.CanceledException {
public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
throws PendingIntent.CanceledException {
final Icon icon = mock(Icon.class);
final Suggestion suggestion = new Suggestion.Builder("pkg1")
.setPendingIntent(mock(PendingIntent.class))
.setIcon(icon)
.build();
final List<Suggestion> suggestions = new ArrayList<>();
suggestions.add(suggestion);
mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin,
null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
mSuggestionAdapter.setSuggestions(suggestions);
mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
new FrameLayout(RuntimeEnvironment.application),
mSuggestionAdapter.getItemViewType(0));
IconCache cache = mock(IconCache.class);
final Drawable drawable = mock(Drawable.class);
when(cache.getIcon(icon)).thenReturn(drawable);
ReflectionHelpers.setField(mSuggestionAdapter, "mCache", cache);
mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
verify(drawable, never()).setTint(anyInt());
}
@Test
public void onBindViewHolder_iconTintable_shouldTintIcon()
throws PendingIntent.CanceledException {
final Icon icon = mock(Icon.class);
final int FLAG_ICON_TINTABLE = 1 << 1;
final Suggestion suggestion = new Suggestion.Builder("pkg1")
.setPendingIntent(mock(PendingIntent.class))
.setIcon(icon)
.setFlags(FLAG_ICON_TINTABLE)
.build();
final List<Suggestion> suggestions = new ArrayList<>();
suggestions.add(suggestion);