Move xmlParserUtils to core
This class is currently used by both search and slice, in the future will be used by DashboardFragment to build controller list. So the scope of this class is beyond search now. Test: rerun robotests Change-Id: If43ebca065aac31ad24f95a94bfe5be784109605
This commit is contained in:
@@ -26,6 +26,7 @@ import android.util.Xml;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.core.PreferenceXmlParserUtils;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -58,7 +59,7 @@ public class XmlParserUtilTest {
|
||||
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||
"com.android.settings.TimeoutListPreference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String title = XmlParserUtils.getDataTitle(mContext, attrs);
|
||||
String title = PreferenceXmlParserUtils.getDataTitle(mContext, attrs);
|
||||
String expTitle = mContext.getString(R.string.screen_timeout);
|
||||
assertThat(title).isEqualTo(expTitle);
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataKeywordsValid_ReturnsPreferenceKeywords() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String keywords = XmlParserUtils.getDataKeywords(mContext, attrs);
|
||||
String keywords = PreferenceXmlParserUtils.getDataKeywords(mContext, attrs);
|
||||
String expKeywords = mContext.getString(R.string.keywords_display);
|
||||
assertThat(keywords).isEqualTo(expKeywords);
|
||||
}
|
||||
@@ -77,7 +78,7 @@ public class XmlParserUtilTest {
|
||||
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||
"com.android.settings.TimeoutListPreference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
||||
String key = PreferenceXmlParserUtils.getDataKey(mContext, attrs);
|
||||
String expKey = "screen_timeout";
|
||||
assertThat(key).isEqualTo(expKey);
|
||||
}
|
||||
@@ -87,7 +88,7 @@ public class XmlParserUtilTest {
|
||||
XmlResourceParser parser = getChildByType(R.xml.display_settings,
|
||||
"com.android.settings.TimeoutListPreference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
||||
String summary = PreferenceXmlParserUtils.getDataSummary(mContext, attrs);
|
||||
String expSummary = mContext.getString(R.string.summary_placeholder);
|
||||
assertThat(summary).isEqualTo(expSummary);
|
||||
|
||||
@@ -99,9 +100,9 @@ public class XmlParserUtilTest {
|
||||
XmlResourceParser parser = getChildByType(R.xml.display_settings, "CheckBoxPreference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
assertThat(XmlParserUtils.getDataSummaryOn(mContext, attrs))
|
||||
assertThat(PreferenceXmlParserUtils.getDataSummaryOn(mContext, attrs))
|
||||
.isEqualTo("summary_on");
|
||||
assertThat(XmlParserUtils.getDataSummaryOff(mContext, attrs))
|
||||
assertThat(PreferenceXmlParserUtils.getDataSummaryOff(mContext, attrs))
|
||||
.isEqualTo("summary_off");
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataEntriesValid_ReturnsPreferenceEntries() {
|
||||
XmlResourceParser parser = getChildByType(R.xml.display_settings, "ListPreference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
|
||||
String entries = PreferenceXmlParserUtils.getDataEntries(mContext, attrs);
|
||||
String[] expEntries = mContext.getResources()
|
||||
.getStringArray(R.array.app_install_location_entries);
|
||||
for (int i = 0; i < expEntries.length; i++) {
|
||||
@@ -124,7 +125,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataKeyInvalid_ReturnsNull() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String key = XmlParserUtils.getDataKey(mContext, attrs);
|
||||
String key = PreferenceXmlParserUtils.getDataKey(mContext, attrs);
|
||||
assertThat(key).isNull();
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ public class XmlParserUtilTest {
|
||||
XmlResourceParser parser = getChildByType(R.xml.about_legal, "Preference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
String controller = XmlParserUtils.getController(mContext, attrs);
|
||||
String controller = PreferenceXmlParserUtils.getController(mContext, attrs);
|
||||
assertThat(controller).isEqualTo("mind_flayer");
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataSummaryInvalid_ReturnsNull() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String summary = XmlParserUtils.getDataSummary(mContext, attrs);
|
||||
String summary = PreferenceXmlParserUtils.getDataSummary(mContext, attrs);
|
||||
assertThat(summary).isNull();
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataSummaryOffInvalid_ReturnsNull() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String summaryOff = XmlParserUtils.getDataSummaryOff(mContext, attrs);
|
||||
String summaryOff = PreferenceXmlParserUtils.getDataSummaryOff(mContext, attrs);
|
||||
assertThat(summaryOff).isNull();
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ public class XmlParserUtilTest {
|
||||
public void testDataEntriesInvalid_ReturnsNull() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
String entries = XmlParserUtils.getDataEntries(mContext, attrs);
|
||||
String entries = PreferenceXmlParserUtils.getDataEntries(mContext, attrs);
|
||||
assertThat(entries).isNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user