-
Notifications
You must be signed in to change notification settings - Fork 6k
Support route on ios engine #31555
Support route on ios engine #31555
Conversation
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a test for the FlutterEngine logic change. This test passed on your PR, you can put it right after
| - (void)testRunningInitialRouteSendsNavigationMessage { |
- (void)testInitialRouteSettingsSendsNavigationMessage {
id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
auto settings = FLTDefaultSettingsForBundle();
settings.route = "test";
FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings];
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
[engine setBinaryMessenger:mockBinaryMessenger];
[engine run];
// Now check that an encoded method call has been made on the binary messenger to set the
// initial route to "test".
FlutterMethodCall* setInitialRouteMethodCall =
[FlutterMethodCall methodCallWithMethodName:@"setInitialRoute" arguments:@"test"];
NSData* encodedSetInitialRouteMethod =
[[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:setInitialRouteMethodCall];
OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/navigation"
message:encodedSetInitialRouteMethod]);
}| self.initialRoute = initialRoute; | ||
|
|
||
| auto settings = [_dartProject.get() settings]; | ||
| if (settings.route.empty() == false) { | ||
| self.initialRoute = [NSString stringWithCString:settings.route.c_str() | ||
| encoding:[NSString defaultCStringEncoding]]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think defaultCStringEncoding usage is discouraged, let's just accept utf8 here.
Also, don't set the initialRoute twice.
| self.initialRoute = initialRoute; | |
| auto settings = [_dartProject.get() settings]; | |
| if (settings.route.empty() == false) { | |
| self.initialRoute = [NSString stringWithCString:settings.route.c_str() | |
| encoding:[NSString defaultCStringEncoding]]; | |
| } | |
| auto settings = [_dartProject.get() settings]; | |
| if (initialRoute != nil) { | |
| self.initialRoute = initialRoute; | |
| } else if (settings.route.empty() == false) { | |
| self.initialRoute = [NSString stringWithCString:settings.route.c_str() | |
| encoding:NSUTF8StringEncoding]; | |
| } |
jmagman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for tracking this down I know it was trickier than it looks!
Thank you for all your help! |
Issue: flutter/flutter#4703
Framework PR: flutter/flutter#99078
Pre-launch Checklist
writing and running engine tests.
///).