From 3bc2378ad2f4afda75a6010db299e733ee2ae0ae Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 30 Apr 2021 17:24:04 -0700 Subject: [PATCH] [flutter_tools] remove mocks from devfs web, cache, and xcode migrator test (#81475) --- .../hermetic/precache_test.dart | 97 ++++++++------ .../ios/ios_project_migration_test.dart | 72 ++++++----- .../general.shard/web/devfs_web_test.dart | 122 ++++++------------ 3 files changed, 141 insertions(+), 150 deletions(-) diff --git a/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart index 835689c5dd6..44a4d1d599f 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/precache.dart'; -import 'package:mockito/mockito.dart'; +import 'package:test/fake.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -16,19 +16,11 @@ import '../../src/fakes.dart'; import '../../src/test_flutter_command_runner.dart'; void main() { - MockCache cache; - Set artifacts; + FakeCache cache; setUp(() { - cache = MockCache(); - // Release lock between test cases. - cache.releaseLock(); - - when(cache.isUpToDate()).thenAnswer((Invocation _) => Future.value(false)); - when(cache.updateAll(any)).thenAnswer((Invocation invocation) { - artifacts = invocation.positionalArguments.first as Set; - return Future.value(null); - }); + cache = FakeCache(); + cache.isUpToDateValue = false; }); testUsingContext('precache should acquire lock', () async { @@ -41,8 +33,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache']); - // Do not throw StateError, lock is acquired. - expect(() => cache.checkLockAcquired(), returnsNormally); + expect(cache.locked, true); }); testUsingContext('precache should not re-entrantly acquire lock', () async { @@ -61,9 +52,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache']); - expect(Cache.isLocked(), isFalse); - // Do not throw StateError, acquired reentrantly with FLUTTER_ALREADY_LOCKED. - expect(() => cache.checkLockAcquired(), returnsNormally); + expect(cache.locked, false); }); testUsingContext('precache downloads web artifacts on dev branch when feature is enabled.', () async { @@ -75,7 +64,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--web', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.web, })); @@ -90,7 +79,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--web', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, })); }); @@ -104,7 +93,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--macos', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.macOS, })); @@ -119,7 +108,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--macos', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, })); }); @@ -133,7 +122,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--windows', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.windows, })); @@ -148,7 +137,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--windows', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, })); }); @@ -162,7 +151,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--linux', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.linux, })); @@ -177,7 +166,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--linux', '--no-android', '--no-ios']); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, })); }); @@ -222,7 +211,7 @@ void main() { '--flutter_runner', ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.iOS, DevelopmentArtifact.androidGenSnapshot, @@ -251,7 +240,7 @@ void main() { '--android', ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.androidGenSnapshot, DevelopmentArtifact.androidMaven, @@ -276,7 +265,7 @@ void main() { '--android_internal_build', ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.androidGenSnapshot, DevelopmentArtifact.androidMaven, @@ -298,7 +287,7 @@ void main() { ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.iOS, DevelopmentArtifact.androidGenSnapshot, @@ -328,7 +317,7 @@ void main() { ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.iOS, DevelopmentArtifact.androidGenSnapshot, @@ -357,7 +346,7 @@ void main() { ], ); - verify(cache.platformOverrideArtifacts = {}); + expect(cache.platformOverrideArtifacts, {}); }); testUsingContext('precache with explicit artifact options overrides platform filtering', () async { @@ -385,15 +374,15 @@ void main() { ], ); - expect(artifacts, unorderedEquals({ + expect(cache.artifacts, unorderedEquals({ DevelopmentArtifact.universal, DevelopmentArtifact.macOS, })); - verify(cache.platformOverrideArtifacts = {'macos'}); + expect(cache.platformOverrideArtifacts, {'macos'}); }); testUsingContext('precache deletes artifact stampfiles when --force is provided', () async { - when(cache.isUpToDate()).thenAnswer((Invocation _) => Future.value(true)); + cache.isUpToDateValue = true; final PrecacheCommand command = PrecacheCommand( cache: cache, logger: BufferLogger.test(), @@ -404,7 +393,7 @@ void main() { ); await createTestCommandRunner(command).run(const ['precache', '--force']); - verify(cache.clearStampFiles()).called(1); + expect(cache.clearedStampFiles, true); }); testUsingContext('precache downloads all enabled platforms if no flags are provided.', () async { @@ -424,7 +413,7 @@ void main() { await createTestCommandRunner(command).run(const ['precache']); expect( - artifacts, + cache.artifacts, unorderedEquals({ DevelopmentArtifact.web, DevelopmentArtifact.macOS, @@ -436,4 +425,38 @@ void main() { }); } -class MockCache extends Mock implements Cache {} +class FakeCache extends Fake implements Cache { + bool isUpToDateValue = false; + bool clearedStampFiles = false; + bool locked = false; + Set artifacts; + + @override + Future lock() async { + locked = true; + } + + @override + void releaseLock() { + locked = false; + } + + @override + Future isUpToDate() async => isUpToDateValue; + + @override + Future updateAll(Set requiredArtifacts) async { + artifacts = requiredArtifacts; + } + + @override + void clearStampFiles() { + clearedStampFiles = true; + } + + @override + Set platformOverrideArtifacts; + + @override + bool includeAllPlatforms = false; +} diff --git a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart index 36bee25f634..4806869a875 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_project_migration_test.dart @@ -15,13 +15,14 @@ import 'package:flutter_tools/src/ios/migrations/xcode_build_system_migration.da import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:meta/meta.dart'; -import 'package:mockito/mockito.dart'; +import 'package:test/fake.dart'; import '../../src/common.dart'; void main () { group('iOS migration', () { TestUsage testUsage; + setUp(() { testUsage = TestUsage(); }); @@ -41,20 +42,20 @@ void main () { group('remove framework linking and embedding migration', () { MemoryFileSystem memoryFileSystem; BufferLogger testLogger; - MockIosProject mockIosProject; + FakeIosProject project; File xcodeProjectInfoFile; setUp(() { memoryFileSystem = MemoryFileSystem.test(); xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); testLogger = BufferLogger.test(); - mockIosProject = MockIosProject(); - when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile); + project = FakeIosProject(); + project.xcodeProjectInfoFile = xcodeProjectInfoFile; }); testWithoutContext('skipped if files are missing', () { final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage ); @@ -73,7 +74,7 @@ void main () { final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync(); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -93,7 +94,7 @@ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend. xcodeProjectInfoFile.writeAsStringSync(contents); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -120,7 +121,7 @@ keep this 2 '''); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -141,7 +142,7 @@ keep this 2 '''); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -158,7 +159,7 @@ keep this 2 '''); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -174,7 +175,7 @@ keep this 2 '''); final RemoveFrameworkLinkAndEmbeddingMigration iosProjectMigration = RemoveFrameworkLinkAndEmbeddingMigration( - mockIosProject, + project, testLogger, testUsage, ); @@ -188,20 +189,20 @@ keep this 2 group('new Xcode build system', () { MemoryFileSystem memoryFileSystem; BufferLogger testLogger; - MockIosProject mockIosProject; + FakeIosProject project; File xcodeWorkspaceSharedSettings; setUp(() { memoryFileSystem = MemoryFileSystem.test(); xcodeWorkspaceSharedSettings = memoryFileSystem.file('WorkspaceSettings.xcsettings'); testLogger = BufferLogger.test(); - mockIosProject = MockIosProject(); - when(mockIosProject.xcodeWorkspaceSharedSettings).thenReturn(xcodeWorkspaceSharedSettings); + project = FakeIosProject(); + project.xcodeWorkspaceSharedSettings = xcodeWorkspaceSharedSettings; }); testWithoutContext('skipped if files are missing', () { final XcodeBuildSystemMigration iosProjectMigration = XcodeBuildSystemMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -224,7 +225,7 @@ keep this 2 xcodeWorkspaceSharedSettings.writeAsStringSync(contents); final XcodeBuildSystemMigration iosProjectMigration = XcodeBuildSystemMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -247,7 +248,7 @@ keep this 2 xcodeWorkspaceSharedSettings.writeAsStringSync(contents); final XcodeBuildSystemMigration iosProjectMigration = XcodeBuildSystemMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -260,20 +261,20 @@ keep this 2 group('Xcode default build location', () { MemoryFileSystem memoryFileSystem; BufferLogger testLogger; - MockIosProject mockIosProject; + FakeIosProject project; File xcodeProjectWorkspaceData; setUp(() { memoryFileSystem = MemoryFileSystem(); xcodeProjectWorkspaceData = memoryFileSystem.file('contents.xcworkspacedata'); testLogger = BufferLogger.test(); - mockIosProject = MockIosProject(); - when(mockIosProject.xcodeProjectWorkspaceData).thenReturn(xcodeProjectWorkspaceData); + project = FakeIosProject(); + project.xcodeProjectWorkspaceData = xcodeProjectWorkspaceData; }); testWithoutContext('skipped if files are missing', () { final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -295,7 +296,7 @@ keep this 2 xcodeProjectWorkspaceData.writeAsStringSync(contents); final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -319,7 +320,7 @@ keep this 2 xcodeProjectWorkspaceData.writeAsStringSync(contents); final ProjectBuildLocationMigration iosProjectMigration = ProjectBuildLocationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -339,20 +340,20 @@ keep this 2 group('remove Runner project base configuration', () { MemoryFileSystem memoryFileSystem; BufferLogger testLogger; - MockIosProject mockIosProject; + FakeIosProject project; File xcodeProjectInfoFile; setUp(() { memoryFileSystem = MemoryFileSystem(); xcodeProjectInfoFile = memoryFileSystem.file('project.pbxproj'); testLogger = BufferLogger.test(); - mockIosProject = MockIosProject(); - when(mockIosProject.xcodeProjectInfoFile).thenReturn(xcodeProjectInfoFile); + project = FakeIosProject(); + project.xcodeProjectInfoFile = xcodeProjectInfoFile; }); testWithoutContext('skipped if files are missing', () { final ProjectBaseConfigurationMigration iosProjectMigration = ProjectBaseConfigurationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -368,7 +369,7 @@ keep this 2 final DateTime projectLastModified = xcodeProjectInfoFile.lastModifiedSync(); final ProjectBaseConfigurationMigration iosProjectMigration = ProjectBaseConfigurationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -396,7 +397,7 @@ keep this 3 '''); final ProjectBaseConfigurationMigration iosProjectMigration = ProjectBaseConfigurationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -451,7 +452,7 @@ keep this 3 '''); final ProjectBaseConfigurationMigration iosProjectMigration = ProjectBaseConfigurationMigration( - mockIosProject, + project, testLogger, ); expect(iosProjectMigration.migrate(), isTrue); @@ -492,7 +493,16 @@ keep this 3 }); } -class MockIosProject extends Mock implements IosProject {} +class FakeIosProject extends Fake implements IosProject { + @override + File xcodeProjectWorkspaceData; + + @override + File xcodeWorkspaceSharedSettings; + + @override + File xcodeProjectInfoFile; +} class FakeIOSMigrator extends ProjectMigrator { FakeIOSMigrator({@required this.succeeds}) diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart index 38099c960b5..128921d1b37 100644 --- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart @@ -15,9 +15,9 @@ import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/isolated/devfs_web.dart'; import 'package:flutter_tools/src/web/compile.dart'; -import 'package:mockito/mockito.dart'; import 'package:package_config/package_config.dart'; import 'package:shelf/shelf.dart'; +import 'package:test/fake.dart'; import '../../src/common.dart'; import '../../src/testbed.dart'; @@ -37,7 +37,7 @@ void main() { Platform linux; PackageConfig packages; Platform windows; - MockHttpServer mockHttpServer; + FakeHttpServer httpServer; setUpAll(() async { packages = PackageConfig([ @@ -46,12 +46,12 @@ void main() { }); setUp(() { - mockHttpServer = MockHttpServer(); + httpServer = FakeHttpServer(); linux = FakePlatform(operatingSystem: 'linux', environment: {}); windows = FakePlatform(operatingSystem: 'windows', environment: {}); testbed = Testbed(setup: () { webAssetServer = WebAssetServer( - mockHttpServer, + httpServer, packages, InternetAddress.loopbackIPv4, null, @@ -232,7 +232,7 @@ void main() { webDir.childFile('index.html').writeAsStringSync(htmlContent); final WebAssetServer webAssetServer = WebAssetServer( - mockHttpServer, + httpServer, packages, InternetAddress.loopbackIPv4, null, @@ -251,7 +251,7 @@ void main() { webDir.childFile('index.html').writeAsStringSync(htmlContent); final WebAssetServer webAssetServer = WebAssetServer( - mockHttpServer, + httpServer, packages, InternetAddress.loopbackIPv4, null, @@ -272,7 +272,7 @@ void main() { expect( () => WebAssetServer( - mockHttpServer, + httpServer, packages, InternetAddress.loopbackIPv4, null, @@ -292,7 +292,7 @@ void main() { expect( () => WebAssetServer( - mockHttpServer, + httpServer, packages, InternetAddress.loopbackIPv4, null, @@ -588,7 +588,7 @@ void main() { test('calling dispose closes the http server', () => testbed.run(() async { await webAssetServer.dispose(); - verify(mockHttpServer.close()).called(1); + expect(httpServer.closed, true); })); test('Can start web server with specified assets', () => testbed.run(() async { @@ -599,17 +599,8 @@ void main() { outputFile.parent.childFile('a.map').writeAsStringSync('{}'); outputFile.parent.childFile('a.metadata').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); + final ResidentCompiler residentCompiler = FakeResidentCompiler() + ..output = const CompilerOutput('a', 0, []); final WebDevFS webDevFS = WebDevFS( hostname: 'localhost', @@ -719,17 +710,8 @@ void main() { outputFile.parent.childFile('a.map').writeAsStringSync('{}'); outputFile.parent.childFile('a.metadata').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); + final ResidentCompiler residentCompiler = FakeResidentCompiler() + ..output = const CompilerOutput('a', 0, []); final WebDevFS webDevFS = WebDevFS( hostname: 'localhost', @@ -836,18 +818,6 @@ void main() { outputFile.parent.childFile('a.json').writeAsStringSync('{}'); outputFile.parent.childFile('a.map').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); - final WebDevFS webDevFS = WebDevFS( hostname: 'any', port: 0, @@ -883,18 +853,6 @@ void main() { outputFile.parent.childFile('a.json').writeAsStringSync('{}'); outputFile.parent.childFile('a.map').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); - final WebDevFS webDevFS = WebDevFS( hostname: 'localhost', port: 0, @@ -938,18 +896,6 @@ void main() { outputFile.parent.childFile('a.json').writeAsStringSync('{}'); outputFile.parent.childFile('a.map').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); - final WebDevFS webDevFS = WebDevFS( hostname: 'localhost', port: 0, @@ -1033,7 +979,7 @@ void main() { ..createSync(recursive: true) ..writeAsStringSync(htmlContent); final WebAssetServer webAssetServer = WebAssetServer( - MockHttpServer(), + FakeHttpServer(), PackageConfig.empty, InternetAddress.anyIPv4, {}, @@ -1060,18 +1006,6 @@ void main() { outputFile.parent.childFile('a.map').writeAsStringSync('{}'); outputFile.parent.childFile('a.metadata').writeAsStringSync('{}'); - final ResidentCompiler residentCompiler = MockResidentCompiler(); - when(residentCompiler.recompile( - any, - any, - outputPath: anyNamed('outputPath'), - packageConfig: anyNamed('packageConfig'), - projectRootPath: anyNamed('projectRootPath'), - fs: anyNamed('fs'), - )).thenAnswer((Invocation invocation) async { - return const CompilerOutput('a', 0, []); - }); - final WebDevFS webDevFS = WebDevFS( hostname: 'localhost', port: 0, @@ -1107,5 +1041,29 @@ void main() { })); } -class MockHttpServer extends Mock implements HttpServer {} -class MockResidentCompiler extends Mock implements ResidentCompiler {} +class FakeHttpServer extends Fake implements HttpServer { + bool closed = false; + + @override + Future close({bool force = false}) async { + closed = true; + } +} + +class FakeResidentCompiler extends Fake implements ResidentCompiler { + CompilerOutput output; + + @override + void addFileSystemRoot(String root) { } + + @override + Future recompile(Uri mainUri, List invalidatedFiles, { + String outputPath, + PackageConfig packageConfig, + String projectRootPath, + FileSystem fs, + bool suppressErrors = false, + }) async { + return output; + } +}