### Question:
TextListItem extends ListItem<TextListItem.ViewHolder> { public void setPrimaryActionIcon(@DrawableRes int iconResId, boolean useLargeIcon) { setPrimaryActionIcon(mContext.getDrawable(iconResId), useLargeIcon); } TextListItem(Context context); static ViewHolder createViewHolder(View itemView); @Override int getViewType(); @Override void onBind(ViewHolder viewHolder); void setOnClickListener(View.OnClickListener listener); void setPrimaryActionIcon(@DrawableRes int iconResId, boolean useLargeIcon); void setPrimaryActionIcon(Drawable drawable, boolean useLargeIcon); void setPrimaryActionEmptyIcon(); void setPrimaryActionNoIcon(); void setTitle(String title); void setBody(String body); void setBody(String body, boolean asPrimary); void setSupplementalIcon(int iconResId, boolean showDivider); void setSupplementalIcon(Drawable drawable, boolean showDivider); void setSupplementalIcon(int iconResId, boolean showDivider,
            View.OnClickListener listener); void setSupplementalIcon(Drawable drawable, boolean showDivider,
            View.OnClickListener listener); void setAction(String text, boolean showDivider, View.OnClickListener listener); void setActions(String action1Text, boolean showAction1Divider,
            View.OnClickListener action1OnClickListener,
            String action2Text, boolean showAction2Divider,
            View.OnClickListener action2OnClickListener); void setSwitch(boolean checked, boolean showDivider,
            CompoundButton.OnCheckedChangeListener listener); void setSwitchState(boolean isChecked);  }### Answer:
@Test public void testPrimaryActionVisible() { TextListItem item0 = new TextListItem(mActivity); item0.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, true); TextListItem item1 = new TextListItem(mActivity); item1.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false); List<TextListItem> items = Arrays.asList(item0, item1); setupPagedListView(items); assertThat(getViewHolderAtPosition(0).getPrimaryIcon().getVisibility(), is(equalTo(View.VISIBLE))); assertThat(getViewHolderAtPosition(1).getPrimaryIcon().getVisibility(), is(equalTo(View.VISIBLE))); }
@Test public void testPrimaryIconDrawable() { Drawable drawable = InstrumentationRegistry.getContext().getResources().getDrawable( android.R.drawable.sym_def_app_icon, null); TextListItem item0 = new TextListItem(mActivity); item0.setPrimaryActionIcon(drawable, true); List<TextListItem> items = Arrays.asList(item0); setupPagedListView(items); assertTrue(getViewHolderAtPosition(0).getPrimaryIcon().getDrawable().getConstantState() .equals(drawable.getConstantState())); }
@Test public void testLargePrimaryIconHasNoStartMargin() { TextListItem item0 = new TextListItem(mActivity); item0.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, true); List<TextListItem> items = Arrays.asList(item0); setupPagedListView(items); TextListItem.ViewHolder viewHolder = getViewHolderAtPosition(0); assertThat(((ViewGroup.MarginLayoutParams) viewHolder.getPrimaryIcon().getLayoutParams()) .getMarginStart(), is(equalTo(0))); }
@Test public void testSmallPrimaryIconStartMargin() { TextListItem item0 = new TextListItem(mActivity); item0.setPrimaryActionIcon(android.R.drawable.sym_def_app_icon, false); List<TextListItem> items = Arrays.asList(item0); setupPagedListView(items); int expected = InstrumentationRegistry.getContext().getResources().getDimensionPixelSize( R.dimen.car_keyline_1); TextListItem.ViewHolder viewHolder = getViewHolderAtPosition(0); assertThat(((ViewGroup.MarginLayoutParams) viewHolder.getPrimaryIcon().getLayoutParams()) .getMarginStart(), is(equalTo(expected))); }