Merge "Support suggestion UI card with a button."

This commit is contained in:
TreeHugger Robot
2017-10-06 03:46:21 +00:00
committed by Android (Google) Code Review
9 changed files with 135 additions and 39 deletions

View File

@@ -143,6 +143,21 @@ public class SuggestionAdapterTest {
.isEqualTo(R.layout.suggestion_tile);
}
@Test
public void getItemType_hasButton_shouldReturnSuggestionWithButton() {
final List<Suggestion> suggestions = new ArrayList<>();
suggestions.add(new Suggestion.Builder("id")
.setFlags(Suggestion.FLAG_HAS_BUTTON)
.setTitle("123")
.setSummary("456")
.build());
mSuggestionAdapter = new SuggestionAdapter(mContext, null /* suggestions */,
suggestions, new ArrayList<>());
assertThat(mSuggestionAdapter.getItemViewType(0))
.isEqualTo(R.layout.suggestion_tile_with_button);
}
@Test
public void onBindViewHolder_shouldSetListener() {
final View view = spy(LayoutInflater.from(mContext).inflate(

View File

@@ -92,7 +92,7 @@ public class SuggestionDismissControllerTest {
@Test
public void getSwipeDirs_isSuggestionTileCard_shouldReturnDirection() {
final RecyclerView.ViewHolder vh = mock(RecyclerView.ViewHolder.class);
when(vh.getItemViewType()).thenReturn(R.layout.suggestion_tile_remote_container);
when(vh.getItemViewType()).thenReturn(R.layout.suggestion_tile_with_button);
assertThat(mController.getSwipeDirs(mRecyclerView, vh))
.isEqualTo(ItemTouchHelper.START | ItemTouchHelper.END);