From 208a418abc1905a3ba25c6f2e826dac601eb40b1 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 2 Jun 2022 13:33:08 -0700 Subject: [PATCH] flutter drive --enable-software-rendering --skia-deterministic-rendering (#105161) --- .../flutter_tools/lib/src/commands/run.dart | 28 ++++++++++--------- .../commands.shard/hermetic/drive_test.dart | 20 ++++++++++++- .../commands.shard/hermetic/run_test.dart | 22 ++++++++++++++- 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index d3e3bedd2c..0ea4c0083e 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -133,6 +133,19 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment 'this comma separated list of allowed prefixes.', valueHelp: 'skia.gpu,skia.shaders', ) + ..addFlag('enable-software-rendering', + negatable: false, + help: 'Enable rendering using the Skia software backend. ' + 'This is useful when testing Flutter on emulators. By default, ' + 'Flutter will attempt to either use OpenGL or Vulkan and fall back ' + 'to software when neither is available.', + ) + ..addFlag('skia-deterministic-rendering', + negatable: false, + help: 'When combined with "--enable-software-rendering", this should provide completely ' + 'deterministic (i.e. reproducible) Skia rendering. This is useful for testing purposes ' + '(e.g. when comparing screenshots).', + ) ..addMultiOption('dart-entrypoint-args', abbr: 'a', help: 'Pass a list of arguments to the Dart entrypoint at application ' @@ -184,6 +197,8 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment String get traceAllowlist => stringArgDeprecated('trace-allowlist'); /// Create a debugging options instance for the current `run` or `drive` invocation. + @visibleForTesting + @protected Future createDebuggingOptions(bool webMode) async { final BuildInfo buildInfo = await getBuildInfo(); final int browserDebugPort = featureFlags.isWebEnabled && argResults.wasParsed('web-browser-debug-port') @@ -268,19 +283,6 @@ class RunCommand extends RunCommandBase { addMultidexOption(); addIgnoreDeprecationOption(); argParser - ..addFlag('enable-software-rendering', - negatable: false, - help: 'Enable rendering using the Skia software backend. ' - 'This is useful when testing Flutter on emulators. By default, ' - 'Flutter will attempt to either use OpenGL or Vulkan and fall back ' - 'to software when neither is available.', - ) - ..addFlag('skia-deterministic-rendering', - negatable: false, - help: 'When combined with "--enable-software-rendering", this should provide completely ' - 'deterministic (i.e. reproducible) Skia rendering. This is useful for testing purposes ' - '(e.g. when comparing screenshots).', - ) ..addFlag('await-first-frame-when-tracing', defaultsTo: true, help: 'Whether to wait for the first frame when tracing startup ("--trace-startup"), ' diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart index c91169cd45..e80ee24d5e 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart @@ -208,7 +208,7 @@ void main() { Pub: () => FakePub(), }); - testUsingContext('--enable-impeller flag propagates to debugging options', () async { + testUsingContext('flags propagate to debugging options', () async { final DriveCommand command = DriveCommand(fileSystem: fileSystem, logger: logger, platform: platform); fileSystem.file('lib/main.dart').createSync(recursive: true); fileSystem.file('test_driver/main_test.dart').createSync(recursive: true); @@ -216,12 +216,30 @@ void main() { await expectLater(() => createTestCommandRunner(command).run([ 'drive', + '--start-paused', + '--disable-service-auth-codes', + '--trace-skia', + '--trace-systrace', + '--verbose-system-logs', + '--null-assertions', + '--native-null-assertions', '--enable-impeller', + '--enable-software-rendering', + '--skia-deterministic-rendering', ]), throwsToolExit()); final DebuggingOptions options = await command.createDebuggingOptions(false); + expect(options.startPaused, true); + expect(options.disableServiceAuthCodes, true); + expect(options.traceSkia, true); + expect(options.traceSystrace, true); + expect(options.verboseSystemLogs, true); + expect(options.nullAssertions, true); + expect(options.nativeNullAssertions, true); expect(options.enableImpeller, true); + expect(options.enableSoftwareRendering, true); + expect(options.skiaDeterministicRendering, true); }, overrides: { Cache: () => Cache.test(processManager: FakeProcessManager.any()), FileSystem: () => MemoryFileSystem.test(), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index e5d6fe22d5..3713e2021e 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -721,16 +721,36 @@ void main() { ProcessManager: () => FakeProcessManager.any(), }); - testUsingContext('--enable-impeller flag propagates to debugging options', () async { + testUsingContext('flags propagate to debugging options', () async { final RunCommand command = RunCommand(); await expectLater(() => createTestCommandRunner(command).run([ 'run', + '--start-paused', + '--disable-service-auth-codes', + '--use-test-fonts', + '--trace-skia', + '--trace-systrace', + '--verbose-system-logs', + '--null-assertions', + '--native-null-assertions', '--enable-impeller', + '--enable-software-rendering', + '--skia-deterministic-rendering', ]), throwsToolExit()); final DebuggingOptions options = await command.createDebuggingOptions(false); + expect(options.startPaused, true); + expect(options.disableServiceAuthCodes, true); + expect(options.useTestFonts, true); + expect(options.traceSkia, true); + expect(options.traceSystrace, true); + expect(options.verboseSystemLogs, true); + expect(options.nullAssertions, true); + expect(options.nativeNullAssertions, true); expect(options.enableImpeller, true); + expect(options.enableSoftwareRendering, true); + expect(options.skiaDeterministicRendering, true); }, overrides: { Cache: () => Cache.test(processManager: FakeProcessManager.any()), FileSystem: () => MemoryFileSystem.test(),