Reland the Dart plugin registry (#79669)
This commit is contained in:
@@ -38,6 +38,7 @@ void main() {
|
||||
processManager: globals.processManager,
|
||||
platform: FakePlatform(),
|
||||
engineVersion: 'invalidEngineVersion',
|
||||
generateDartPluginRegistry: false,
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/common.dart';
|
||||
import 'package:flutter_tools/src/build_system/targets/dart_plugin_registrant.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
|
||||
import '../../../src/common.dart';
|
||||
import '../../../src/context.dart';
|
||||
|
||||
const String _kEmptyPubspecFile = '''
|
||||
name: app_without_plugins
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
''';
|
||||
|
||||
const String _kEmptyPackageJson = '''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
]
|
||||
}
|
||||
''';
|
||||
|
||||
const String _kSamplePackageJson = '''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "path_provider_linux",
|
||||
"rootUri": "/path_provider_linux",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "path_provider_example",
|
||||
"rootUri": "../",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
''';
|
||||
|
||||
const String _kSamplePackagesFile = '''
|
||||
path_provider_linux:/path_provider_linux/lib/
|
||||
path_provider_example:lib/
|
||||
''';
|
||||
|
||||
const String _kSamplePubspecFile = '''
|
||||
name: path_provider_example
|
||||
description: Demonstrates how to use the path_provider plugin.
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
path_provider_linux: 1.0.0
|
||||
''';
|
||||
|
||||
const String _kLinuxRegistrant =
|
||||
'//\n'
|
||||
'// Generated file. Do not edit.\n'
|
||||
'// This file is generated from template in file `flutter_tools/lib/src/flutter_plugins.dart`.\n'
|
||||
'//\n'
|
||||
'\n'
|
||||
'// @dart = 2.12\n'
|
||||
'\n'
|
||||
'import \'package:path_provider_example/main.dart\' as entrypoint;\n'
|
||||
'import \'dart:io\'; // flutter_ignore: dart_io_import.\n'
|
||||
'import \'package:path_provider_linux/path_provider_linux.dart\';\n'
|
||||
'\n'
|
||||
'@pragma(\'vm:entry-point\')\n'
|
||||
'class _PluginRegistrant {\n'
|
||||
'\n'
|
||||
' @pragma(\'vm:entry-point\')\n'
|
||||
' static void register() {\n'
|
||||
' if (Platform.isLinux) {\n'
|
||||
' try {\n'
|
||||
' PathProviderLinux.registerWith();\n'
|
||||
' } catch (err) {\n'
|
||||
' print(\n'
|
||||
' \'`path_provider_linux` threw an error: \$err. \'\n'
|
||||
' \'The app may not function as expected until you remove this plugin from pubspec.yaml\'\n'
|
||||
' );\n'
|
||||
' rethrow;\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
' } else if (Platform.isMacOS) {\n'
|
||||
' } else if (Platform.isWindows) {\n'
|
||||
' }\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
'}\n'
|
||||
'\n'
|
||||
'typedef _UnaryFunction = dynamic Function(List<String> args);\n'
|
||||
'typedef _NullaryFunction = dynamic Function();\n'
|
||||
'\n'
|
||||
'void main(List<String> args) {\n'
|
||||
' if (entrypoint.main is _UnaryFunction) {\n'
|
||||
' (entrypoint.main as _UnaryFunction)(args);\n'
|
||||
' } else {\n'
|
||||
' (entrypoint.main as _NullaryFunction)();\n'
|
||||
' }\n'
|
||||
'}\n'
|
||||
'';
|
||||
|
||||
const String _kSamplePluginPubspec = '''
|
||||
name: path_provider_linux
|
||||
description: linux implementation of the path_provider plugin
|
||||
// version: 2.0.1
|
||||
// homepage: https://github.com/flutter/plugins/tree/master/packages/path_provider/path_provider_linux
|
||||
|
||||
flutter:
|
||||
plugin:
|
||||
implements: path_provider
|
||||
platforms:
|
||||
linux:
|
||||
dartPluginClass: PathProviderLinux
|
||||
pluginClass: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0-259.9.beta <3.0.0"
|
||||
flutter: ">=1.20.0"
|
||||
''';
|
||||
|
||||
void main() {
|
||||
|
||||
group('Dart plugin registrant' , () {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
|
||||
testWithoutContext('skipped based on environment.generateDartPluginRegistry',
|
||||
() async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
artifacts: null,
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
generateDartPluginRegistry: false);
|
||||
|
||||
expect(const DartPluginRegistrantTarget().canSkip(environment), true);
|
||||
|
||||
final Environment environment2 = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
artifacts: null,
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
generateDartPluginRegistry: true);
|
||||
|
||||
expect(const DartPluginRegistrantTarget().canSkip(environment2), false);
|
||||
});
|
||||
|
||||
testUsingContext("doesn't generate generated_main.dart if there aren't Dart plugins", () async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
projectDir: fileSystem.directory('project')..createSync(),
|
||||
artifacts: null,
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
generateDartPluginRegistry: true);
|
||||
|
||||
final File config = environment.projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
config.createSync(recursive: true);
|
||||
config.writeAsStringSync(_kSamplePackageJson);
|
||||
|
||||
final File pubspec = environment.projectDir.childFile('pubspec.yaml');
|
||||
pubspec.createSync();
|
||||
|
||||
final File packages = environment.projectDir.childFile('.packages');
|
||||
packages.createSync();
|
||||
|
||||
final File generatedMain = environment.projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childDirectory('flutter_build')
|
||||
.childFile('generated_main.dart');
|
||||
|
||||
final FlutterProject testProject = FlutterProject.fromDirectoryTest(environment.projectDir);
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
|
||||
expect(generatedMain.existsSync(), isFalse);
|
||||
});
|
||||
|
||||
testUsingContext('regenerates generated_main.dart', () async {
|
||||
final Directory projectDir = fileSystem.directory('project')..createSync();
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
projectDir: projectDir,
|
||||
artifacts: null,
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
defines: <String, String>{
|
||||
kTargetFile: projectDir.childDirectory('lib').childFile('main.dart').absolute.path,
|
||||
},
|
||||
generateDartPluginRegistry: true);
|
||||
|
||||
final File config = projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
config.createSync(recursive: true);
|
||||
config.writeAsStringSync(_kSamplePackageJson);
|
||||
|
||||
final File pubspec = projectDir.childFile('pubspec.yaml');
|
||||
pubspec.createSync();
|
||||
pubspec.writeAsStringSync(_kSamplePubspecFile);
|
||||
|
||||
final File packages = projectDir.childFile('.packages');
|
||||
packages.createSync();
|
||||
packages.writeAsStringSync(_kSamplePackagesFile);
|
||||
|
||||
final File generatedMain = projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childDirectory('flutter_build')
|
||||
.childFile('generated_main.dart');
|
||||
generatedMain.createSync(recursive: true);
|
||||
|
||||
final File mainEntrypoint = projectDir.childDirectory('lib').childFile('main.dart');
|
||||
mainEntrypoint.createSync(recursive: true);
|
||||
|
||||
final File pluginPubspec = environment.fileSystem.currentDirectory.childDirectory('path_provider_linux').childFile('pubspec.yaml');
|
||||
pluginPubspec.createSync(recursive: true);
|
||||
pluginPubspec.writeAsStringSync(_kSamplePluginPubspec);
|
||||
|
||||
final FlutterProject testProject = FlutterProject.fromDirectoryTest(environment.projectDir);
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
|
||||
final String mainContent = generatedMain.readAsStringSync();
|
||||
expect(mainContent, equals(_kLinuxRegistrant));
|
||||
});
|
||||
|
||||
testUsingContext('removes generated_main.dart if plugins are removed from pubspec.yaml', () async {
|
||||
final Environment environment = Environment.test(
|
||||
fileSystem.currentDirectory,
|
||||
projectDir: fileSystem.directory('project')..createSync(),
|
||||
artifacts: null,
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
generateDartPluginRegistry: true);
|
||||
final File config = environment.projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
config.createSync(recursive: true);
|
||||
config.writeAsStringSync(_kSamplePackageJson);
|
||||
|
||||
final File pubspec = environment.projectDir.childFile('pubspec.yaml');
|
||||
pubspec.createSync();
|
||||
pubspec.writeAsStringSync(_kSamplePubspecFile);
|
||||
|
||||
final File packages = environment.projectDir.childFile('.packages');
|
||||
packages.createSync();
|
||||
packages.writeAsStringSync(_kSamplePackagesFile);
|
||||
|
||||
final File generatedMain = environment.projectDir
|
||||
.childDirectory('.dart_tool')
|
||||
.childDirectory('flutter_build')
|
||||
.childFile('generated_main.dart');
|
||||
|
||||
final File pluginPubspec = environment.fileSystem.currentDirectory
|
||||
.childDirectory('path_provider_linux')
|
||||
.childFile('pubspec.yaml');
|
||||
|
||||
pluginPubspec.createSync(recursive: true);
|
||||
pluginPubspec.writeAsStringSync(_kSamplePluginPubspec);
|
||||
|
||||
final FlutterProject testProject = FlutterProject.fromDirectoryTest(environment.projectDir);
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
expect(generatedMain.existsSync(), isTrue);
|
||||
|
||||
// Simulate a user removing everything from pubspec.yaml.
|
||||
pubspec.writeAsStringSync(_kEmptyPubspecFile);
|
||||
packages.writeAsStringSync(_kEmptyPackageJson);
|
||||
config.writeAsStringSync(_kEmptyPackageJson);
|
||||
|
||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||
expect(generatedMain.existsSync(), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/compile.dart';
|
||||
@@ -367,4 +368,60 @@ void main() {
|
||||
|
||||
expect((await output).outputFilename, '');
|
||||
});
|
||||
|
||||
testWithoutContext('KernelCompiler uses generated entrypoint', () async {
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final StdoutHandler stdoutHandler = StdoutHandler(logger: logger, fileSystem: MemoryFileSystem.test());
|
||||
final Completer<void> completer = Completer<void>();
|
||||
final MemoryFileSystem fs = MemoryFileSystem.test();
|
||||
final KernelCompiler kernelCompiler = KernelCompiler(
|
||||
artifacts: Artifacts.test(),
|
||||
fileSystem: fs,
|
||||
fileSystemRoots: <String>[
|
||||
'/foo/bar/fizz',
|
||||
],
|
||||
fileSystemScheme: 'scheme',
|
||||
logger: logger,
|
||||
processManager: FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: const <String>[
|
||||
'HostArtifact.engineDartBinary',
|
||||
'--disable-dart-dev',
|
||||
'Artifact.frontendServerSnapshotForEngineDartSdk',
|
||||
'--sdk-root',
|
||||
'/path/to/sdkroot/',
|
||||
'--target=flutter',
|
||||
'--no-print-incremental-dependencies',
|
||||
'-Ddart.vm.profile=false',
|
||||
'-Ddart.vm.product=false',
|
||||
'--enable-asserts',
|
||||
'--no-link-platform',
|
||||
'--packages',
|
||||
'.packages',
|
||||
'.dart_tools/flutter_build/generated_main.dart',
|
||||
], completer: completer),
|
||||
]),
|
||||
stdoutHandler: stdoutHandler,
|
||||
);
|
||||
|
||||
final Directory buildDir = fs.directory('.dart_tools')
|
||||
.childDirectory('flutter_build')
|
||||
.childDirectory('test');
|
||||
|
||||
buildDir.parent.childFile('generated_main.dart').createSync(recursive: true);
|
||||
|
||||
final Future<CompilerOutput> output = kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
||||
mainPath: '/foo/bar/fizz/main.dart',
|
||||
buildMode: BuildMode.debug,
|
||||
trackWidgetCreation: false,
|
||||
dartDefines: const <String>[],
|
||||
packageConfig: PackageConfig.empty,
|
||||
packagesPath: '.packages',
|
||||
buildDir: buildDir,
|
||||
checkDartPluginRegistry: true,
|
||||
);
|
||||
|
||||
stdoutHandler.compilerOutput.complete(const CompilerOutput('', 0, <Uri>[]));
|
||||
completer.complete();
|
||||
await output;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
projectRootPath: '',
|
||||
fs: fileSystem,
|
||||
).then((CompilerOutput output) {
|
||||
expect(frontendServerStdIn.getAndClear(),
|
||||
'compile file:///path/to/main.dart\n');
|
||||
@@ -137,6 +139,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
projectRootPath: '',
|
||||
fs: MemoryFileSystem(),
|
||||
).then((CompilerOutput outputCompile) {
|
||||
expect(testLogger.errorText,
|
||||
equals('line1\nline2\n'));
|
||||
|
||||
@@ -92,6 +92,8 @@ void main() {
|
||||
null /* invalidatedFiles */,
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||
expect(testLogger.errorText, equals('line1\nline2\n'));
|
||||
@@ -117,6 +119,8 @@ void main() {
|
||||
null /* invalidatedFiles */,
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n');
|
||||
expect(testLogger.errorText, equals('line1\nline2\n'));
|
||||
@@ -135,6 +139,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
)), throwsToolExit());
|
||||
});
|
||||
|
||||
@@ -150,6 +156,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
)), throwsToolExit(message: 'the Dart compiler exited unexpectedly.'));
|
||||
});
|
||||
|
||||
@@ -167,6 +175,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
projectRootPath: '',
|
||||
fs: MemoryFileSystem(),
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||
|
||||
@@ -213,6 +223,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n');
|
||||
|
||||
@@ -274,6 +286,8 @@ void main() {
|
||||
null, /* invalidatedFiles */
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n');
|
||||
|
||||
@@ -323,6 +337,8 @@ void main() {
|
||||
<Uri>[],
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||
|
||||
@@ -359,6 +375,8 @@ void main() {
|
||||
null /* invalidatedFiles */,
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||
|
||||
@@ -398,6 +416,8 @@ Future<void> _recompile(
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
suppressErrors: suppressErrors,
|
||||
fs: MemoryFileSystem(),
|
||||
projectRootPath: '',
|
||||
);
|
||||
|
||||
// Put content into the output stream after generator.recompile gets
|
||||
|
||||
954
packages/flutter_tools/test/general.shard/dart_plugin_test.dart
Normal file
954
packages/flutter_tools/test/general.shard/dart_plugin_test.dart
Normal file
@@ -0,0 +1,954 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
||||
import 'package:flutter_tools/src/flutter_plugins.dart';
|
||||
import 'package:flutter_tools/src/globals_null_migrated.dart' as globals;
|
||||
import 'package:flutter_tools/src/plugins.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('Dart plugin registrant', () {
|
||||
FileSystem fs;
|
||||
MockFlutterProject flutterProject;
|
||||
MockFlutterManifest flutterManifest;
|
||||
|
||||
setUp(() async {
|
||||
fs = MemoryFileSystem.test();
|
||||
|
||||
flutterProject = MockFlutterProject();
|
||||
|
||||
flutterManifest = MockFlutterManifest();
|
||||
when(flutterManifest.dependencies).thenReturn(<String>{});
|
||||
|
||||
when(flutterProject.manifest).thenReturn(flutterManifest);
|
||||
when(flutterProject.directory).thenReturn(fs.systemTempDirectory.childDirectory('app'));
|
||||
|
||||
when(flutterProject.flutterPluginsFile).thenReturn(flutterProject.directory.childFile('.flutter-plugins'));
|
||||
when(flutterProject.flutterPluginsDependenciesFile).thenReturn(flutterProject.directory.childFile('.flutter-plugins-dependencies'));
|
||||
|
||||
flutterProject.directory.childFile('.packages').createSync(recursive: true);
|
||||
});
|
||||
|
||||
group('resolvePlatformImplementation', () {
|
||||
testWithoutContext('selects implementation from direct dependency', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_linux',
|
||||
'url_launcher_macos',
|
||||
};
|
||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_macos',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'macos': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginMacOS',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'undirect_dependency_plugin',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'windows': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginWindows',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_macos',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'macos': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginMacOS',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
|
||||
expect(resolutions.length, equals(2));
|
||||
expect(resolutions[0].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'url_launcher_linux',
|
||||
'dartClass': 'UrlLauncherPluginLinux',
|
||||
'platform': 'linux',
|
||||
})
|
||||
);
|
||||
expect(resolutions[1].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'url_launcher_macos',
|
||||
'dartClass': 'UrlLauncherPluginMacOS',
|
||||
'platform': 'macos',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('selects default implementation', () async {
|
||||
final Set<String> directDependencies = <String>{};
|
||||
|
||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'default_package': 'url_launcher_linux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
expect(resolutions.length, equals(1));
|
||||
expect(resolutions[0].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'url_launcher_linux',
|
||||
'dartClass': 'UrlLauncherPluginLinux',
|
||||
'platform': 'linux',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('selects default implementation if interface is direct dependency', () async {
|
||||
final Set<String> directDependencies = <String>{'url_launcher'};
|
||||
|
||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'default_package': 'url_launcher_linux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
expect(resolutions.length, equals(1));
|
||||
expect(resolutions[0].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'url_launcher_linux',
|
||||
'dartClass': 'UrlLauncherPluginLinux',
|
||||
'platform': 'linux',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('selects user selected implementation despites default implementation', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'user_selected_url_launcher_implementation',
|
||||
'url_launcher',
|
||||
};
|
||||
|
||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'default_package': 'url_launcher_linux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'user_selected_url_launcher_implementation',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
expect(resolutions.length, equals(1));
|
||||
expect(resolutions[0].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'user_selected_url_launcher_implementation',
|
||||
'dartClass': 'UrlLauncherPluginLinux',
|
||||
'platform': 'linux',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('selects user selected implementation despites default implementation', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'user_selected_url_launcher_implementation',
|
||||
'url_launcher',
|
||||
};
|
||||
|
||||
final List<PluginInterfaceResolution> resolutions = resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'default_package': 'url_launcher_linux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'user_selected_url_launcher_implementation',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
expect(resolutions.length, equals(1));
|
||||
expect(resolutions[0].toMap(), equals(
|
||||
<String, String>{
|
||||
'pluginName': 'user_selected_url_launcher_implementation',
|
||||
'dartClass': 'UrlLauncherPluginLinux',
|
||||
'platform': 'linux',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
testUsingContext('provides error when user selected multiple implementations', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_linux_1',
|
||||
'url_launcher_linux_2',
|
||||
};
|
||||
expect(() {
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux_1',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux_2',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
'Plugin `url_launcher_linux_2` implements an interface for `linux`, which was already implemented by plugin `url_launcher_linux_1`.\n'
|
||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
||||
'\n\n'
|
||||
);
|
||||
},
|
||||
throwsToolExit(
|
||||
message: 'Please resolve the errors',
|
||||
));
|
||||
});
|
||||
|
||||
testUsingContext('provides all errors when user selected multiple implementations', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_linux_1',
|
||||
'url_launcher_linux_2',
|
||||
};
|
||||
expect(() {
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux_1',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux_2',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'implements': 'url_launcher',
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
'Plugin `url_launcher_linux_2` implements an interface for `linux`, which was already implemented by plugin `url_launcher_linux_1`.\n'
|
||||
'To fix this issue, remove either dependency from pubspec.yaml.'
|
||||
'\n\n'
|
||||
);
|
||||
},
|
||||
throwsToolExit(
|
||||
message: 'Please resolve the errors',
|
||||
));
|
||||
});
|
||||
|
||||
testUsingContext('provides error when plugin pubspec.yaml doesn\'t have "implementation" nor "default_implementation"', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_linux_1',
|
||||
};
|
||||
expect(() {
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux_1',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
},
|
||||
throwsToolExit(
|
||||
message: 'Please resolve the errors'
|
||||
));
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
'Plugin `url_launcher_linux_1` doesn\'t implement a plugin interface, '
|
||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
||||
'To set a default implementation, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' platforms:\n'
|
||||
' linux:\n'
|
||||
' default_package: <plugin-implementation>\n'
|
||||
'\n'
|
||||
'To implement an interface, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' implements: <plugin-interface>'
|
||||
'\n\n'
|
||||
);
|
||||
});
|
||||
|
||||
testUsingContext('provides all errors when plugin pubspec.yaml doesn\'t have "implementation" nor "default_implementation"', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_linux',
|
||||
'url_launcher_windows',
|
||||
};
|
||||
expect(() {
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_linux',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'linux': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginLinux',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_windows',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'windows': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginWindows',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
]);
|
||||
},
|
||||
throwsToolExit(
|
||||
message: 'Please resolve the errors'
|
||||
));
|
||||
expect(
|
||||
testLogger.errorText,
|
||||
'Plugin `url_launcher_linux` doesn\'t implement a plugin interface, '
|
||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
||||
'To set a default implementation, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' platforms:\n'
|
||||
' linux:\n'
|
||||
' default_package: <plugin-implementation>\n'
|
||||
'\n'
|
||||
'To implement an interface, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' implements: <plugin-interface>'
|
||||
'\n\n'
|
||||
'Plugin `url_launcher_windows` doesn\'t implement a plugin interface, '
|
||||
'nor sets a default implementation in pubspec.yaml.\n\n'
|
||||
'To set a default implementation, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' platforms:\n'
|
||||
' windows:\n'
|
||||
' default_package: <plugin-implementation>\n'
|
||||
'\n'
|
||||
'To implement an interface, use:\n'
|
||||
'flutter:\n'
|
||||
' plugin:\n'
|
||||
' implements: <plugin-interface>'
|
||||
'\n\n'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('generateMainDartWithPluginRegistrant', () {
|
||||
|
||||
void createFakeDartPlugins(
|
||||
FlutterProject flutterProject,
|
||||
FlutterManifest flutterManifest,
|
||||
FileSystem fs,
|
||||
Map<String, String> plugins,
|
||||
) {
|
||||
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
||||
final File packagesFile = flutterProject.directory
|
||||
.childFile('.packages')
|
||||
..createSync(recursive: true);
|
||||
|
||||
for (final MapEntry<String, String> entry in plugins.entries) {
|
||||
final String name = fs.path.basename(entry.key);
|
||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
||||
packagesFile.writeAsStringSync(
|
||||
'$name:file://${pluginDirectory.childFile('lib').uri}\n',
|
||||
mode: FileMode.writeOnlyAppend);
|
||||
pluginDirectory.childFile('pubspec.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(entry.value);
|
||||
}
|
||||
when(flutterManifest.dependencies).thenReturn(<String>{...plugins.keys});
|
||||
}
|
||||
|
||||
testUsingContext('Generates new entrypoint', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
|
||||
createFakeDartPlugins(
|
||||
flutterProject,
|
||||
flutterManifest,
|
||||
fs,
|
||||
<String, String>{
|
||||
'url_launcher_macos': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
platforms:
|
||||
macos:
|
||||
dartPluginClass: MacOSPlugin
|
||||
''',
|
||||
'url_launcher_linux': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
platforms:
|
||||
linux:
|
||||
dartPluginClass: LinuxPlugin
|
||||
''',
|
||||
'url_launcher_windows': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
platforms:
|
||||
windows:
|
||||
dartPluginClass: WindowsPlugin
|
||||
''',
|
||||
'awesome_macos': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: awesome
|
||||
platforms:
|
||||
macos:
|
||||
dartPluginClass: AwesomeMacOS
|
||||
'''
|
||||
});
|
||||
|
||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||
libDir.createSync(recursive: true);
|
||||
|
||||
final File mainFile = libDir.childFile('main.dart');
|
||||
mainFile.writeAsStringSync('''
|
||||
// @dart = 2.8
|
||||
void main() {
|
||||
}
|
||||
''');
|
||||
final File generatedMainFile = flutterProject.directory.childFile('generated_main.dart');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
await generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
);
|
||||
expect(generatedMainFile.readAsStringSync(),
|
||||
'//\n'
|
||||
'// Generated file. Do not edit.\n'
|
||||
'// This file is generated from template in file `flutter_tools/lib/src/flutter_plugins.dart`.\n'
|
||||
'//\n'
|
||||
'\n'
|
||||
'// @dart = 2.8\n'
|
||||
'\n'
|
||||
'import \'package:app/main.dart\' as entrypoint;\n'
|
||||
'import \'dart:io\'; // flutter_ignore: dart_io_import.\n'
|
||||
'import \'package:url_launcher_linux/url_launcher_linux.dart\';\n'
|
||||
'import \'package:awesome_macos/awesome_macos.dart\';\n'
|
||||
'import \'package:url_launcher_macos/url_launcher_macos.dart\';\n'
|
||||
'import \'package:url_launcher_windows/url_launcher_windows.dart\';\n'
|
||||
'\n'
|
||||
'@pragma(\'vm:entry-point\')\n'
|
||||
'class _PluginRegistrant {\n'
|
||||
'\n'
|
||||
' @pragma(\'vm:entry-point\')\n'
|
||||
' static void register() {\n'
|
||||
' if (Platform.isLinux) {\n'
|
||||
' try {\n'
|
||||
' LinuxPlugin.registerWith();\n'
|
||||
' } catch (err) {\n'
|
||||
' print(\n'
|
||||
' \'`url_launcher_linux` threw an error: \$err. \'\n'
|
||||
' \'The app may not function as expected until you remove this plugin from pubspec.yaml\'\n'
|
||||
' );\n'
|
||||
' rethrow;\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
' } else if (Platform.isMacOS) {\n'
|
||||
' try {\n'
|
||||
' AwesomeMacOS.registerWith();\n'
|
||||
' } catch (err) {\n'
|
||||
' print(\n'
|
||||
' \'`awesome_macos` threw an error: \$err. \'\n'
|
||||
' \'The app may not function as expected until you remove this plugin from pubspec.yaml\'\n'
|
||||
' );\n'
|
||||
' rethrow;\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
' try {\n'
|
||||
' MacOSPlugin.registerWith();\n'
|
||||
' } catch (err) {\n'
|
||||
' print(\n'
|
||||
' \'`url_launcher_macos` threw an error: \$err. \'\n'
|
||||
' \'The app may not function as expected until you remove this plugin from pubspec.yaml\'\n'
|
||||
' );\n'
|
||||
' rethrow;\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
' } else if (Platform.isWindows) {\n'
|
||||
' try {\n'
|
||||
' WindowsPlugin.registerWith();\n'
|
||||
' } catch (err) {\n'
|
||||
' print(\n'
|
||||
' \'`url_launcher_windows` threw an error: \$err. \'\n'
|
||||
' \'The app may not function as expected until you remove this plugin from pubspec.yaml\'\n'
|
||||
' );\n'
|
||||
' rethrow;\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
' }\n'
|
||||
' }\n'
|
||||
'\n'
|
||||
'}\n'
|
||||
'\n'
|
||||
'typedef _UnaryFunction = dynamic Function(List<String> args);\n'
|
||||
'typedef _NullaryFunction = dynamic Function();\n'
|
||||
'\n'
|
||||
'void main(List<String> args) {\n'
|
||||
' if (entrypoint.main is _UnaryFunction) {\n'
|
||||
' (entrypoint.main as _UnaryFunction)(args);\n'
|
||||
' } else {\n'
|
||||
' (entrypoint.main as _NullaryFunction)();\n'
|
||||
' }\n'
|
||||
'}\n'
|
||||
'',
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Plugin without platform support throws tool exit', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
|
||||
createFakeDartPlugins(
|
||||
flutterProject,
|
||||
flutterManifest,
|
||||
fs,
|
||||
<String, String>{
|
||||
'url_launcher_macos': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
platforms:
|
||||
macos:
|
||||
invalid:
|
||||
'''
|
||||
});
|
||||
|
||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||
libDir.createSync(recursive: true);
|
||||
|
||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
||||
final File generatedMainFile = flutterProject.directory.childFile('generated_main.dart');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
await expectLater(
|
||||
generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
), throwsToolExit(message:
|
||||
'Invalid plugin specification url_launcher_macos.\n'
|
||||
'Invalid "macos" plugin specification.'
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Plugin with platform support without dart plugin class throws tool exit', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
|
||||
createFakeDartPlugins(
|
||||
flutterProject,
|
||||
flutterManifest,
|
||||
fs,
|
||||
<String, String>{
|
||||
'url_launcher_macos': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
'''
|
||||
});
|
||||
|
||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||
libDir.createSync(recursive: true);
|
||||
|
||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
||||
final File generatedMainFile = flutterProject.directory.childFile('generated_main.dart');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
await expectLater(
|
||||
generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
), throwsToolExit(message:
|
||||
'Invalid plugin specification url_launcher_macos.\n'
|
||||
'Cannot find the `flutter.plugin.platforms` key in the `pubspec.yaml` file. '
|
||||
'An instruction to format the `pubspec.yaml` can be found here: '
|
||||
'https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms'
|
||||
),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Does not show error messages if throwOnPluginPubspecError is false', () async {
|
||||
final Set<String> directDependencies = <String>{
|
||||
'url_launcher_windows',
|
||||
};
|
||||
resolvePlatformImplementation(<Plugin>[
|
||||
Plugin.fromYaml(
|
||||
'url_launcher_windows',
|
||||
'',
|
||||
YamlMap.wrap(<String, dynamic>{
|
||||
'platforms': <String, dynamic>{
|
||||
'windows': <String, dynamic>{
|
||||
'dartPluginClass': 'UrlLauncherPluginWindows',
|
||||
},
|
||||
},
|
||||
}),
|
||||
<String>[],
|
||||
fileSystem: fs,
|
||||
appDependencies: directDependencies,
|
||||
),
|
||||
],
|
||||
throwOnPluginPubspecError: false,
|
||||
);
|
||||
expect(testLogger.errorText, '');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Does not create new entrypoint if there are no platform resolutions', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
when(flutterManifest.dependencies).thenReturn(<String>{});
|
||||
|
||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||
libDir.createSync(recursive: true);
|
||||
|
||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
||||
final File generatedMainFile = flutterProject.directory.childFile('generated_main.dart');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
await generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
);
|
||||
expect(generatedMainFile.existsSync(), isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Deletes new entrypoint if there are no platform resolutions', () async {
|
||||
when(flutterProject.isModule).thenReturn(false);
|
||||
|
||||
createFakeDartPlugins(
|
||||
flutterProject,
|
||||
flutterManifest,
|
||||
fs,
|
||||
<String, String>{
|
||||
'url_launcher_macos': '''
|
||||
flutter:
|
||||
plugin:
|
||||
implements: url_launcher
|
||||
platforms:
|
||||
macos:
|
||||
dartPluginClass: MacOSPlugin
|
||||
'''
|
||||
});
|
||||
|
||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||
libDir.createSync(recursive: true);
|
||||
|
||||
final File mainFile = libDir.childFile('main.dart')..writeAsStringSync('');
|
||||
final File generatedMainFile = flutterProject.directory.childFile('generated_main.dart');
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json'),
|
||||
logger: globals.logger,
|
||||
throwOnError: false,
|
||||
);
|
||||
await generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
);
|
||||
expect(generatedMainFile.existsSync(), isTrue);
|
||||
|
||||
// No plugins.
|
||||
createFakeDartPlugins(
|
||||
flutterProject,
|
||||
flutterManifest,
|
||||
fs,
|
||||
<String, String>{});
|
||||
|
||||
await generateMainDartWithPluginRegistrant(
|
||||
flutterProject,
|
||||
packageConfig,
|
||||
'package:app/main.dart',
|
||||
generatedMainFile,
|
||||
mainFile,
|
||||
throwOnPluginPubspecError: true,
|
||||
);
|
||||
expect(generatedMainFile.existsSync(), isFalse);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
class MockFlutterManifest extends Mock implements FlutterManifest {}
|
||||
class MockFlutterProject extends Mock implements FlutterProject {}
|
||||
@@ -170,6 +170,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('lib/foo.dill')
|
||||
..createSync(recursive: true)
|
||||
@@ -237,6 +239,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('lib/foo.dill', 2, <Uri>[]);
|
||||
});
|
||||
@@ -281,6 +285,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('example').createSync();
|
||||
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
|
||||
@@ -327,6 +333,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('lib/foo.txt.dill').createSync(recursive: true);
|
||||
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
|
||||
@@ -379,6 +387,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('example').createSync();
|
||||
return const CompilerOutput('lib/foo.txt.dill', 0, <Uri>[]);
|
||||
|
||||
@@ -1444,6 +1444,19 @@ flutter:
|
||||
expect(deferredComponents[0].assets[1].path, 'path/to/asset2.jpg');
|
||||
expect(deferredComponents[0].assets[2].path, 'path/to/asset3.jpg');
|
||||
});
|
||||
|
||||
testWithoutContext('FlutterManifest can parse empty dependencies', () async {
|
||||
const String manifest = '''
|
||||
name: test
|
||||
''';
|
||||
final FlutterManifest? flutterManifest = FlutterManifest.createFromString(
|
||||
manifest,
|
||||
logger: BufferLogger.test(),
|
||||
);
|
||||
|
||||
expect(flutterManifest, isNotNull);
|
||||
expect(flutterManifest!.dependencies, isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Matcher matchesManifest({
|
||||
|
||||
@@ -218,6 +218,39 @@ void main() {
|
||||
);
|
||||
|
||||
expect(plugin.platforms, <String, PluginPlatform>{});
|
||||
expect(plugin.defaultPackagePlatforms, <String, String>{
|
||||
'linux': 'sample_package_linux',
|
||||
'macos': 'sample_package_macos',
|
||||
'windows': 'sample_package_windows',
|
||||
});
|
||||
expect(plugin.pluginDartClassPlatforms, <String, String>{});
|
||||
});
|
||||
|
||||
testWithoutContext('Desktop plugin parsing allows a dartPluginClass field', () {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
const String pluginYamlRaw =
|
||||
'platforms:\n'
|
||||
' linux:\n'
|
||||
' dartPluginClass: LinuxClass\n'
|
||||
' macos:\n'
|
||||
' dartPluginClass: MacOSClass\n'
|
||||
' windows:\n'
|
||||
' dartPluginClass: WindowsClass\n';
|
||||
|
||||
final YamlMap pluginYaml = loadYaml(pluginYamlRaw) as YamlMap;
|
||||
final Plugin plugin = Plugin.fromYaml(
|
||||
_kTestPluginName,
|
||||
_kTestPluginPath,
|
||||
pluginYaml,
|
||||
const <String>[],
|
||||
fileSystem: fileSystem,
|
||||
);
|
||||
|
||||
expect(plugin.pluginDartClassPlatforms, <String, String>{
|
||||
'linux': 'LinuxClass',
|
||||
'macos': 'MacOSClass',
|
||||
'windows': 'WindowsClass',
|
||||
});
|
||||
});
|
||||
|
||||
testWithoutContext('Plugin parsing throws a fatal error on an empty plugin', () {
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
||||
import 'package:flutter_tools/src/flutter_plugins.dart';
|
||||
import 'package:flutter_tools/src/globals_null_migrated.dart' as globals;
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
@@ -33,6 +34,7 @@ void main() {
|
||||
group('plugins', () {
|
||||
FileSystem fs;
|
||||
MockFlutterProject flutterProject;
|
||||
MockFlutterManifest flutterManifest;
|
||||
MockIosProject iosProject;
|
||||
MockMacOSProject macosProject;
|
||||
MockAndroidProject androidProject;
|
||||
@@ -49,6 +51,12 @@ void main() {
|
||||
// Adds basic properties to the flutterProject and its subprojects.
|
||||
void setUpProject(FileSystem fileSystem) {
|
||||
flutterProject = MockFlutterProject();
|
||||
|
||||
flutterManifest = MockFlutterManifest();
|
||||
when(flutterManifest.dependencies).thenReturn(<String>{});
|
||||
|
||||
when(flutterProject.manifest).thenReturn(flutterManifest);
|
||||
|
||||
when(flutterProject.directory).thenReturn(fileSystem.systemTempDirectory.childDirectory('app'));
|
||||
// TODO(franciscojma): Remove logic for .flutter-plugins once it's deprecated.
|
||||
when(flutterProject.flutterPluginsFile).thenReturn(flutterProject.directory.childFile('.flutter-plugins'));
|
||||
@@ -1412,6 +1420,7 @@ flutter:
|
||||
}
|
||||
|
||||
class MockAndroidProject extends Mock implements AndroidProject {}
|
||||
class MockFlutterManifest extends Mock implements FlutterManifest {}
|
||||
class MockFlutterProject extends Mock implements FlutterProject {}
|
||||
class MockIosProject extends Mock implements IosProject {}
|
||||
class MockMacOSProject extends Mock implements MacOSProject {}
|
||||
|
||||
@@ -110,6 +110,17 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
_testInMemory('reads dependencies from pubspec.yaml', () async {
|
||||
final Directory directory = globals.fs.directory('myproject');
|
||||
directory.childFile('pubspec.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(validPubspecWithDependencies);
|
||||
expect(
|
||||
FlutterProject.fromDirectory(directory).manifest.dependencies,
|
||||
<String>{'plugin_a', 'plugin_b'},
|
||||
);
|
||||
});
|
||||
|
||||
_testInMemory('sets up location', () async {
|
||||
final Directory directory = globals.fs.directory('myproject');
|
||||
expect(
|
||||
@@ -920,6 +931,16 @@ name: hello
|
||||
flutter:
|
||||
''';
|
||||
|
||||
String get validPubspecWithDependencies => '''
|
||||
name: hello
|
||||
flutter:
|
||||
|
||||
dependencies:
|
||||
plugin_a:
|
||||
plugin_b:
|
||||
''';
|
||||
|
||||
|
||||
String get invalidPubspec => '''
|
||||
name: hello
|
||||
flutter:
|
||||
|
||||
@@ -271,6 +271,8 @@ void main() {
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
suppressErrors: true,
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('foo', 0 ,<Uri>[]);
|
||||
});
|
||||
@@ -288,6 +290,8 @@ void main() {
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
suppressErrors: true,
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).called(1);
|
||||
expect(fakeVmServiceHost.hasRemainingExpectations, false);
|
||||
}), overrides: <Type, Generator>{
|
||||
@@ -316,6 +320,8 @@ void main() {
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
suppressErrors: true,
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('foo', 1 ,<Uri>[]);
|
||||
});
|
||||
@@ -408,6 +414,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
suppressErrors: false,
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('foo', 0, <Uri>[]);
|
||||
@@ -426,6 +434,8 @@ void main() {
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
suppressErrors: false,
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).called(1);
|
||||
expect(fakeVmServiceHost.hasRemainingExpectations, false);
|
||||
}), overrides: <Type, Generator>{
|
||||
@@ -1438,6 +1448,26 @@ void main() {
|
||||
globals.fs.file('l10n.yaml').createSync();
|
||||
globals.fs.file('pubspec.yaml').writeAsStringSync('flutter:\n generate: true\n');
|
||||
|
||||
// Create necessary files for [DartPluginRegistrantTarget]
|
||||
final File packageConfig = globals.fs.directory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
packageConfig.createSync(recursive: true);
|
||||
packageConfig.writeAsStringSync('''
|
||||
{
|
||||
"configVersion": 2,
|
||||
"packages": [
|
||||
{
|
||||
"name": "path_provider_linux",
|
||||
"rootUri": "../../../path_provider_linux",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
''');
|
||||
// Start from an empty generated_main.dart file.
|
||||
globals.fs.directory('.dart_tool').childDirectory('flutter_build').childFile('generated_main.dart').createSync(recursive: true);
|
||||
|
||||
await residentRunner.runSourceGenerators();
|
||||
|
||||
expect(testLogger.errorText, isEmpty);
|
||||
@@ -2515,6 +2545,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
||||
List<Uri> invalidatedFiles, {
|
||||
@required String outputPath,
|
||||
@required PackageConfig packageConfig,
|
||||
@required String projectRootPath,
|
||||
@required FileSystem fs,
|
||||
bool suppressErrors = false,
|
||||
}) async {
|
||||
return const CompilerOutput('foo.dill', 0, <Uri>[]);
|
||||
|
||||
@@ -55,6 +55,8 @@ void main() {
|
||||
<Uri>[Uri.parse('test/foo.dart')],
|
||||
outputPath: testCompiler.outputDill.path,
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('abc.dill').createSync();
|
||||
return const CompilerOutput('abc.dill', 0, <Uri>[]);
|
||||
@@ -80,6 +82,8 @@ void main() {
|
||||
<Uri>[Uri.parse('test/foo.dart')],
|
||||
outputPath: testCompiler.outputDill.path,
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
fileSystem.file('abc.dill').createSync();
|
||||
return const CompilerOutput('abc.dill', 1, <Uri>[]);
|
||||
|
||||
@@ -605,6 +605,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
@@ -723,6 +725,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
@@ -838,6 +842,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
@@ -883,6 +889,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
@@ -936,6 +944,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
@@ -1056,6 +1066,8 @@ void main() {
|
||||
any,
|
||||
outputPath: anyNamed('outputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
fs: anyNamed('fs'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return const CompilerOutput('a', 0, <Uri>[]);
|
||||
});
|
||||
|
||||
@@ -44,8 +44,11 @@ void main() {
|
||||
Plugin(
|
||||
name: 'test',
|
||||
path: 'foo',
|
||||
defaultPackagePlatforms: const <String, String>{},
|
||||
pluginDartClassPlatforms: const <String, String>{},
|
||||
platforms: const <String, PluginPlatform>{WindowsPlugin.kConfigKey: WindowsPlugin(name: 'test', pluginClass: 'Foo')},
|
||||
dependencies: <String>[],
|
||||
isDirectDependency: true,
|
||||
),
|
||||
], renderer);
|
||||
|
||||
@@ -67,8 +70,11 @@ void main() {
|
||||
Plugin(
|
||||
name: 'test',
|
||||
path: 'foo',
|
||||
defaultPackagePlatforms: const <String, String>{},
|
||||
pluginDartClassPlatforms: const <String, String>{},
|
||||
platforms: const <String, PluginPlatform>{WindowsPlugin.kConfigKey: WindowsPlugin(name: 'test', pluginClass: 'Foo')},
|
||||
dependencies: <String>[],
|
||||
isDirectDependency: true,
|
||||
),
|
||||
], renderer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user