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

Commit d4c7cd4

Browse files
Log unexpeted FlutterErrors in tests instead of throwing
1 parent f024969 commit d4c7cd4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,21 @@ - (void)testTransformFix {
191191
XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"initialized"];
192192
__block NSDictionary<NSString *, id> *initializationEvent;
193193
[player onListenWithArguments:nil
194-
eventSink:^(NSDictionary<NSString *, id> *event) {
195-
if ([event[@"event"] isEqualToString:@"initialized"]) {
196-
initializationEvent = event;
197-
XCTAssertEqual(event.count, 4);
198-
[initializedExpectation fulfill];
194+
eventSink:^(id event) {
195+
XCTAssertTrue([event isKindOfClass:[NSDictionary class]],
196+
@"Unexpected event type: %@", event);
197+
if ([event isKindOfClass:[NSDictionary class]]) {
198+
NSDictionary<NSString *, id> *eventDictionary = event;
199+
if ([eventDictionary[@"event"] isEqualToString:@"initialized"]) {
200+
initializationEvent = eventDictionary;
201+
XCTAssertEqual(eventDictionary.count, 4);
202+
}
203+
} else if ([event isKindOfClass:[FlutterError class]]) {
204+
FlutterError *error = event;
205+
XCTFail(@"%@: %@ (%@)", error.code, error.message, error.details);
199206
}
207+
208+
[initializedExpectation fulfill];
200209
}];
201210
[self waitForExpectationsWithTimeout:30.0 handler:nil];
202211

0 commit comments

Comments
 (0)