From e21952ad3b2a80ce154feca291f6412e5836e765 Mon Sep 17 00:00:00 2001 From: David Iglesias Date: Mon, 22 Feb 2021 19:11:03 -0800 Subject: [PATCH] [video_player_platform_interface] Bump version for NNBD stable (#3578) --- .../CHANGELOG.md | 26 ++--- .../lib/messages.dart | 30 ++--- .../lib/test.dart | 2 +- .../pubspec.yaml | 11 +- .../method_channel_video_player_test.dart | 110 +++++++----------- 5 files changed, 70 insertions(+), 109 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 7b223f4d958c4..d0c59bd050232 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,27 +1,15 @@ -## 4.0.0-nullsafety.1 +## 4.0.0 +* **Breaking Changes**: + * Migrate to null-safety + * Update to latest Pigeon. This includes a breaking change to how the test logic is exposed. * Add note about the `mixWithOthers` option being ignored on the web. - -## 4.0.0-nullsafety.0 - -* Update to latest Pigeon. - This includes a breaking change to how the test logic is exposed. - -## 3.0.0-nullsafety.3 - -* `messages.dart` sets Dart `2.12`. - -## 3.0.0-nullsafety.2 - -* Bump Dart SDK to support null safety. - -## 3.0.0-nullsafety.1 - * Make DataSource's `uri` parameter nullable. +* `messages.dart` sets Dart `2.12`. -## 3.0.0-nullsafety +## 3.0.0 -* Migrate to null safety. +* Version 3 only was published as nullsafety "previews". ## 2.2.1 diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index 3f2d78ef9ed5a..dc5237f2e151f 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.19), do not edit directly. +// Autogenerated from Pigeon (v0.1.21), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import // @dart = 2.12 @@ -18,7 +18,7 @@ class TextureMessage { static TextureMessage decode(Object message) { final Map pigeonMap = message as Map; - return TextureMessage()..textureId = pigeonMap['textureId'] as int; + return TextureMessage()..textureId = pigeonMap['textureId'] as int?; } } @@ -40,10 +40,10 @@ class CreateMessage { static CreateMessage decode(Object message) { final Map pigeonMap = message as Map; return CreateMessage() - ..asset = pigeonMap['asset'] as String - ..uri = pigeonMap['uri'] as String - ..packageName = pigeonMap['packageName'] as String - ..formatHint = pigeonMap['formatHint'] as String; + ..asset = pigeonMap['asset'] as String? + ..uri = pigeonMap['uri'] as String? + ..packageName = pigeonMap['packageName'] as String? + ..formatHint = pigeonMap['formatHint'] as String?; } } @@ -61,8 +61,8 @@ class LoopingMessage { static LoopingMessage decode(Object message) { final Map pigeonMap = message as Map; return LoopingMessage() - ..textureId = pigeonMap['textureId'] as int - ..isLooping = pigeonMap['isLooping'] as bool; + ..textureId = pigeonMap['textureId'] as int? + ..isLooping = pigeonMap['isLooping'] as bool?; } } @@ -80,8 +80,8 @@ class VolumeMessage { static VolumeMessage decode(Object message) { final Map pigeonMap = message as Map; return VolumeMessage() - ..textureId = pigeonMap['textureId'] as int - ..volume = pigeonMap['volume'] as double; + ..textureId = pigeonMap['textureId'] as int? + ..volume = pigeonMap['volume'] as double?; } } @@ -99,8 +99,8 @@ class PlaybackSpeedMessage { static PlaybackSpeedMessage decode(Object message) { final Map pigeonMap = message as Map; return PlaybackSpeedMessage() - ..textureId = pigeonMap['textureId'] as int - ..speed = pigeonMap['speed'] as double; + ..textureId = pigeonMap['textureId'] as int? + ..speed = pigeonMap['speed'] as double?; } } @@ -118,8 +118,8 @@ class PositionMessage { static PositionMessage decode(Object message) { final Map pigeonMap = message as Map; return PositionMessage() - ..textureId = pigeonMap['textureId'] as int - ..position = pigeonMap['position'] as int; + ..textureId = pigeonMap['textureId'] as int? + ..position = pigeonMap['position'] as int?; } } @@ -135,7 +135,7 @@ class MixWithOthersMessage { static MixWithOthersMessage decode(Object message) { final Map pigeonMap = message as Map; return MixWithOthersMessage() - ..mixWithOthers = pigeonMap['mixWithOthers'] as bool; + ..mixWithOthers = pigeonMap['mixWithOthers'] as bool?; } } diff --git a/packages/video_player/video_player_platform_interface/lib/test.dart b/packages/video_player/video_player_platform_interface/lib/test.dart index 538e9526b1117..457a838e8d24b 100644 --- a/packages/video_player/video_player_platform_interface/lib/test.dart +++ b/packages/video_player/video_player_platform_interface/lib/test.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.19), do not edit directly. +// Autogenerated from Pigeon (v0.1.21), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import // @dart = 2.12 diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index ed16ea1033fa6..c85f483d041f5 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -3,19 +3,18 @@ description: A common platform interface for the video_player plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.0.0-nullsafety.1 +version: 4.0.0 dependencies: flutter: sdk: flutter - meta: ^1.3.0-nullsafety.3 + meta: ^1.3.0 flutter_test: sdk: flutter dev_dependencies: - mockito: ^4.1.1 - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 environment: - sdk: ">=2.12.0-0 <3.0.0" - flutter: ">=1.10.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" + flutter: ">=1.20.0" diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index 669fd2839897a..fae4b746bf053 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -2,14 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(egarciad): Remove once Mockito is migrated to null safety. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; import 'package:video_player_platform_interface/messages.dart'; import 'package:video_player_platform_interface/method_channel_video_player.dart'; import 'package:video_player_platform_interface/test.dart'; @@ -17,13 +13,13 @@ import 'package:video_player_platform_interface/video_player_platform_interface. class _ApiLogger implements TestHostVideoPlayerApi { final List log = []; - TextureMessage textureMessage; - CreateMessage createMessage; - PositionMessage positionMessage; - LoopingMessage loopingMessage; - VolumeMessage volumeMessage; - PlaybackSpeedMessage playbackSpeedMessage; - MixWithOthersMessage mixWithOthersMessage; + TextureMessage? textureMessage; + CreateMessage? createMessage; + PositionMessage? positionMessage; + LoopingMessage? loopingMessage; + VolumeMessage? volumeMessage; + PlaybackSpeedMessage? playbackSpeedMessage; + MixWithOthersMessage? mixWithOthersMessage; @override TextureMessage create(CreateMessage arg) { @@ -101,28 +97,11 @@ void main() { expect(VideoPlayerPlatform.instance, isInstanceOf()); }); - - test('Cannot be implemented with `implements`', () { - expect(() { - VideoPlayerPlatform.instance = ImplementsVideoPlayerPlatform(); - }, throwsA(isInstanceOf())); - }); - - test('Can be mocked with `implements`', () { - final ImplementsVideoPlayerPlatform mock = - ImplementsVideoPlayerPlatform(); - when(mock.isMock).thenReturn(true); - VideoPlayerPlatform.instance = mock; - }); - - test('Can be extended', () { - VideoPlayerPlatform.instance = ExtendsVideoPlayerPlatform(); - }); }); group('$MethodChannelVideoPlayer', () { final MethodChannelVideoPlayer player = MethodChannelVideoPlayer(); - _ApiLogger log; + late _ApiLogger log; setUp(() { log = _ApiLogger(); @@ -140,108 +119,108 @@ void main() { test('dispose', () async { await player.dispose(1); expect(log.log.last, 'dispose'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('create with asset', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.asset, asset: 'someAsset', package: 'somePackage', )); expect(log.log.last, 'create'); - expect(log.createMessage.asset, 'someAsset'); - expect(log.createMessage.packageName, 'somePackage'); + expect(log.createMessage?.asset, 'someAsset'); + expect(log.createMessage?.packageName, 'somePackage'); expect(textureId, 3); }); test('create with network', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.network, uri: 'someUri', formatHint: VideoFormat.dash, )); expect(log.log.last, 'create'); - expect(log.createMessage.uri, 'someUri'); - expect(log.createMessage.formatHint, 'dash'); + expect(log.createMessage?.uri, 'someUri'); + expect(log.createMessage?.formatHint, 'dash'); expect(textureId, 3); }); test('create with file', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.file, uri: 'someUri', )); expect(log.log.last, 'create'); - expect(log.createMessage.uri, 'someUri'); + expect(log.createMessage?.uri, 'someUri'); expect(textureId, 3); }); test('setLooping', () async { await player.setLooping(1, true); expect(log.log.last, 'setLooping'); - expect(log.loopingMessage.textureId, 1); - expect(log.loopingMessage.isLooping, true); + expect(log.loopingMessage?.textureId, 1); + expect(log.loopingMessage?.isLooping, true); }); test('play', () async { await player.play(1); expect(log.log.last, 'play'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('pause', () async { await player.pause(1); expect(log.log.last, 'pause'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('setMixWithOthers', () async { await player.setMixWithOthers(true); expect(log.log.last, 'setMixWithOthers'); - expect(log.mixWithOthersMessage.mixWithOthers, true); + expect(log.mixWithOthersMessage?.mixWithOthers, true); await player.setMixWithOthers(false); expect(log.log.last, 'setMixWithOthers'); - expect(log.mixWithOthersMessage.mixWithOthers, false); + expect(log.mixWithOthersMessage?.mixWithOthers, false); }); test('setVolume', () async { await player.setVolume(1, 0.7); expect(log.log.last, 'setVolume'); - expect(log.volumeMessage.textureId, 1); - expect(log.volumeMessage.volume, 0.7); + expect(log.volumeMessage?.textureId, 1); + expect(log.volumeMessage?.volume, 0.7); }); test('setPlaybackSpeed', () async { await player.setPlaybackSpeed(1, 1.5); expect(log.log.last, 'setPlaybackSpeed'); - expect(log.playbackSpeedMessage.textureId, 1); - expect(log.playbackSpeedMessage.speed, 1.5); + expect(log.playbackSpeedMessage?.textureId, 1); + expect(log.playbackSpeedMessage?.speed, 1.5); }); test('seekTo', () async { await player.seekTo(1, const Duration(milliseconds: 12345)); expect(log.log.last, 'seekTo'); - expect(log.positionMessage.textureId, 1); - expect(log.positionMessage.position, 12345); + expect(log.positionMessage?.textureId, 1); + expect(log.positionMessage?.position, 12345); }); test('getPosition', () async { final Duration position = await player.getPosition(1); expect(log.log.last, 'position'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); expect(position, const Duration(milliseconds: 234)); }); test('videoEventsFor', () async { - ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler( + ServicesBinding.instance?.defaultBinaryMessenger.setMockMessageHandler( "flutter.io/videoPlayer/videoEvents123", - (ByteData message) async { + (ByteData? message) async { final MethodCall methodCall = const StandardMethodCodec().decodeMethodCall(message); if (methodCall.method == 'listen') { - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() @@ -251,18 +230,18 @@ void main() { 'width': 1920, 'height': 1080, }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'completed', }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() @@ -273,25 +252,25 @@ void main() { [1235, 4000], ], }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingStart', }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingEnd', }), - (ByteData data) {}); + (ByteData? data) {}); return const StandardMethodCodec().encodeSuccessEnvelope(null); } else if (methodCall.method == 'cancel') { @@ -328,8 +307,3 @@ void main() { }); }); } - -class ImplementsVideoPlayerPlatform extends Mock - implements VideoPlayerPlatform {} - -class ExtendsVideoPlayerPlatform extends VideoPlayerPlatform {}