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

Commit 75aa03b

Browse files
committed
Add test
1 parent 7c1211e commit 75aa03b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

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

0 commit comments

Comments
 (0)