@@ -840,6 +840,55 @@ void main() {
840840 ]);
841841 });
842842
843+ testWithoutContext ('FlutterWebSdk does not download CanvasKit if it is already in flutter_web_sdk' , () async {
844+ final MemoryFileSystem fileSystem = MemoryFileSystem .test ();
845+ final Directory internalDir = fileSystem.currentDirectory
846+ .childDirectory ('cache' )
847+ .childDirectory ('bin' )
848+ .childDirectory ('internal' );
849+ final File canvasKitVersionFile = internalDir.childFile ('canvaskit.version' );
850+ canvasKitVersionFile.createSync (recursive: true );
851+ canvasKitVersionFile.writeAsStringSync ('abcdefg' );
852+
853+ final File engineVersionFile = internalDir.childFile ('engine.version' );
854+ engineVersionFile.createSync (recursive: true );
855+ engineVersionFile.writeAsStringSync ('hijklmnop' );
856+
857+ final Cache cache = Cache .test (processManager: FakeProcessManager .any (), fileSystem: fileSystem);
858+ final FakeArtifactUpdater artifactUpdater = FakeArtifactUpdater ();
859+ final FlutterWebSdk webSdk = FlutterWebSdk (cache, platform: FakePlatform ());
860+
861+ final List <String > messages = < String > [];
862+ final List <String > downloads = < String > [];
863+ final List <String > locations = < String > [];
864+ artifactUpdater.onDownloadZipArchive = (String message, Uri uri, Directory location) {
865+ messages.add (message);
866+ downloads.add (uri.toString ());
867+ locations.add (location.path);
868+ location.createSync (recursive: true );
869+ location.childDirectory ('canvaskit' ).createSync ();
870+ location.childDirectory ('canvaskit' ).childFile ('canvaskit.js' ).createSync ();
871+ location.childDirectory ('canvaskit' ).childFile ('canvaskit.wasm' ).createSync ();
872+ location.childDirectory ('canvaskit' ).childDirectory ('profiling' ).createSync ();
873+ location.childDirectory ('canvaskit' ).childDirectory ('profiling' ).childFile ('canvaskit.js' ).createSync ();
874+ location.childDirectory ('canvaskit' ).childDirectory ('profiling' ).childFile ('canvaskit.wasm' ).createSync ();
875+ };
876+
877+ await webSdk.updateInner (artifactUpdater, fileSystem, FakeOperatingSystemUtils ());
878+
879+ expect (messages, < String > [
880+ 'Downloading Web SDK...' ,
881+ ]);
882+
883+ expect (downloads, < String > [
884+ 'https://storage.googleapis.com/flutter_infra_release/flutter/hijklmnop/flutter-web-sdk-linux-x64.zip' ,
885+ ]);
886+
887+ expect (locations, < String > [
888+ 'cache/bin/cache/flutter_web_sdk' ,
889+ ]);
890+ });
891+
843892 testWithoutContext ('FlutterWebSdk uses tryToDelete to handle directory edge cases' , () async {
844893 final FileExceptionHandler handler = FileExceptionHandler ();
845894 final MemoryFileSystem fileSystem = MemoryFileSystem .test (opHandle: handler.opHandle);
0 commit comments