Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit b401c84

Browse files
[video_player]: initial test coverage file() constructor api (#3407)
1 parent 3da7654 commit b401c84

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

packages/video_player/video_player/example/integration_test/video_player_test.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:io';
7+
import 'dart:typed_data';
68

79
import 'package:flutter/foundation.dart';
810
import 'package:flutter/material.dart';
9-
import 'package:integration_test/integration_test.dart';
11+
import 'package:flutter/services.dart' show rootBundle;
1012
import 'package:flutter_test/flutter_test.dart';
13+
import 'package:integration_test/integration_test.dart';
14+
import 'package:path_provider/path_provider.dart';
1115
import 'package:video_player/video_player.dart';
1216

1317
const Duration _playDuration = Duration(seconds: 1);
@@ -224,5 +228,23 @@ void main() {
224228
skip: kIsWeb || // Web does not support local assets.
225229
// Extremely flaky on iOS: https://github.com/flutter/flutter/issues/86915
226230
defaultTargetPlatform == TargetPlatform.iOS);
231+
232+
testWidgets('test video player using static file() method as constructor',
233+
(WidgetTester tester) async {
234+
String tempDir = (await getTemporaryDirectory()).path;
235+
ByteData bytes = await rootBundle.load('assets/Butterfly-209.mp4');
236+
237+
File file = File('$tempDir/Butterfly-209.mp4');
238+
await file.writeAsBytes(bytes.buffer.asInt8List());
239+
240+
VideoPlayerController fileController = VideoPlayerController.file(file);
241+
await fileController.initialize();
242+
243+
await fileController.play();
244+
expect(fileController.value.isPlaying, true);
245+
246+
await fileController.pause();
247+
expect(fileController.value.isPlaying, false);
248+
}, skip: kIsWeb);
227249
});
228250
}

packages/video_player/video_player/example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ dev_dependencies:
2424
sdk: flutter
2525
integration_test:
2626
sdk: flutter
27-
test: any
27+
path_provider: ^2.0.6
2828
pedantic: ^1.10.0
29+
test: any
2930

3031
flutter:
3132
uses-material-design: true

0 commit comments

Comments
 (0)