Unverified Commit 3bc2378a authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove mocks from devfs web, cache, and xcode migrator test (#81475)

parent 13c346c4
......@@ -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<DevelopmentArtifact> artifacts;
FakeCache cache;
setUp(() {
cache = MockCache();
// Release lock between test cases.
cache.releaseLock();
when(cache.isUpToDate()).thenAnswer((Invocation _) => Future<bool>.value(false));
when(cache.updateAll(any)).thenAnswer((Invocation invocation) {
artifacts = invocation.positionalArguments.first as Set<DevelopmentArtifact>;
return Future<void>.value(null);
});
cache = FakeCache();
cache.isUpToDateValue = false;
});
testUsingContext('precache should acquire lock', () async {
......@@ -41,8 +33,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['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 <String>['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 <String>['precache', '--web', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.web,
}));
......@@ -90,7 +79,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--web', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
});
......@@ -104,7 +93,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--macos', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.macOS,
}));
......@@ -119,7 +108,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--macos', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
});
......@@ -133,7 +122,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--windows', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.windows,
}));
......@@ -148,7 +137,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--windows', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
});
......@@ -162,7 +151,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--linux', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.linux,
}));
......@@ -177,7 +166,7 @@ void main() {
);
await createTestCommandRunner(command).run(const <String>['precache', '--linux', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
});
......@@ -222,7 +211,7 @@ void main() {
'--flutter_runner',
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.iOS,
DevelopmentArtifact.androidGenSnapshot,
......@@ -251,7 +240,7 @@ void main() {
'--android',
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.androidGenSnapshot,
DevelopmentArtifact.androidMaven,
......@@ -276,7 +265,7 @@ void main() {
'--android_internal_build',
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.androidGenSnapshot,
DevelopmentArtifact.androidMaven,
......@@ -298,7 +287,7 @@ void main() {
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.iOS,
DevelopmentArtifact.androidGenSnapshot,
......@@ -328,7 +317,7 @@ void main() {
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.iOS,
DevelopmentArtifact.androidGenSnapshot,
......@@ -357,7 +346,7 @@ void main() {
],
);
verify(cache.platformOverrideArtifacts = <String>{});
expect(cache.platformOverrideArtifacts, <String>{});
});
testUsingContext('precache with explicit artifact options overrides platform filtering', () async {
......@@ -385,15 +374,15 @@ void main() {
],
);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
expect(cache.artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.macOS,
}));
verify(cache.platformOverrideArtifacts = <String>{'macos'});
expect(cache.platformOverrideArtifacts, <String>{'macos'});
});
testUsingContext('precache deletes artifact stampfiles when --force is provided', () async {
when(cache.isUpToDate()).thenAnswer((Invocation _) => Future<bool>.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 <String>['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 <String>['precache']);
expect(
artifacts,
cache.artifacts,
unorderedEquals(<DevelopmentArtifact>{
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<DevelopmentArtifact> artifacts;
@override
Future<void> lock() async {
locked = true;
}
@override
void releaseLock() {
locked = false;
}
@override
Future<bool> isUpToDate() async => isUpToDateValue;
@override
Future<void> updateAll(Set<DevelopmentArtifact> requiredArtifacts) async {
artifacts = requiredArtifacts;
}
@override
void clearStampFiles() {
clearedStampFiles = true;
}
@override
Set<String> platformOverrideArtifacts;
@override
bool includeAllPlatforms = false;
}
......@@ -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})
......
......@@ -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(<Package>[
......@@ -46,12 +46,12 @@ void main() {
});
setUp(() {
mockHttpServer = MockHttpServer();
httpServer = FakeHttpServer();
linux = FakePlatform(operatingSystem: 'linux', environment: <String, String>{});
windows = FakePlatform(operatingSystem: 'windows', environment: <String, String>{});
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, <Uri>[]);
});
final ResidentCompiler residentCompiler = FakeResidentCompiler()
..output = const CompilerOutput('a', 0, <Uri>[]);
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, <Uri>[]);
});
final ResidentCompiler residentCompiler = FakeResidentCompiler()
..output = const CompilerOutput('a', 0, <Uri>[]);
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, <Uri>[]);
});
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, <Uri>[]);
});
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, <Uri>[]);
});
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,
<String, String>{},
......@@ -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, <Uri>[]);
});
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<void> close({bool force = false}) async {
closed = true;
}
}
class FakeResidentCompiler extends Fake implements ResidentCompiler {
CompilerOutput output;
@override
void addFileSystemRoot(String root) { }
@override
Future<CompilerOutput> recompile(Uri mainUri, List<Uri> invalidatedFiles, {
String outputPath,
PackageConfig packageConfig,
String projectRootPath,
FileSystem fs,
bool suppressErrors = false,
}) async {
return output;
}
}
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