Skip to content

Commit

Permalink
Added tests for decorated number picker
Browse files Browse the repository at this point in the history
  • Loading branch information
moniaS committed Aug 2, 2019
1 parent 7001b1c commit ea510b0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/integer_infinite_numberpicker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,18 @@ void main() {
infiniteLoop: true,
expectedDisplayValues: ['09', '10', '00']);
});
}

testWidgets('Decorated number picker works', (WidgetTester tester) async {
await testNumberPicker(
tester: tester,
minValue: 0,
maxValue: 10,
initialValue: 2,
scrollBy: 2,
expectedValue: 4,
infiniteLoop: true,
highlightSelectedValue: false,
decoration: decoration,
);
});
}
13 changes: 13 additions & 0 deletions test/integer_numberpicker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,17 @@ void main() {
scrollBy: 1,
expectedDisplayValues: ['02', '03', '04']);
});

testWidgets('Decorated number picker works', (WidgetTester tester) async {
await testNumberPicker(
tester: tester,
minValue: 0,
maxValue: 10,
initialValue: 2,
scrollBy: 2,
expectedValue: 4,
highlightSelectedValue: false,
decoration: decoration,
);
});
}
19 changes: 19 additions & 0 deletions test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:numberpicker/numberpicker.dart';

Decoration decoration = new BoxDecoration(
border: new Border(
top: new BorderSide(
style: BorderStyle.solid,
color: Colors.black26,
),
bottom: new BorderSide(
style: BorderStyle.solid,
color: Colors.black26,
),
),
);

Future<NumberPicker> testNumberPicker({
WidgetTester tester,
int minValue,
Expand All @@ -13,6 +26,8 @@ Future<NumberPicker> testNumberPicker({
bool animateToItself = false,
Axis axis = Axis.vertical,
bool infiniteLoop = false,
Decoration decoration,
bool highlightSelectedValue = true,
}) async {
int value = initialValue;
NumberPicker picker;
Expand All @@ -26,13 +41,17 @@ Future<NumberPicker> testNumberPicker({
maxValue: maxValue,
step: step,
infiniteLoop: infiniteLoop,
decoration: decoration,
highlightSelectedValue: highlightSelectedValue,
onChanged: (newValue) => setState(() => value = newValue),
)
: NumberPicker.horizontal(
initialValue: value,
minValue: minValue,
maxValue: maxValue,
step: step,
decoration: decoration,
highlightSelectedValue: highlightSelectedValue,
onChanged: (newValue) => setState(() => value = newValue),
);
return MaterialApp(
Expand Down

0 comments on commit ea510b0

Please sign in to comment.