Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:video_player/video_player.dart';
Expand All @@ -29,38 +29,81 @@ void main() {
const Duration(seconds: 7, milliseconds: 540));
});

testWidgets('can be played', (WidgetTester tester) async {
await _controller.initialize();
testWidgets(
'can be played',
(WidgetTester tester) async {
await _controller.initialize();

await _controller.play();
await tester.pumpAndSettle(_playDuration);
await _controller.play();
await tester.pumpAndSettle(_playDuration);

expect(_controller.value.isPlaying, true);
expect(_controller.value.position,
(Duration position) => position > const Duration(seconds: 0));
}, skip: Platform.isIOS);
expect(_controller.value.isPlaying, true);
expect(_controller.value.position,
(Duration position) => position > const Duration(seconds: 0));
},
);

testWidgets('can seek', (WidgetTester tester) async {
await _controller.initialize();
testWidgets(
'can seek',
(WidgetTester tester) async {
await _controller.initialize();

await _controller.seekTo(const Duration(seconds: 3));
await _controller.seekTo(const Duration(seconds: 3));

expect(_controller.value.position, const Duration(seconds: 3));
}, skip: Platform.isIOS);
expect(_controller.value.position, const Duration(seconds: 3));
},
);

testWidgets('can be paused', (WidgetTester tester) async {
await _controller.initialize();
testWidgets(
'can be paused',
(WidgetTester tester) async {
await _controller.initialize();

// Play for a second, then pause, and then wait a second.
await _controller.play();
await tester.pumpAndSettle(_playDuration);
await _controller.pause();
final Duration pausedPosition = _controller.value.position;
await tester.pumpAndSettle(_playDuration);
// Play for a second, then pause, and then wait a second.
await _controller.play();
await tester.pumpAndSettle(_playDuration);
await _controller.pause();
final Duration pausedPosition = _controller.value.position;
await tester.pumpAndSettle(_playDuration);

// Verify that we stopped playing after the pause.
expect(_controller.value.isPlaying, false);
expect(_controller.value.position, pausedPosition);
}, skip: Platform.isIOS);
// Verify that we stopped playing after the pause.
expect(_controller.value.isPlaying, false);
expect(_controller.value.position, pausedPosition);
},
);

testWidgets('test video player view with local asset',
(WidgetTester tester) async {
Future<bool> started() async {
await _controller.initialize();
await _controller.play();
return true;
}

await tester.pumpWidget(Material(
elevation: 0,
child: Directionality(
textDirection: TextDirection.ltr,
child: Center(
child: FutureBuilder<bool>(
future: started(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.data == true) {
return AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
);
} else {
return const Text('waiting for video to load');
}
},
),
),
),
));

await tester.pumpAndSettle();
expect(_controller.value.isPlaying, true);
});
});
}
8 changes: 7 additions & 1 deletion packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: video_player_example
description: Demonstrates how to use the video_player plugin.
version: 0.0.1
publish_to: none

dependencies:
flutter:
Expand All @@ -14,7 +16,7 @@ dev_dependencies:
sdk: flutter
integration_test:
path: ../../../integration_test
test: any
# test: any
pedantic: ^1.8.0

flutter:
Expand All @@ -23,3 +25,7 @@ flutter:
- assets/flutter-mark-square-64.png
- assets/Butterfly-209.mp4
- assets/bumble_bee_captions.srt

environment:
sdk: ">=2.8.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"

This file was deleted.

This file was deleted.