From 834be88e7f6a1211557975b3a1aeb6d08da31a74 Mon Sep 17 00:00:00 2001 From: Emmanuel Garcia Date: Thu, 29 Oct 2020 17:14:34 -0700 Subject: [PATCH] [video_player] Add toString() to Caption --- .../video_player/video_player/CHANGELOG.md | 4 +++ .../lib/src/closed_caption_file.dart | 9 ++++++ .../video_player/video_player/pubspec.yaml | 2 +- .../test/closed_caption_file_test.dart | 28 +++++++++++++++++++ .../video_player/test/video_player_test.dart | 2 +- 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 packages/video_player/video_player/test/closed_caption_file_test.dart diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index 787393991f3a..e02bd76aa818 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.1+4 + +* Add `toString()` to `Caption`. + ## 0.11.1+3 * Android: Upgrade ExoPlayer to 2.12.1. diff --git a/packages/video_player/video_player/lib/src/closed_caption_file.dart b/packages/video_player/video_player/lib/src/closed_caption_file.dart index 2d9242a675d5..550e30a77935 100644 --- a/packages/video_player/video_player/lib/src/closed_caption_file.dart +++ b/packages/video_player/video_player/lib/src/closed_caption_file.dart @@ -45,4 +45,13 @@ class Caption { /// The actual text that should appear on screen to be read between [start] /// and [end]. final String text; + + @override + String toString() { + return '$runtimeType(' + 'number: $number, ' + 'start: $start, ' + 'end: $end, ' + 'text: $text)'; + } } diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index 26686ccf937a..8234fee272e3 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter # 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump # the version to 2.0.0. # See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0 -version: 0.11.1+3 +version: 0.11.1+4 homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player flutter: diff --git a/packages/video_player/video_player/test/closed_caption_file_test.dart b/packages/video_player/video_player/test/closed_caption_file_test.dart new file mode 100644 index 000000000000..148c082bceee --- /dev/null +++ b/packages/video_player/video_player/test/closed_caption_file_test.dart @@ -0,0 +1,28 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter_test/flutter_test.dart'; +import 'package:video_player/src/closed_caption_file.dart'; + +void main() { + group('ClosedCaptionFile', () { + test('toString()', () { + final Caption caption = const Caption( + number: 1, + start: Duration(seconds: 1), + end: Duration(seconds: 2), + text: 'caption', + ); + + expect( + caption.toString(), + 'Caption(' + 'number: 1, ' + 'start: 0:00:01.000000, ' + 'end: 0:00:02.000000, ' + 'text: caption' + ')'); + }); + }); +} diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index a40781a1e9ce..a7b23c3b1f27 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -566,7 +566,7 @@ void main() { 'VideoPlayerValue(duration: 0:00:05.000000, ' 'size: Size(400.0, 300.0), ' 'position: 0:00:01.000000, ' - 'caption: Instance of \'Caption\', ' + 'caption: Caption(number: null, start: null, end: null, text: foo), ' 'buffered: [DurationRange(start: 0:00:00.000000, end: 0:00:04.000000)], ' 'isPlaying: true, ' 'isLooping: true, '