Add PrefController in XML support
Add the ability to define a Preference Controller in xml using the 'controller' tag. This is useful for two reasons: - It allows the controllers to be instantiated via reflection for Slices and Dashboard fragment - Removes the requirement that controllers be defined manually in Fragments In order to be instantiable, they must have a unified construction following either: ClassName(Context) ClassName(Context, String) Also added a robotest that verifies that all controllers defined in XML follow the constructor schema, and extend BasePreferenceController. Test: robotests Bug: 67996923 Change-Id: I304b35dc666daebecf0c9e286696f3f2a510704a
This commit is contained in:
@@ -128,6 +128,16 @@ public class XmlParserUtilTest {
|
||||
assertThat(key).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void testControllerAttribute_returnsValidData() {
|
||||
XmlResourceParser parser = getChildByType(R.xml.about_legal, "Preference");
|
||||
final AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||
|
||||
String controller = XmlParserUtils.getController(mContext, attrs);
|
||||
assertThat(controller).isEqualTo("mind_flayer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataSummaryInvalid_ReturnsNull() {
|
||||
XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings);
|
||||
|
||||
Reference in New Issue
Block a user