Merge "Only add icons to settings items with icons" into oc-dev am: ec00573139
am: ab13b378c9
Change-Id: I7194c8f3a1e17cc7b44548f97b0eabb51d4f6616
This commit is contained in:
@@ -99,6 +99,7 @@ public class DatabaseIndexingManagerTest {
|
||||
private final String screenTitle = "screen title";
|
||||
private final String className = "class name";
|
||||
private final int iconResId = 0xff;
|
||||
private final int noIcon = 0;
|
||||
private final String action = "action";
|
||||
private final String targetPackage = "target package";
|
||||
private final String targetClass = "target class";
|
||||
@@ -394,7 +395,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Class Name
|
||||
assertThat(cursor.getString(11)).isEqualTo(className);
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isEqualTo(iconResId);
|
||||
assertThat(cursor.getInt(12)).isEqualTo(noIcon);
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isEqualTo(action);
|
||||
// Target Package
|
||||
@@ -451,7 +452,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Class Name
|
||||
assertThat(cursor.getString(11)).isEqualTo(className);
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isEqualTo(iconResId);
|
||||
assertThat(cursor.getInt(12)).isEqualTo(noIcon);
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isEqualTo(action);
|
||||
// Target Package
|
||||
@@ -508,7 +509,7 @@ public class DatabaseIndexingManagerTest {
|
||||
// Class Name
|
||||
assertThat(cursor.getString(11)).isEqualTo(className);
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isEqualTo(iconResId);
|
||||
assertThat(cursor.getInt(12)).isEqualTo(noIcon);
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isEqualTo(action);
|
||||
// Target Package
|
||||
@@ -530,6 +531,18 @@ public class DatabaseIndexingManagerTest {
|
||||
assertThat(unmarshalledPayload).isInstanceOf(ResultPayload.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddResource_iconAddedFromXml() {
|
||||
SearchIndexableResource resource = getFakeResource(R.xml.connected_devices);
|
||||
mManager.indexOneSearchIndexableData(mDb, localeStr, resource, new HashMap<>());
|
||||
|
||||
Cursor cursor = mDb.rawQuery("SELECT * FROM prefs_index ORDER BY data_title", null);
|
||||
cursor.moveToPosition(0);
|
||||
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isNotEqualTo(noIcon);
|
||||
}
|
||||
|
||||
// Tests for the flow: IndexOneResource -> IndexFromProvider -> IndexFromResource ->
|
||||
// UpdateOneRowWithFilteredData -> UpdateOneRow
|
||||
|
||||
@@ -580,7 +593,7 @@ public class DatabaseIndexingManagerTest {
|
||||
assertThat(cursor.getString(11))
|
||||
.isEqualTo("com.android.settings.display.ScreenZoomSettings");
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isEqualTo(iconResId);
|
||||
assertThat(cursor.getInt(12)).isEqualTo(noIcon);
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isNull();
|
||||
// Target Package
|
||||
@@ -648,7 +661,7 @@ public class DatabaseIndexingManagerTest {
|
||||
assertThat(cursor.getString(11))
|
||||
.isEqualTo("com.android.settings.display.ScreenZoomSettings");
|
||||
// Icon
|
||||
assertThat(cursor.getInt(12)).isEqualTo(iconResId);
|
||||
assertThat(cursor.getInt(12)).isEqualTo(noIcon);
|
||||
// Intent Action
|
||||
assertThat(cursor.getString(13)).isNull();
|
||||
// Target Package
|
||||
|
@@ -78,7 +78,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();
|
||||
@@ -86,8 +86,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();
|
||||
|
||||
@@ -105,6 +105,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()
|
||||
@@ -151,15 +159,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 ResultPayload(
|
||||
new Intent().setComponent(new ComponentName("pkg", "class"))))
|
||||
.addBreadcrumbs(new ArrayList<>())
|
||||
.addIcon(mIcon);
|
||||
.addIcon(icon);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
Reference in New Issue
Block a user