### Question:
SubheaderListItem extends ListItem<SubheaderListItem.ViewHolder> { public void setTextStartMarginType(@TextStartMarginType int type) { mTextStartMarginType = type; markDirty(); } SubheaderListItem(Context context, String text); static ViewHolder createViewHolder(View itemView); void setTextStartMarginType(@TextStartMarginType int type); void setText(String text); @Override int getViewType(); static final int TEXT_START_MARGIN_TYPE_NONE; static final int TEXT_START_MARGIN_TYPE_SMALL; static final int TEXT_START_MARGIN_TYPE_LARGE; }### Answer:
@Test public void testEmptyStartMargin() { SubheaderListItem subheader = new SubheaderListItem(mActivity, "text"); subheader.setTextStartMarginType(SubheaderListItem.TEXT_START_MARGIN_TYPE_NONE); TextListItem item = new TextListItem(mActivity); item.setTitle("title"); item.setPrimaryActionNoIcon(); setupPagedListView(Arrays.asList(subheader, item)); assertThat(getViewHolderAtPosition(0).getText().getLeft(), is(equalTo(getTextViewHolderAtPosition(1).getTitle().getLeft()))); }
@Test public void testStartMarginMatchesSmallIcon() { SubheaderListItem subheader = new SubheaderListItem(mActivity, "text"); subheader.setTextStartMarginType(SubheaderListItem.TEXT_START_MARGIN_TYPE_SMALL); TextListItem item = new TextListItem(mActivity); item.setTitle("title"); item.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false); setupPagedListView(Arrays.asList(subheader, item)); assertThat(getViewHolderAtPosition(0).getText().getLeft(), is(equalTo(getTextViewHolderAtPosition(1).getTitle().getLeft()))); }
@Test public void testStartMarginMatchesLargeIcon() { SubheaderListItem subheader = new SubheaderListItem(mActivity, "text"); subheader.setTextStartMarginType(SubheaderListItem.TEXT_START_MARGIN_TYPE_LARGE); TextListItem item = new TextListItem(mActivity); item.setTitle("title"); item.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, true); setupPagedListView(Arrays.asList(subheader, item)); assertThat(getViewHolderAtPosition(0).getText().getLeft(), is(equalTo(getTextViewHolderAtPosition(1).getTitle().getLeft()))); }