mirror of
https://github.com/flutter/packages.git
synced 2025-06-29 14:18:54 +08:00
[video_player] Endorse macOS (#5021)
Endorses the macOS implementation of `video_player`, updating the constraint of the existing `video_player_avfoundation` dependency to ensure macOS support is present. Adds macOS support to the example, and adds macOS discussion to the README. This is the first macOS plugin with multiple integration test files, which turned up a bug in `flutter test`, so this also includes a repo tooling change to work around that bug for now by running each integration test file separately on macOS (as we already have to do with `flutter drive` on web). Fixes https://github.com/flutter/flutter/issues/41688
This commit is contained in:
@ -224,7 +224,8 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
||||
chromedriver.kill();
|
||||
}
|
||||
} else {
|
||||
if (!await _runTests(example, deviceFlags: deviceFlags)) {
|
||||
if (!await _runTests(example,
|
||||
deviceFlags: deviceFlags, testFiles: testTargets)) {
|
||||
errors.add('Integration tests failed.');
|
||||
}
|
||||
}
|
||||
@ -395,19 +396,34 @@ class DriveExamplesCommand extends PackageLoopingCommand {
|
||||
Future<bool> _runTests(
|
||||
RepositoryPackage example, {
|
||||
required List<String> deviceFlags,
|
||||
required List<File> testFiles,
|
||||
}) async {
|
||||
final String enableExperiment = getStringArg(kEnableExperiment);
|
||||
|
||||
final int exitCode = await processRunner.runAndStream(
|
||||
flutterCommand,
|
||||
<String>[
|
||||
'test',
|
||||
...deviceFlags,
|
||||
if (enableExperiment.isNotEmpty)
|
||||
'--enable-experiment=$enableExperiment',
|
||||
'integration_test',
|
||||
],
|
||||
workingDir: example.directory);
|
||||
return exitCode == 0;
|
||||
// Workaround for https://github.com/flutter/flutter/issues/135673
|
||||
// Once that is fixed on stable, this logic can be removed and the command
|
||||
// can always just be run with "integration_test".
|
||||
final bool needsMultipleInvocations =
|
||||
testFiles.length > 1 && getBoolArg(platformMacOS);
|
||||
final Iterable<String> individualRunTargets = needsMultipleInvocations
|
||||
? testFiles
|
||||
.map((File f) => getRelativePosixPath(f, from: example.directory))
|
||||
: <String>['integration_test'];
|
||||
|
||||
bool passed = true;
|
||||
for (final String target in individualRunTargets) {
|
||||
final int exitCode = await processRunner.runAndStream(
|
||||
flutterCommand,
|
||||
<String>[
|
||||
'test',
|
||||
...deviceFlags,
|
||||
if (enableExperiment.isNotEmpty)
|
||||
'--enable-experiment=$enableExperiment',
|
||||
target,
|
||||
],
|
||||
workingDir: example.directory);
|
||||
passed = passed && (exitCode == 0);
|
||||
}
|
||||
return passed;
|
||||
}
|
||||
}
|
||||
|
@ -448,6 +448,61 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
// This tests the workaround for https://github.com/flutter/flutter/issues/135673
|
||||
// and the behavior it tests should be removed once that is fixed.
|
||||
test('runs tests separately on macOS', () async {
|
||||
final RepositoryPackage plugin = createFakePlugin(
|
||||
'plugin',
|
||||
packagesDir,
|
||||
extraFiles: <String>[
|
||||
'example/integration_test/first_test.dart',
|
||||
'example/integration_test/second_test.dart',
|
||||
'example/macos/macos.swift',
|
||||
],
|
||||
platformSupport: <String, PlatformDetails>{
|
||||
platformMacOS: const PlatformDetails(PlatformSupport.inline),
|
||||
},
|
||||
);
|
||||
|
||||
final Directory pluginExampleDirectory = getExampleDir(plugin);
|
||||
|
||||
final List<String> output = await runCapturingPrint(runner, <String>[
|
||||
'drive-examples',
|
||||
'--macos',
|
||||
]);
|
||||
|
||||
expect(
|
||||
output,
|
||||
containsAllInOrder(<Matcher>[
|
||||
contains('Running for plugin'),
|
||||
contains('No issues found!'),
|
||||
]),
|
||||
);
|
||||
|
||||
expect(
|
||||
processRunner.recordedCalls,
|
||||
orderedEquals(<ProcessCall>[
|
||||
ProcessCall(
|
||||
getFlutterCommand(mockPlatform),
|
||||
const <String>[
|
||||
'test',
|
||||
'-d',
|
||||
'macos',
|
||||
'integration_test/first_test.dart',
|
||||
],
|
||||
pluginExampleDirectory.path),
|
||||
ProcessCall(
|
||||
getFlutterCommand(mockPlatform),
|
||||
const <String>[
|
||||
'test',
|
||||
'-d',
|
||||
'macos',
|
||||
'integration_test/second_test.dart',
|
||||
],
|
||||
pluginExampleDirectory.path),
|
||||
]));
|
||||
});
|
||||
|
||||
test('driving when plugin does not suppport web is a no-op', () async {
|
||||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
|
||||
'example/integration_test/plugin_test.dart',
|
||||
@ -1086,24 +1141,21 @@ void main() {
|
||||
extraFiles: <String>[
|
||||
'example/integration_test/bar_test.dart',
|
||||
'example/integration_test/foo_test.dart',
|
||||
'example/macos/macos.swift',
|
||||
'example/ios/ios.swift',
|
||||
],
|
||||
platformSupport: <String, PlatformDetails>{
|
||||
platformMacOS: const PlatformDetails(PlatformSupport.inline),
|
||||
platformIOS: const PlatformDetails(PlatformSupport.inline),
|
||||
},
|
||||
);
|
||||
|
||||
setMockFlutterDevicesOutput();
|
||||
// Simulate failure from `flutter test`.
|
||||
processRunner
|
||||
.mockProcessesForExecutable[getFlutterCommand(mockPlatform)] =
|
||||
<FakeProcessInfo>[
|
||||
FakeProcessInfo(MockProcess(exitCode: 1), <String>['test']),
|
||||
];
|
||||
processRunner.mockProcessesForExecutable[getFlutterCommand(mockPlatform)]!
|
||||
.add(FakeProcessInfo(MockProcess(exitCode: 1), <String>['test']));
|
||||
|
||||
Error? commandError;
|
||||
final List<String> output =
|
||||
await runCapturingPrint(runner, <String>['drive-examples', '--macos'],
|
||||
errorHandler: (Error e) {
|
||||
final List<String> output = await runCapturingPrint(
|
||||
runner, <String>['drive-examples', '--ios'], errorHandler: (Error e) {
|
||||
commandError = e;
|
||||
});
|
||||
|
||||
@ -1122,12 +1174,14 @@ void main() {
|
||||
expect(
|
||||
processRunner.recordedCalls,
|
||||
orderedEquals(<ProcessCall>[
|
||||
ProcessCall(getFlutterCommand(mockPlatform),
|
||||
const <String>['devices', '--machine'], null),
|
||||
ProcessCall(
|
||||
getFlutterCommand(mockPlatform),
|
||||
const <String>[
|
||||
'test',
|
||||
'-d',
|
||||
'macos',
|
||||
_fakeIOSDevice,
|
||||
'integration_test',
|
||||
],
|
||||
pluginExampleDirectory.path),
|
||||
|
Reference in New Issue
Block a user