From 09e148e477f578c5fd6e030ecb99c7e2745a669b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jakubowski?= Date: Mon, 20 Jan 2025 23:00:31 +0100 Subject: [PATCH] Move throw-exception-on-invalid-asset test from Dart side to native iOS side --- .../darwin/RunnerTests/VideoPlayerTests.m | 26 ++++++++++++++++ .../test/avfoundation_video_player_test.dart | 31 ------------------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m b/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m index f7756bc7514..91ded6527dd 100644 --- a/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m +++ b/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m @@ -165,6 +165,32 @@ - (FVPDisplayLink *)displayLinkWithRegistrar:(id)registr @implementation VideoPlayerTests +- (void)testCreateWithOptionsReturnsErrorForInvalidAssetPath { + NSObject *registrar = [GetPluginRegistry() + registrarForPlugin:@"testCreateWithOptionsReturnsErrorForInvalidAssetPath"]; + FVPVideoPlayerPlugin *videoPlayerPlugin = + [[FVPVideoPlayerPlugin alloc] initWithRegistrar:registrar]; + + FlutterError *initializationError; + [videoPlayerPlugin initialize:&initializationError]; + XCTAssertNil(initializationError); + + FVPCreationOptions *create = + [FVPCreationOptions makeWithAsset:@"invalid/path/to/asset" + uri:nil + packageName:nil + formatHint:nil + httpHeaders:@{} + viewType:FVPPlatformVideoViewTypeTextureView]; + + FlutterError *createError; + NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&createError]; + + XCTAssertNil(textureId); + XCTAssertNotNil(createError); + XCTAssertEqualObjects(createError.code, @"video_player"); +} + - (void)testBlankVideoBugWithEncryptedVideoStreamAndInvertedAspectRatioBugForSomeVideoStream { // This is to fix 2 bugs: 1. blank video for encrypted video streams on iOS 16 // (https://github.com/flutter/flutter/issues/111457) and 2. swapped width and height for some diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index e898956f9aa..6c3855c0df8 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -141,19 +141,6 @@ void main() { const VideoPlayerTextureViewState(textureId: 3)); }); - // FIXME Is this test valid? - test('create with incorrect asset throws exception', () async { - try { - await player.create(DataSource( - sourceType: DataSourceType.asset, - asset: '/path/to/incorrect_asset', - )); - fail('should throw PlatformException'); - } catch (e) { - expect(e, isException); - } - }); - test('create with network', () async { final int? textureId = await player.create(DataSource( sourceType: DataSourceType.network, @@ -220,24 +207,6 @@ void main() { const VideoPlayerTextureViewState(textureId: 3)); }); - // FIXME Is this test valid? - test('createWithOptions with incorrect asset throws exception', () async { - try { - await player.createWithOptions( - VideoCreationOptions( - dataSource: DataSource( - sourceType: DataSourceType.asset, - asset: '/path/to/incorrect_asset', - ), - viewType: VideoViewType.textureView, - ), - ); - fail('should throw PlatformException'); - } catch (e) { - expect(e, isException); - } - }); - test('createWithOptions with network', () async { final int? textureId = await player.createWithOptions( VideoCreationOptions(