Unverified Commit f62da010 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] ensure setAssetDirectory uses windows path (#109021)

parent b02f68a6
...@@ -1047,6 +1047,7 @@ class HotRunner extends ResidentRunner { ...@@ -1047,6 +1047,7 @@ class HotRunner extends ResidentRunner {
assetsDirectory: deviceAssetsDirectoryUri, assetsDirectory: deviceAssetsDirectoryUri,
uiIsolateId: view.uiIsolate!.id, uiIsolateId: view.uiIsolate!.id,
viewId: view.id, viewId: view.id,
windows: device.targetPlatform == TargetPlatform.windows_x64,
) )
)); ));
for (final FlutterView view in views) { for (final FlutterView view in views) {
......
...@@ -478,12 +478,13 @@ class FlutterVmService { ...@@ -478,12 +478,13 @@ class FlutterVmService {
required Uri assetsDirectory, required Uri assetsDirectory,
required String? viewId, required String? viewId,
required String? uiIsolateId, required String? uiIsolateId,
required bool windows,
}) async { }) async {
await callMethodWrapper(kSetAssetBundlePathMethod, await callMethodWrapper(kSetAssetBundlePathMethod,
isolateId: uiIsolateId, isolateId: uiIsolateId,
args: <String, Object?>{ args: <String, Object?>{
'viewId': viewId, 'viewId': viewId,
'assetDirectory': assetsDirectory.toFilePath(windows: false), 'assetDirectory': assetsDirectory.toFilePath(windows: windows),
}); });
} }
......
...@@ -214,6 +214,7 @@ void main() { ...@@ -214,6 +214,7 @@ void main() {
assetsDirectory: Uri(path: 'abc', scheme: 'file'), assetsDirectory: Uri(path: 'abc', scheme: 'file'),
viewId: 'abc', viewId: 'abc',
uiIsolateId: 'def', uiIsolateId: 'def',
windows: false,
)); ));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>; final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
...@@ -228,6 +229,34 @@ void main() { ...@@ -228,6 +229,34 @@ void main() {
])); ]));
}); });
testWithoutContext('setAssetDirectory forwards arguments correctly - windows', () async {
final Completer<String> completer = Completer<String>();
final vm_service.VmService vmService = vm_service.VmService(
const Stream<String>.empty(),
completer.complete,
);
final FlutterVmService flutterVmService = FlutterVmService(vmService);
unawaited(flutterVmService.setAssetDirectory(
assetsDirectory: Uri(path: 'C:/Users/Tester/AppData/Local/Temp/hello_worldb42a6da5/hello_world/build/flutter_assets', scheme: 'file'),
viewId: 'abc',
uiIsolateId: 'def',
// If windows is not set to `true`, then the file path below is incorrectly prepended with a `/` which
// causes the engine asset manager to interpret the file scheme as invalid.
windows: true,
));
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
expect(rawRequest, allOf(<Matcher>[
containsPair('method', kSetAssetBundlePathMethod),
containsPair('params', allOf(<Matcher>[
containsPair('viewId', 'abc'),
containsPair('assetDirectory', r'C:\Users\Tester\AppData\Local\Temp\hello_worldb42a6da5\hello_world\build\flutter_assets'),
containsPair('isolateId', 'def'),
])),
]));
});
testWithoutContext('getSkSLs forwards arguments correctly', () async { testWithoutContext('getSkSLs forwards arguments correctly', () async {
final Completer<String> completer = Completer<String>(); final Completer<String> completer = Completer<String>();
final vm_service.VmService vmService = vm_service.VmService( final vm_service.VmService vmService = vm_service.VmService(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment