5#import <Flutter/Flutter.h>
6#import <XCTest/XCTest.h>
22 self.continueAfterFailure = NO;
27 XCTestExpectation* vcDismissed = [
self expectationWithDescription:@"dismiss"];
28 [
self.flutterViewController dismissViewControllerAnimated:NO
30 [vcDismissed fulfill];
32 [
self waitForExpectationsWithTimeout:10.0 handler:nil];
38 self.flutterViewController =
40 initialRoute:@"myCustomInitialRoute"
44 NSObject<FlutterBinaryMessenger>* binaryMessenger =
self.flutterViewController.binaryMessenger;
45 __weak typeof(binaryMessenger) weakBinaryMessenger = binaryMessenger;
48 setMessageHandlerOnChannel:@"waiting_for_status"
49 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
54 [channel invokeMethod:@"set_scenario" arguments:@{@"name" : @"initial_route_reply"}];
57 XCTestExpectation* customInitialRouteSet =
58 [
self expectationWithDescription:@"Custom initial route was set on the Dart side"];
60 [binaryMessenger setMessageHandlerOnChannel:@"initial_route_test_channel"
61 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
62 NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:message
65 NSString* initialRoute = dict[@"method"];
66 if ([initialRoute isEqualToString:@"myCustomInitialRoute"]) {
67 [customInitialRouteSet fulfill];
69 XCTFail(@"Expected initial route to be set to "
70 @"myCustomInitialRoute. Was set to %@ instead",
76 UIViewController* rootVC = appDelegate.
window.rootViewController;
77 [rootVC presentViewController:
self.flutterViewController animated:NO completion:nil];
79 [
self waitForExpectationsWithTimeout:30.0 handler:nil];
81 [binaryMessenger cleanUpConnection:waitingForStatusConnection];
82 [binaryMessenger cleanUpConnection:initialRoutTestChannelConnection];
int64_t FlutterBinaryMessengerConnection
instancetype sharedInstance()
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)
FlutterViewController * flutterViewController
void testSettingInitialRoute()