mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Support route on ios engine (flutter/engine#31555)
This commit is contained in:
parent
35f59675e2
commit
a9dc88faa7
@ -107,6 +107,8 @@ struct Settings {
|
||||
std::string isolate_snapshot_instr_path; // deprecated
|
||||
MappingCallback isolate_snapshot_instr;
|
||||
|
||||
std::string route;
|
||||
|
||||
// Returns the Mapping to a kernel buffer which contains sources for dart:*
|
||||
// libraries.
|
||||
MappingCallback dart_library_sources_kernel;
|
||||
|
||||
@ -356,6 +356,8 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
|
||||
command_line.GetOptionValue(FlagForSwitch(Switch::VmSnapshotData),
|
||||
&vm_snapshot_data_filename);
|
||||
|
||||
command_line.GetOptionValue(FlagForSwitch(Switch::Route), &settings.route);
|
||||
|
||||
std::string vm_snapshot_instr_filename;
|
||||
command_line.GetOptionValue(FlagForSwitch(Switch::VmSnapshotInstructions),
|
||||
&vm_snapshot_instr_filename);
|
||||
|
||||
@ -105,6 +105,9 @@ DEF_SWITCH(EnableSoftwareRendering,
|
||||
"Enable rendering using the Skia software backend. This is useful "
|
||||
"when testing Flutter on emulators. By default, Flutter will "
|
||||
"attempt to either use OpenGL, Metal, or Vulkan.")
|
||||
DEF_SWITCH(Route,
|
||||
"route",
|
||||
"Start app with an specific route defined on the framework")
|
||||
DEF_SWITCH(SkiaDeterministicRendering,
|
||||
"skia-deterministic-rendering",
|
||||
"Skips the call to SkGraphics::Init(), thus avoiding swapping out "
|
||||
|
||||
@ -46,5 +46,15 @@ TEST(SwitchesTest, SkiaTraceAllowlistFlag) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(SwitchesTest, RouteParsedFlag) {
|
||||
fml::CommandLine command_line =
|
||||
fml::CommandLineFromInitializerList({"command", "--route=/animation"});
|
||||
Settings settings = SettingsFromCommandLine(command_line);
|
||||
EXPECT_EQ(settings.route, "/animation");
|
||||
command_line = fml::CommandLineFromInitializerList({"command", "--route"});
|
||||
settings = SettingsFromCommandLine(command_line);
|
||||
EXPECT_TRUE(settings.route.empty());
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
@ -695,6 +695,13 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
|
||||
self.initialRoute = initialRoute;
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
FlutterView.forceSoftwareRendering = settings.enable_software_rendering;
|
||||
|
||||
auto platformData = [_dartProject.get() defaultPlatformData];
|
||||
|
||||
@ -159,6 +159,26 @@ FLUTTER_ASSERT_ARC
|
||||
message:encodedSetInitialRouteMethod]);
|
||||
}
|
||||
|
||||
- (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]);
|
||||
}
|
||||
|
||||
- (void)testPlatformViewsControllerRenderingMetalBackend {
|
||||
FlutterEngine* engine = [[FlutterEngine alloc] init];
|
||||
[engine run];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user