Skip to content

Commit

Permalink
test: Add test to verify input captions are unsorted
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelaziz-mahdy committed Dec 31, 2024
1 parent 9a23e47 commit 57260cb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/video_player/video_player/test/video_player_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,31 @@ void main() {
});

group('caption', () {
test('makes sure the input captions are unsorted', () async {
final VideoPlayerController controller =
VideoPlayerController.networkUrl(
_localhostUri,
closedCaptionFile: _loadClosedCaption(),
);

await controller.initialize();
final List<Caption> captions =
(await controller.closedCaptionFile)!.captions.toList();

// Check that captions are not in sorted order
bool isSorted = true;
for (int i = 0; i < captions.length - 1; i++) {
if (captions[i].start.compareTo(captions[i + 1].start) > 0) {
isSorted = false;
break;
}
}

expect(isSorted, false, reason: 'Expected captions to be unsorted');
expect(captions.map((Caption c) => c.text).toList(),
<String>['one', 'two', 'three', 'five', 'four'],
reason: 'Captions should be in original unsorted order');
});
test('works when seeking, includes all captions', () async {
final VideoPlayerController controller =
VideoPlayerController.networkUrl(
Expand Down

0 comments on commit 57260cb

Please sign in to comment.