Unverified Commit a9c28d5f authored by Slade Capasso's avatar Slade Capasso Committed by GitHub

range_slider_test.dart diagnostics property tests (#40291)

* Updates to slider_test.dart

Fixed error that required onChanged.

* Updated slider.dart and slider_test.dart debugFillProperties

Updated slider.dart debugFillProperties to include all properties and slider_test debugFillProperties to test all properties

* Updated Slider onChanged property

* Updated debugFillProperties to ignore testing methods that are null in test

Per feedback from Hans/Anthony on Flutter Material

* Updated spacing in debugFillProperties

Per feedback from Hans

* Updated range_slider.dart and range_slider_test.dart to have DiagnosticProperties tests for all properties

* Updated range_slider.dart and range_slider_test.dart per feedback

Preventing null labels from creating an error.

Added made RangeLabels and RangeValues constants in instantiation of Range Slider.

Fixed spacing.

* Updates to start and end labels in diagnostic property tests

Updated per feedback from @clocksmith
parent 6714baab
......@@ -337,6 +337,24 @@ class RangeSlider extends StatefulWidget {
@override
_RangeSliderState createState() => _RangeSliderState();
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DoubleProperty('valueStart', values.start));
properties.add(DoubleProperty('valueEnd', values.end));
properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>('onChanged', onChanged, ifNull: 'disabled'));
properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>.has('onChangeStart', onChangeStart));
properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>.has('onChangeEnd', onChangeEnd));
properties.add(DoubleProperty('min', min));
properties.add(DoubleProperty('max', max));
properties.add(IntProperty('divisions', divisions));
properties.add(StringProperty('labelStart', labels?.start));
properties.add(StringProperty('labelEnd', labels?.end));
properties.add(ColorProperty('activeColor', activeColor));
properties.add(ColorProperty('inactiveColor', inactiveColor));
properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>.has('semanticFormatterCallback', semanticFormatterCallback));
}
}
class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin {
......
......@@ -1533,5 +1533,40 @@ void main() {
await gesture.up();
});
testWidgets('Range Slider implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
RangeSlider(
activeColor: Colors.blue,
divisions: 4,
inactiveColor: Colors.grey,
labels: const RangeLabels('lowerValue', 'upperValue'),
max: 100.0,
min: 0.0,
onChanged: null,
onChangeEnd: null,
onChangeStart: null,
semanticFormatterCallback: null,
values: const RangeValues(25.0, 75.0),
).debugFillProperties(builder);
final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString()).toList();
expect(description, <String>[
'valueStart: 25.0',
'valueEnd: 75.0',
'disabled',
'min: 0.0',
'max: 100.0',
'divisions: 4',
'labelStart: "lowerValue"',
'labelEnd: "upperValue"',
'activeColor: MaterialColor(primary value: Color(0xff2196f3))',
'inactiveColor: MaterialColor(primary value: Color(0xff9e9e9e))'
]);
});
}
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