Skip to content

Commit

Permalink
Move throw-exception-on-invalid-asset test from Dart side to native i…
Browse files Browse the repository at this point in the history
…OS side
  • Loading branch information
FirentisTFW committed Jan 20, 2025
1 parent cee36ce commit 09e148e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,32 @@ - (FVPDisplayLink *)displayLinkWithRegistrar:(id<FlutterPluginRegistrar>)registr

@implementation VideoPlayerTests

- (void)testCreateWithOptionsReturnsErrorForInvalidAssetPath {
NSObject<FlutterPluginRegistrar> *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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 09e148e

Please sign in to comment.