|
10 | 10 |
|
11 | 11 | @interface FLTVideoPlayer : NSObject <FlutterStreamHandler>
|
12 | 12 | @property(readonly, nonatomic) AVPlayer *player;
|
| 13 | +@property(readonly, nonatomic) CGAffineTransform preferredTransform; |
13 | 14 | @end
|
14 | 15 |
|
15 | 16 | @interface FLTVideoPlayerPlugin (Test) <FLTAVFoundationVideoPlayerApi>
|
@@ -121,6 +122,44 @@ - (void)testHLSControls {
|
121 | 122 | XCTAssertEqualWithAccuracy([videoInitialization[@"duration"] intValue], 4000, 200);
|
122 | 123 | }
|
123 | 124 |
|
| 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 | + |
124 | 163 | - (NSDictionary<NSString *, id> *)testPlugin:(FLTVideoPlayerPlugin *)videoPlayerPlugin
|
125 | 164 | uri:(NSString *)uri {
|
126 | 165 | FlutterError *error;
|
|
0 commit comments