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

Commit 8624a5f

Browse files
[video_player] Reduce server dependencies in tests (#5103)
Reduce test dependencies on servers that the Flutter team doesn't control: - Switches webm URL to the GitHub URL for the example asset, matching the existing mp4 setup - Switches m3u8 URL to the assets-for-api-docs URL that was recently added for a native iOS video_player test Ideally these would use local web severs, but initial attempts to serve binary assets via the local web server didn't work, and I won't have time to investigate further in the short term. This is an incremental improvement, and adds TODOs to fully convert.
1 parent 1bb37bd commit 8624a5f

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ const String _videoAssetKey =
2121
kIsWeb ? 'assets/Butterfly-209.webm' : 'assets/Butterfly-209.mp4';
2222

2323
// Returns the URL to load an asset from this example app as a network source.
24+
//
25+
// TODO(stuartmorgan): Convert this to a local `HttpServer` that vends the
26+
// assets directly, https://github.com/flutter/flutter/issues/95420
2427
String getUrlForAssetAsNetworkSource(String assetKey) {
2528
return 'https://github.com/flutter/plugins/blob/'
2629
// This hash can be rolled forward to pick up newly-added assets.
27-
'cba393233e559c925a4daf71b06b4bb01c606762'
30+
'cb381ced070d356799dddf24aca38ce0579d3d7b'
2831
'/packages/video_player/video_player/example/'
2932
'$assetKey'
3033
'?raw=true';
@@ -56,7 +59,7 @@ void main() {
5659
(WidgetTester tester) async {
5760
final VideoPlayerController networkController =
5861
VideoPlayerController.network(
59-
'https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8',
62+
'https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8',
6063
);
6164
await networkController.initialize();
6265

@@ -229,13 +232,8 @@ void main() {
229232

230233
group('network videos', () {
231234
setUp(() {
232-
// TODO(stuartmorgan): Remove this conditional and update the hash in
233-
// getUrlForAssetAsNetworkSource as a follow-up, once the webm asset is
234-
// checked in.
235-
final String videoUrl = kIsWeb
236-
? 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm'
237-
: getUrlForAssetAsNetworkSource(_videoAssetKey);
238-
_controller = VideoPlayerController.network(videoUrl);
235+
_controller = VideoPlayerController.network(
236+
getUrlForAssetAsNetworkSource(_videoAssetKey));
239237
});
240238

241239
testWidgets(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ const Duration _playDuration = Duration(seconds: 1);
2424
const String _videoAssetKey = 'assets/Butterfly-209.mp4';
2525

2626
// Returns the URL to load an asset from this example app as a network source.
27+
//
28+
// TODO(stuartmorgan): Convert this to a local `HttpServer` that vends the
29+
// assets directly, https://github.com/flutter/flutter/issues/95420
2730
String getUrlForAssetAsNetworkSource(String assetKey) {
2831
return 'https://github.com/flutter/plugins/blob/'
2932
// This hash can be rolled forward to pick up newly-added assets.
30-
'cba393233e559c925a4daf71b06b4bb01c606762'
33+
'cb381ced070d356799dddf24aca38ce0579d3d7b'
3134
'/packages/video_player/video_player/example/'
3235
'$assetKey'
3336
'?raw=true';
@@ -155,7 +158,7 @@ void main() {
155158

156159
testWidgets('live stream duration != 0', (WidgetTester tester) async {
157160
final MiniController livestreamController = MiniController.network(
158-
'https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8',
161+
'https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8',
159162
);
160163
await livestreamController.initialize();
161164

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ const Duration _playDuration = Duration(seconds: 1);
2424
const String _videoAssetKey = 'assets/Butterfly-209.mp4';
2525

2626
// Returns the URL to load an asset from this example app as a network source.
27+
//
28+
// TODO(stuartmorgan): Convert this to a local `HttpServer` that vends the
29+
// assets directly, https://github.com/flutter/flutter/issues/95420
2730
String getUrlForAssetAsNetworkSource(String assetKey) {
2831
return 'https://github.com/flutter/plugins/blob/'
2932
// This hash can be rolled forward to pick up newly-added assets.
30-
'cba393233e559c925a4daf71b06b4bb01c606762'
33+
'cb381ced070d356799dddf24aca38ce0579d3d7b'
3134
'/packages/video_player/video_player/example/'
3235
'$assetKey'
3336
'?raw=true';
@@ -167,7 +170,7 @@ void main() {
167170

168171
testWidgets('live stream duration != 0', (WidgetTester tester) async {
169172
final MiniController livestreamController = MiniController.network(
170-
'https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8',
173+
'https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8',
171174
);
172175
await livestreamController.initialize();
173176

0 commit comments

Comments
 (0)