Only add icons to settings items with icons

Currently the icon for the category of setting is used for
each setting result. Change it to only add an icon when
it exists in xml.

Bug: 37858983
Test: make RunSettingsRoboTests
Change-Id: Ib95e76c5a9ba2e73738cea716d72c5994a6aa0ba
This commit is contained in:
Matthew Fritze
2017-05-02 18:43:31 -07:00
parent 8fc602fed8
commit 5416a5992b
5 changed files with 51 additions and 34 deletions

View File

@@ -82,7 +82,7 @@ public class IntentSearchViewHolderTest {
}
@Test
public void testConstructor_MembersNotNull() {
public void testConstructor_membersNotNull() {
assertThat(mHolder.titleView).isNotNull();
assertThat(mHolder.summaryView).isNotNull();
assertThat(mHolder.iconView).isNotNull();
@@ -90,8 +90,8 @@ public class IntentSearchViewHolderTest {
}
@Test
public void testBindViewElements_AllUpdated() {
SearchResult result = getSearchResult();
public void testBindViewElements_allUpdated() {
SearchResult result = getSearchResult(TITLE, SUMMARY, mIcon);
mHolder.onBind(mFragment, result);
mHolder.itemView.performClick();
@@ -109,6 +109,14 @@ public class IntentSearchViewHolderTest {
any(Pair.class));
}
@Test
public void testBindViewIcon_nullIcon_imageDrawableIsNull() {
final SearchResult result = getSearchResult(TITLE, SUMMARY, null);
mHolder.onBind(mFragment, result);
assertThat(mHolder.iconView.getDrawable()).isNull();
}
@Test
public void testBindViewElements_emptySummary_hideSummaryView() {
final SearchResult result = new Builder()
@@ -155,15 +163,15 @@ public class IntentSearchViewHolderTest {
assertThat(mHolder.summaryView.getVisibility()).isEqualTo(View.GONE);
}
private SearchResult getSearchResult() {
private SearchResult getSearchResult(String title, String summary, Drawable icon) {
Builder builder = new Builder();
builder.addTitle(TITLE)
.addSummary(SUMMARY)
builder.addTitle(title)
.addSummary(summary)
.addRank(1)
.addPayload(new IntentPayload(
new Intent().setComponent(new ComponentName("pkg", "class"))))
.addBreadcrumbs(new ArrayList<>())
.addIcon(mIcon);
.addIcon(icon);
return builder.build();
}