37 {
38 self.flutterViewController =
40 initialRoute:@"myCustomInitialRoute"
41 nibName:nil
42 bundle:nil];
43
44 NSObject<FlutterBinaryMessenger>* binaryMessenger = self.flutterViewController.binaryMessenger;
45 __weak typeof(binaryMessenger) weakBinaryMessenger = binaryMessenger;
46
48 setMessageHandlerOnChannel:@"waiting_for_status"
49 binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
54 [channel invokeMethod:@"set_scenario" arguments:@{@"name" : @"initial_route_reply"}];
55 }];
56
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
63 options:0
64 error:nil];
65 NSString* initialRoute = dict[@"method"];
66 if ([initialRoute isEqualToString:@"myCustomInitialRoute"]) {
67 [customInitialRouteSet fulfill];
68 } else {
69 XCTFail(@"Expected initial route to be set to "
70 @"myCustomInitialRoute. Was set to %@ instead",
71 initialRoute);
72 }
73 }];
74
76 UIViewController* rootVC = appDelegate.
window.rootViewController;
77 [rootVC presentViewController:self.flutterViewController animated:NO completion:nil];
78
79 [self waitForExpectationsWithTimeout:30.0 handler:nil];
80
81 [binaryMessenger cleanUpConnection:waitingForStatusConnection];
82 [binaryMessenger cleanUpConnection:initialRoutTestChannelConnection];
83}
int64_t FlutterBinaryMessengerConnection
instancetype sharedInstance()
instancetype methodChannelWithName:binaryMessenger:codec:(NSString *name,[binaryMessenger] NSObject< FlutterBinaryMessenger > *messenger,[codec] NSObject< FlutterMethodCodec > *codec)