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

Commit f984752

Browse files
committed
Add test
1 parent 7c1211e commit f984752

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/video_player/video_player_avfoundation/example/ios/RunnerTests/VideoPlayerTests.m

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
@interface FLTVideoPlayer : NSObject <FlutterStreamHandler>
1212
@property(readonly, nonatomic) AVPlayer *player;
13+
@property(readonly, nonatomic) CGAffineTransform preferredTransform;
1314
@end
1415

1516
@interface FLTVideoPlayerPlugin (Test) <FLTAVFoundationVideoPlayerApi>
@@ -121,6 +122,44 @@ - (void)testHLSControls {
121122
XCTAssertEqualWithAccuracy([videoInitialization[@"duration"] intValue], 4000, 200);
122123
}
123124

125+
- (void)testTransformFix {
126+
NSObject<FlutterPluginRegistry> *registry =
127+
(NSObject<FlutterPluginRegistry> *)[[UIApplication sharedApplication] delegate];
128+
NSObject<FlutterPluginRegistrar> *registrar = [registry registrarForPlugin:@"TestTransformFix"];
129+
FLTVideoPlayerPlugin *videoPlayerPlugin =
130+
(FLTVideoPlayerPlugin *)[[FLTVideoPlayerPlugin alloc] initWithRegistrar:registrar];
131+
132+
FlutterError *error;
133+
[videoPlayerPlugin initialize:&error];
134+
XCTAssertNil(error);
135+
136+
FLTCreateMessage *create = [FLTCreateMessage
137+
makeWithAsset:nil
138+
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
139+
packageName:nil
140+
formatHint:nil
141+
httpHeaders:@{}];
142+
FLTTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error];
143+
XCTAssertNil(error);
144+
XCTAssertNotNil(textureMessage);
145+
FLTVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
146+
XCTAssertNotNil(player);
147+
XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"initialized"];
148+
__block NSDictionary<NSString *, id> *initializationEvent;
149+
[player onListenWithArguments:nil
150+
eventSink:^(NSDictionary<NSString *, id> *event) {
151+
if ([event[@"event"] isEqualToString:@"initialized"]) {
152+
initializationEvent = event;
153+
XCTAssertEqual(event.count, 4);
154+
[initializedExpectation fulfill];
155+
}
156+
}];
157+
[self waitForExpectationsWithTimeout:30.0 handler:nil];
158+
CGAffineTransform transform = player.preferredTransform;
159+
XCTAssertEqual(transform.tx, 0.0f);
160+
XCTAssertEqual(transform.ty, 0.0f);
161+
}
162+
124163
- (NSDictionary<NSString *, id> *)testPlugin:(FLTVideoPlayerPlugin *)videoPlayerPlugin
125164
uri:(NSString *)uri {
126165
FlutterError *error;

0 commit comments

Comments
 (0)