|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
5 | 5 | import 'dart:async';
|
| 6 | +import 'dart:io'; |
| 7 | +import 'dart:typed_data'; |
6 | 8 |
|
7 | 9 | import 'package:flutter/foundation.dart';
|
8 | 10 | import 'package:flutter/material.dart';
|
9 |
| -import 'package:integration_test/integration_test.dart'; |
| 11 | +import 'package:flutter/services.dart' show rootBundle; |
10 | 12 | import 'package:flutter_test/flutter_test.dart';
|
| 13 | +import 'package:integration_test/integration_test.dart'; |
| 14 | +import 'package:path_provider/path_provider.dart'; |
11 | 15 | import 'package:video_player/video_player.dart';
|
12 | 16 |
|
13 | 17 | const Duration _playDuration = Duration(seconds: 1);
|
@@ -224,5 +228,23 @@ void main() {
|
224 | 228 | skip: kIsWeb || // Web does not support local assets.
|
225 | 229 | // Extremely flaky on iOS: https://github.com/flutter/flutter/issues/86915
|
226 | 230 | 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); |
227 | 249 | });
|
228 | 250 | }
|
0 commit comments