Unverified Commit 30d405c7 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Temporarily allow pluginClass: none on desktop (#57498)

Treats 'pluginClass: none' as equivalent to having no 'pluginClass'
entry on the desktop platforms, to satisy stable channel plugin
validation of Dart-only desktop plugin implementations. See
issue for full details.

Part of https://github.com/flutter/flutter/issues/57497
parent 5a3104b3
......@@ -214,9 +214,14 @@ class MacOSPlugin extends PluginPlatform implements NativeOrDartPlugin {
factory MacOSPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String pluginClass = yaml[kPluginClass] as String;
if (pluginClass == 'none') {
pluginClass = null;
}
return MacOSPlugin(
name: name,
pluginClass: yaml[kPluginClass] as String,
pluginClass: pluginClass,
dartPluginClass: yaml[kDartPluginClass] as String,
);
}
......@@ -260,9 +265,14 @@ class WindowsPlugin extends PluginPlatform implements NativeOrDartPlugin{
factory WindowsPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String pluginClass = yaml[kPluginClass] as String;
if (pluginClass == 'none') {
pluginClass = null;
}
return WindowsPlugin(
name: name,
pluginClass: yaml[kPluginClass] as String,
pluginClass: pluginClass,
dartPluginClass: yaml[kDartPluginClass] as String,
);
}
......@@ -307,9 +317,14 @@ class LinuxPlugin extends PluginPlatform implements NativeOrDartPlugin {
factory LinuxPlugin.fromYaml(String name, YamlMap yaml) {
assert(validate(yaml));
// Treat 'none' as not present. See https://github.com/flutter/flutter/issues/57497.
String pluginClass = yaml[kPluginClass] as String;
if (pluginClass == 'none') {
pluginClass = null;
}
return LinuxPlugin(
name: name,
pluginClass: yaml[kPluginClass] as String,
pluginClass: pluginClass,
dartPluginClass: yaml[kDartPluginClass] as String,
);
}
......
......@@ -914,6 +914,35 @@ flutter:
FeatureFlags: () => featureFlags,
});
testUsingContext('pluginClass: none doesn\'t trigger registrant entry on macOS', () async {
when(macosProject.existsSync()).thenReturn(true);
when(featureFlags.isMacOSEnabled).thenReturn(true);
when(flutterProject.isModule).thenReturn(true);
// Create a plugin without a pluginClass.
dummyPackageDirectory.parent.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync('''
flutter:
plugin:
platforms:
macos:
pluginClass: none
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, checkProjects: true);
final File registrantFile = macosProject.managedDirectory.childFile('GeneratedPluginRegistrant.swift');
expect(registrantFile, exists);
expect(registrantFile, isNot(contains('SomePlugin')));
expect(registrantFile, isNot(contains('none')));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => featureFlags,
});
testUsingContext('Injecting creates generated Linux registrant', () async {
when(linuxProject.existsSync()).thenReturn(true);
when(featureFlags.isLinuxEnabled).thenReturn(true);
......@@ -961,6 +990,35 @@ flutter:
FeatureFlags: () => featureFlags,
});
testUsingContext('pluginClass: none doesn\'t trigger registrant entry on Linux', () async {
when(linuxProject.existsSync()).thenReturn(true);
when(featureFlags.isLinuxEnabled).thenReturn(true);
when(flutterProject.isModule).thenReturn(false);
// Create a plugin without a pluginClass.
dummyPackageDirectory.parent.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync('''
flutter:
plugin:
platforms:
linux:
pluginClass: none
dartPluginClass: SomePlugin
''');
await injectPlugins(flutterProject, checkProjects: true);
final File registrantImpl = linuxProject.managedDirectory.childFile('generated_plugin_registrant.cc');
expect(registrantImpl, exists);
expect(registrantImpl, isNot(contains('SomePlugin')));
expect(registrantImpl, isNot(contains('none')));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => featureFlags,
});
testUsingContext('Injecting creates generated Linux plugin Cmake file', () async {
when(linuxProject.existsSync()).thenReturn(true);
when(featureFlags.isLinuxEnabled).thenReturn(true);
......@@ -1034,6 +1092,38 @@ flutter:
FeatureFlags: () => featureFlags,
});
testUsingContext('pluginClass: none doesn\'t trigger registrant entry on Windows', () async {
when(windowsProject.existsSync()).thenReturn(true);
when(featureFlags.isWindowsEnabled).thenReturn(true);
when(flutterProject.isModule).thenReturn(false);
// Create a plugin without a pluginClass.
dummyPackageDirectory.parent.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync('''
flutter:
plugin:
platforms:
windows:
pluginClass: none
dartPluginClass: SomePlugin
''');
createDummyWindowsSolutionFile();
createDummyPluginWindowsProjectFile();
await injectPlugins(flutterProject, checkProjects: true);
final File registrantImpl = windowsProject.managedDirectory.childFile('generated_plugin_registrant.cc');
expect(registrantImpl, exists);
expect(registrantImpl, isNot(contains('SomePlugin')));
expect(registrantImpl, isNot(contains('none')));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
FeatureFlags: () => featureFlags,
});
testUsingContext('Injecting creates generated Windows plugin properties', () async {
when(windowsProject.existsSync()).thenReturn(true);
when(featureFlags.isWindowsEnabled).thenReturn(true);
......
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