Skip to content

Commit b9065e8

Browse files
committed
lightbox test [nfc]: Extract findSliderPosition
1 parent 97109a0 commit b9065e8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/widgets/lightbox_test.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,24 @@ void main() {
224224
FakeVideoPlayerPlatform.registerWith();
225225
final platform = FakeVideoPlayerPlatform.instance;
226226

227+
/// Find the position shown by the slider, and check the label agrees.
228+
Duration findSliderPosition(WidgetTester tester) {
229+
final sliderValue = tester.widget<Slider>(find.byType(Slider)).value;
230+
final result = Duration(milliseconds: sliderValue.toInt());
231+
check(tester.widget<RichText>(
232+
find.descendant(of: find.bySemanticsLabel('Current position'),
233+
matching: find.byType(RichText))).text.toPlainText())
234+
.equals(VideoDurationLabel.formatDuration(result));
235+
return result;
236+
}
237+
227238
/// Check the slider and label show position [slider],
228239
/// and the actual position of the video controller is [video].
229240
void checkPositions(WidgetTester tester, {
230241
required Duration slider,
231242
required Duration video,
232243
}) {
233-
check(tester.widget<Slider>(find.byType(Slider)).value.toInt())
234-
.equals(slider.inMilliseconds);
235-
check(tester.widget<RichText>(
236-
find.descendant(of: find.bySemanticsLabel('Current position'),
237-
matching: find.byType(RichText))).text.toPlainText())
238-
.equals(VideoDurationLabel.formatDuration(slider));
239-
244+
check(findSliderPosition(tester)).equals(slider);
240245
check(platform.position).equals(video);
241246
}
242247

0 commit comments

Comments
 (0)