Skip to content

Commit

Permalink
chore(deps): Bump video_player_platform_interface from 5.1.4 to 6.0.1…
Browse files Browse the repository at this point in the history
… in /flutter_news_example/packages/news_blocks_ui (#671)

* chore(deps): Bump video_player_platform_interface

Bumps [video_player_platform_interface](https://github.com/flutter/plugins/tree/main/packages/video_player) from 5.1.4 to 6.0.1.
- [Release notes](https://github.com/flutter/plugins/releases)
- [Commits](https://github.com/flutter/plugins/commits/video_player_platform_interface-v6.0.1/packages/video_player)

---
updated-dependencies:
- dependency-name: video_player_platform_interface
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix video player tests

* fix flutter_news_example tests

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: matiasleyba <[email protected]>
Co-authored-by: Kaicey Dettmann <[email protected]>
  • Loading branch information
3 people authored Mar 30, 2023
1 parent dbba780 commit bb474ff
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 6 deletions.
2 changes: 1 addition & 1 deletion flutter_news_example/packages/news_blocks_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
url_launcher: ^6.1.7
url_launcher_platform_interface: ^2.1.1
video_player: ^2.4.2
video_player_platform_interface: ^5.1.4
video_player_platform_interface: ^6.0.1

dev_dependencies:
fake_async: ^1.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

class FakeVideoPlayerPlatform extends VideoPlayerPlatform {
Completer<bool> initialized = Completer<bool>();
List<String> calls = <String>[];
List<DataSource> dataSources = <DataSource>[];
final Map<int, StreamController<VideoEvent>> streams =
<int, StreamController<VideoEvent>>{};
bool forceInitError = false;
int nextTextureId = 0;
final Map<int, Duration> _positions = <int, Duration>{};

@override
Future<int?> create(DataSource dataSource) async {
calls.add('create');
final stream = StreamController<VideoEvent>();
streams[nextTextureId] = stream;
if (forceInitError) {
stream.addError(
PlatformException(
code: 'VideoError',
message: 'Video player had error XYZ',
),
);
} else {
stream.add(
VideoEvent(
eventType: VideoEventType.initialized,
size: const Size(100, 100),
duration: const Duration(seconds: 1),
),
);
}
dataSources.add(dataSource);
return nextTextureId++;
}

@override
Future<void> dispose(int textureId) async {
calls.add('dispose');
}

@override
Future<void> init() async {
calls.add('init');
initialized.complete(true);
}

@override
Stream<VideoEvent> videoEventsFor(int textureId) {
return streams[textureId]!.stream;
}

@override
Future<void> pause(int textureId) async {
calls.add('pause');
}

@override
Future<void> play(int textureId) async {
calls.add('play');
}

@override
Future<Duration> getPosition(int textureId) async {
calls.add('position');
return _positions[textureId] ?? Duration.zero;
}

@override
Future<void> seekTo(int textureId, Duration position) async {
calls.add('seekTo');
_positions[textureId] = position;
}

@override
Future<void> setLooping(int textureId, bool looping) async {
calls.add('setLooping');
}

@override
Future<void> setVolume(int textureId, double volume) async {
calls.add('setVolume');
}

@override
Future<void> setPlaybackSpeed(int textureId, double speed) async {
calls.add('setPlaybackSpeed');
}

@override
Future<void> setMixWithOthers(bool mixWithOthers) async {
calls.add('setMixWithOthers');
}

@override
Widget buildView(int textureId) {
return Texture(textureId: textureId);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export 'fake_video_player_platform.dart';
export 'path_provider.dart';
export 'pump_app.dart';
export 'pump_content_themed_app.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:mocktail_image_network/mocktail_image_network.dart';
import 'package:news_blocks/news_blocks.dart';
import 'package:news_blocks_ui/news_blocks_ui.dart';
import 'package:news_blocks_ui/src/widgets/widgets.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

import '../helpers/helpers.dart';

Expand All @@ -19,7 +20,13 @@ void main() {
'and prices are finally falling';

group('VideoIntroduction', () {
setUpAll(setUpTolerantComparator);
setUpAll(
() {
final fakeVideoPlayerPlatform = FakeVideoPlayerPlatform();
VideoPlayerPlatform.instance = fakeVideoPlayerPlatform;
setUpTolerantComparator();
},
);

testWidgets('renders correctly', (tester) async {
final technologyVideoIntroduction = VideoIntroductionBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:news_blocks/news_blocks.dart';
import 'package:news_blocks_ui/news_blocks_ui.dart';
import 'package:news_blocks_ui/src/widgets/widgets.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

import '../helpers/helpers.dart';

void main() {
group('Video', () {
setUp(
() {
final fakeVideoPlayerPlatform = FakeVideoPlayerPlatform();
VideoPlayerPlatform.instance = fakeVideoPlayerPlatform;
},
);

testWidgets('renders InlineVideo with correct video', (tester) async {
const block = VideoBlock(videoUrl: 'videoUrl');

Expand All @@ -28,11 +36,14 @@ void main() {
testWidgets('renders ProgressIndicator when loading', (tester) async {
const block = VideoBlock(videoUrl: 'videoUrl');

await tester.pumpApp(
await tester.pumpWidget(
Video(block: block),
);

expect(find.byType(ProgressIndicator), findsOneWidget);
expect(
find.byType(ProgressIndicator, skipOffstage: false),
findsOneWidget,
);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ import 'package:flutter/material.dart' hide ProgressIndicator;
import 'package:flutter_test/flutter_test.dart';
import 'package:news_blocks_ui/src/widgets/widgets.dart';
import 'package:video_player/video_player.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

import '../../helpers/helpers.dart';

void main() {
group('InlineVideo', () {
setUp(
() {
final fakeVideoPlayerPlatform = FakeVideoPlayerPlatform();
VideoPlayerPlatform.instance = fakeVideoPlayerPlatform;
},
);

testWidgets('renders progressIndicator when loading', (tester) async {
const progressIndicatorKey = Key('__progress_indicator__');
final controller = FakeVideoPlayerController();
Expand Down
4 changes: 2 additions & 2 deletions flutter_news_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1658,13 +1658,13 @@ packages:
source: hosted
version: "2.3.8"
video_player_platform_interface:
dependency: transitive
dependency: "direct main"
description:
name: video_player_platform_interface
sha256: "318a6d20577e1c78cf0bf40670883cc571ea860c72a4f7426d7dacce4bdd4343"
url: "https://pub.dev"
source: hosted
version: "5.1.4"
version: "6.0.1"
video_player_web:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions flutter_news_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ dependencies:
user_repository:
path: packages/user_repository
very_good_analysis: ^4.0.0
video_player_platform_interface: ^6.0.1
visibility_detector: ^0.3.3

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

class FakeVideoPlayerPlatform extends VideoPlayerPlatform {
Completer<bool> initialized = Completer<bool>();
List<String> calls = <String>[];
List<DataSource> dataSources = <DataSource>[];
final Map<int, StreamController<VideoEvent>> streams =
<int, StreamController<VideoEvent>>{};
bool forceInitError = false;
int nextTextureId = 0;
final Map<int, Duration> _positions = <int, Duration>{};

@override
Future<int?> create(DataSource dataSource) async {
calls.add('create');
final stream = StreamController<VideoEvent>();
streams[nextTextureId] = stream;
if (forceInitError) {
stream.addError(
PlatformException(
code: 'VideoError',
message: 'Video player had error XYZ',
),
);
} else {
stream.add(
VideoEvent(
eventType: VideoEventType.initialized,
size: const Size(100, 100),
duration: const Duration(seconds: 1),
),
);
}
dataSources.add(dataSource);
return nextTextureId++;
}

@override
Future<void> dispose(int textureId) async {
calls.add('dispose');
}

@override
Future<void> init() async {
calls.add('init');
initialized.complete(true);
}

@override
Stream<VideoEvent> videoEventsFor(int textureId) {
return streams[textureId]!.stream;
}

@override
Future<void> pause(int textureId) async {
calls.add('pause');
}

@override
Future<void> play(int textureId) async {
calls.add('play');
}

@override
Future<Duration> getPosition(int textureId) async {
calls.add('position');
return _positions[textureId] ?? Duration.zero;
}

@override
Future<void> seekTo(int textureId, Duration position) async {
calls.add('seekTo');
_positions[textureId] = position;
}

@override
Future<void> setLooping(int textureId, bool looping) async {
calls.add('setLooping');
}

@override
Future<void> setVolume(int textureId, double volume) async {
calls.add('setVolume');
}

@override
Future<void> setPlaybackSpeed(int textureId, double speed) async {
calls.add('setPlaybackSpeed');
}

@override
Future<void> setMixWithOthers(bool mixWithOthers) async {
calls.add('setMixWithOthers');
}

@override
Widget buildView(int textureId) {
return Texture(textureId: textureId);
}
}
1 change: 1 addition & 0 deletions flutter_news_example/test/article/helpers/helpers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'fake_video_player_platform.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import 'package:flutter_news_example/slideshow/slideshow.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:news_blocks/news_blocks.dart';
import 'package:news_blocks_ui/news_blocks_ui.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';
import 'package:visibility_detector/visibility_detector.dart';

import '../../helpers/helpers.dart';
import '../helpers/helpers.dart';

void main() {
initMockHydratedStorage();

void setUpVideoPlayerPlatform() {
final fakeVideoPlayerPlatform = FakeVideoPlayerPlatform();
VideoPlayerPlatform.instance = fakeVideoPlayerPlatform;
}

group('ArticleContentItem', () {
testWidgets(
'renders DividerHorizontal '
Expand Down Expand Up @@ -131,6 +138,7 @@ void main() {
testWidgets(
'renders Video '
'for VideoBlock', (tester) async {
setUpVideoPlayerPlatform();
const block = VideoBlock(videoUrl: 'videoUrl');
await tester.pumpApp(ArticleContentItem(block: block));
expect(
Expand Down Expand Up @@ -169,6 +177,8 @@ void main() {
testWidgets(
'renders VideoIntroduction '
'for VideoIntroductionBlock', (tester) async {
setUpVideoPlayerPlatform();

final block = VideoIntroductionBlock(
category: PostCategory.technology,
title: 'title',
Expand Down

0 comments on commit bb474ff

Please sign in to comment.