Unverified Commit 64f7bf7e authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Add ListTile debugFillProperties (#100765)

parent c7d29350
......@@ -798,6 +798,39 @@ class ListTile extends StatelessWidget {
),
);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Widget>('leading', leading, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('title', title, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('subtitle', subtitle, defaultValue: null));
properties.add(DiagnosticsProperty<Widget>('trailing', trailing, defaultValue: null));
properties.add(FlagProperty('isThreeLine', value: isThreeLine, ifTrue:'THREE_LINE', ifFalse: 'TWO_LINE', showName: true, defaultValue: false));
properties.add(FlagProperty('dense', value: dense, ifTrue: 'true', ifFalse: 'false', showName: true));
properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: null));
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
properties.add(DiagnosticsProperty<ListTileStyle>('style', style, defaultValue: null));
properties.add(ColorProperty('selectedColor', selectedColor, defaultValue: null));
properties.add(ColorProperty('iconColor', iconColor, defaultValue: null));
properties.add(ColorProperty('textColor', textColor, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('contentPadding', contentPadding, defaultValue: null));
properties.add(FlagProperty('enabled', value: enabled, ifTrue: 'true', ifFalse: 'false', showName: true, defaultValue: true));
properties.add(DiagnosticsProperty<Function>('onTap', onTap, defaultValue: null));
properties.add(DiagnosticsProperty<Function>('onLongPress', onLongPress, defaultValue: null));
properties.add(DiagnosticsProperty<MouseCursor>('mouseCursor', mouseCursor, defaultValue: null));
properties.add(FlagProperty('selected', value: selected, ifTrue: 'true', ifFalse: 'false', showName: true, defaultValue: false));
properties.add(ColorProperty('focusColor', focusColor, defaultValue: null));
properties.add(ColorProperty('hoverColor', hoverColor, defaultValue: null));
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
properties.add(FlagProperty('autofocus', value: autofocus, ifTrue: 'true', ifFalse: 'false', showName: true, defaultValue: false));
properties.add(ColorProperty('tileColor', tileColor, defaultValue: null));
properties.add(ColorProperty('selectedTileColor', selectedTileColor, defaultValue: null));
properties.add(FlagProperty('enableFeedback', value: enableFeedback, ifTrue: 'true', ifFalse: 'false', showName: true));
properties.add(DoubleProperty('horizontalTitleGap', horizontalTitleGap, defaultValue: null));
properties.add(DoubleProperty('minVerticalPadding', minVerticalPadding, defaultValue: null));
properties.add(DoubleProperty('minLeadingWidth', minLeadingWidth, defaultValue: null));
}
}
// Identifies the children of a _ListTileElement.
......
......@@ -2228,6 +2228,78 @@ void main() {
trailing = _getTextRenderObject(tester, 'trailing');
expect(trailing.text.style!.color, theme.textTheme.bodyText2!.color);
});
testWidgets('Default ListTile debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ListTile().debugFillProperties(builder);
final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description, <String>[]);
});
testWidgets('ListTile implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ListTile(
leading: Text('leading'),
title: Text('title'),
subtitle: Text('trailing'),
trailing: Text('trailing'),
isThreeLine: true,
dense: true,
visualDensity: VisualDensity.standard,
shape: RoundedRectangleBorder(),
style: ListTileStyle.list,
selectedColor: Color(0xff0000ff),
iconColor: Color(0xff00ff00),
textColor: Color(0xffff0000),
contentPadding: EdgeInsets.zero,
enabled: false,
selected: true,
focusColor: Color(0xff00ffff),
hoverColor: Color(0xff0000ff),
autofocus: true,
tileColor: Color(0xffffff00),
selectedTileColor: Color(0xff123456),
enableFeedback: false,
horizontalTitleGap: 4.0,
minVerticalPadding: 2.0,
minLeadingWidth: 6.0,
).debugFillProperties(builder);
final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description[0], 'leading: Text');
expect(description[1], 'title: Text');
expect(description[2], 'subtitle: Text');
expect(description[3], 'trailing: Text');
expect(description[4], 'isThreeLine: THREE_LINE');
expect(description[5], 'dense: true');
expect(description[6], equalsIgnoringHashCodes('visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)'));
expect(description[7], 'shape: RoundedRectangleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none), BorderRadius.zero)');
expect(description[8], 'style: ListTileStyle.list');
expect(description[9], 'selectedColor: Color(0xff0000ff)');
expect(description[10], 'iconColor: Color(0xff00ff00)');
expect(description[11], 'textColor: Color(0xffff0000)');
expect(description[12], 'contentPadding: EdgeInsets.zero');
expect(description[13], 'enabled: false');
expect(description[14], 'selected: true');
expect(description[15], 'focusColor: Color(0xff00ffff)');
expect(description[16], 'hoverColor: Color(0xff0000ff)');
expect(description[17], 'autofocus: true');
expect(description[18], 'tileColor: Color(0xffffff00)');
expect(description[19], 'selectedTileColor: Color(0xff123456)');
expect(description[20], 'enableFeedback: false');
expect(description[21], 'horizontalTitleGap: 4.0');
expect(description[22], 'minVerticalPadding: 2.0');
expect(description[23], 'minLeadingWidth: 6.0');
});
}
RenderParagraph _getTextRenderObject(WidgetTester tester, String text) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment