mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[flutter_tools] ensure setAssetDirectory uses windows path (#109021)
This commit is contained in:
parent
b02f68a66c
commit
f62da01068
@ -1047,6 +1047,7 @@ class HotRunner extends ResidentRunner {
|
||||
assetsDirectory: deviceAssetsDirectoryUri,
|
||||
uiIsolateId: view.uiIsolate!.id,
|
||||
viewId: view.id,
|
||||
windows: device.targetPlatform == TargetPlatform.windows_x64,
|
||||
)
|
||||
));
|
||||
for (final FlutterView view in views) {
|
||||
|
||||
@ -478,12 +478,13 @@ class FlutterVmService {
|
||||
required Uri assetsDirectory,
|
||||
required String? viewId,
|
||||
required String? uiIsolateId,
|
||||
required bool windows,
|
||||
}) async {
|
||||
await callMethodWrapper(kSetAssetBundlePathMethod,
|
||||
isolateId: uiIsolateId,
|
||||
args: <String, Object?>{
|
||||
'viewId': viewId,
|
||||
'assetDirectory': assetsDirectory.toFilePath(windows: false),
|
||||
'assetDirectory': assetsDirectory.toFilePath(windows: windows),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +214,7 @@ void main() {
|
||||
assetsDirectory: Uri(path: 'abc', scheme: 'file'),
|
||||
viewId: 'abc',
|
||||
uiIsolateId: 'def',
|
||||
windows: false,
|
||||
));
|
||||
|
||||
final Map<String, Object> rawRequest = json.decode(await completer.future) as Map<String, Object>;
|
||||
@ -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 {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
final vm_service.VmService vmService = vm_service.VmService(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user