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

[flutter_tools] support starting in canvaskit with FLUTTER_WEB_USE_SKIA=true (#60708)

parent 2f43aeaf
......@@ -660,6 +660,9 @@ class WebDevFS implements DevFS {
expressionCompiler,
testMode: testMode,
);
if (buildInfo.dartDefines.contains('FLUTTER_WEB_USE_SKIA=true')) {
webAssetServer.canvasKitRendering = true;
}
if (hostname == 'any') {
_baseUri = Uri.http('localhost:$port', '');
} else {
......
......@@ -486,7 +486,9 @@ void main() {
expect(await webDevFS.webAssetServer.dartSourceContents('dart_sdk.js'), 'BELLOW');
// Toggle CanvasKit
expect(webDevFS.webAssetServer.canvasKitRendering, false);
webDevFS.webAssetServer.canvasKitRendering = true;
expect(await webDevFS.webAssetServer.dartSourceContents('dart_sdk.js'), 'OL');
expect(await webDevFS.webAssetServer.dartSourceContents('dart_sdk.js.map'), 'CHUM');
......@@ -650,6 +652,55 @@ void main() {
expect(uri, Uri.http('localhost:0', ''));
await webDevFS.destroy();
}));
test('Can start web server with canvaskit enabled', () => testbed.run(() async {
globals.fs.file('.packages').writeAsStringSync('\n');
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
..createSync(recursive: true);
outputFile.parent.childFile('a.sources').writeAsStringSync('');
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
final ResidentCompiler residentCompiler = MockResidentCompiler();
when(residentCompiler.recompile(
any,
any,
outputPath: anyNamed('outputPath'),
packageConfig: anyNamed('packageConfig'),
)).thenAnswer((Invocation invocation) async {
return const CompilerOutput('a', 0, <Uri>[]);
});
final WebDevFS webDevFS = WebDevFS(
hostname: 'localhost',
port: 0,
packagesFilePath: '.packages',
urlTunneller: null,
useSseForDebugProxy: true,
buildInfo: const BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
dartDefines: <String>[
'FLUTTER_WEB_USE_SKIA=true',
]
),
enableDwds: false,
entrypoint: Uri.base,
testMode: true,
expressionCompiler: null,
chromiumLauncher: null,
);
webDevFS.requireJS.createSync(recursive: true);
webDevFS.stackTraceMapper.createSync(recursive: true);
await webDevFS.create();
expect(webDevFS.webAssetServer.canvasKitRendering, true);
await webDevFS.destroy();
}));
}
class MockHttpServer extends Mock implements HttpServer {}
......
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