Change --disable-dds to --no-dds to avoid double negatives (#80900)

Also, refactor internal code to do the same.

See https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-double-negatives-in-apis
This commit is contained in:
Ian Hickson
2021-04-23 16:29:38 -07:00
committed by GitHub
parent 7ec7d4dae6
commit e5414695d4
16 changed files with 132 additions and 41 deletions

View File

@@ -206,7 +206,7 @@ class TestFlutterDevice extends FlutterDevice {
CompileExpression compileExpression,
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
bool disableDds = false,
bool enableDds = true,
bool disableServiceAuthCodes = false,
int hostVmServicePort,
int ddsPort,

View File

@@ -231,7 +231,7 @@ void main() {
observatoryUri: Uri.parse('http://127.0.0.1:63426/1UasC_ihpXY=/'),
));
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, disableDds: true), true);
await driverService.start(BuildInfo.profile, device, DebuggingOptions.enabled(BuildInfo.profile, enableDds: false), true);
final int testResult = await driverService.startTest(
'foo.test',
<String>[],

View File

@@ -221,7 +221,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
packagesPath: '.dart_tool/package_config.json',
),
startPaused: false,
disableDds: false,
enableDds: true,
disableServiceAuthCodes: false,
hostVmServicePort: 1234,
nullAssertions: false,

View File

@@ -366,7 +366,7 @@ class TestFlutterDevice extends FlutterDevice {
GetSkSLMethod getSkSLMethod,
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
bool disableServiceAuthCodes = false,
bool disableDds = false,
bool enableDds = true,
bool ipv6 = false,
int hostVmServicePort,
int ddsPort,

View File

@@ -2517,7 +2517,7 @@ class FakeFlutterDevice extends FlutterDevice {
Future<void> connect({
ReloadSources reloadSources,
Restart restart,
bool disableDds = false,
bool enableDds = true,
bool disableServiceAuthCodes = false,
bool ipv6 = false,
CompileExpression compileExpression,

View File

@@ -87,7 +87,7 @@ void main() {
final CommandRunner<void> runner = createTestCommandRunner(flutterCommand);
await runner.run(<String>['deprecated']);
expect(testLogger.statusText,
expect(testLogger.errorText,
contains('The "deprecated" command is deprecated and will be removed in '
'a future version of Flutter.'));
expect(flutterCommand.usage,
@@ -546,6 +546,49 @@ void main() {
final BuildInfo buildInfo = await flutterCommand.getBuildInfo(forcedBuildMode: BuildMode.debug);
expect(buildInfo.packagesPath, 'foo');
});
testUsingContext('dds options', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--dds-port=1']);
expect(ddsCommand.enableDds, isTrue);
expect(ddsCommand.ddsPort, 1);
});
testUsingContext('dds options --dds', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--dds']);
expect(ddsCommand.enableDds, isTrue);
});
testUsingContext('dds options --no-dds', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--no-dds']);
expect(ddsCommand.enableDds, isFalse);
});
testUsingContext('dds options --disable-dds', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--disable-dds']);
expect(ddsCommand.enableDds, isFalse);
});
testUsingContext('dds options --no-disable-dds', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--no-disable-dds']);
expect(ddsCommand.enableDds, isTrue);
});
testUsingContext('dds options --dds --disable-dds', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
await runner.run(<String>['test', '--dds', '--disable-dds']);
expect(() => ddsCommand.enableDds, throwsToolExit());
});
});
}
@@ -611,6 +654,23 @@ class FakeReportingNullSafetyCommand extends FlutterCommand {
}
}
class FakeDdsCommand extends FlutterCommand {
FakeDdsCommand() {
addDdsOptions(verboseHelp: false);
}
@override
String get description => 'test';
@override
String get name => 'test';
@override
Future<FlutterCommandResult> runCommand() async {
return FlutterCommandResult.success();
}
}
class MockProcessInfo extends Mock implements ProcessInfo {}
class MockIoProcessSignal extends Mock implements io.ProcessSignal {}

View File

@@ -474,7 +474,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
if (!chrome)
'--disable-service-auth-codes',
'--machine',
if (!spawnDdsInstance) '--disable-dds',
if (!spawnDdsInstance) '--no-dds',
...getLocalEngineArguments(),
'-d',
if (chrome)
@@ -512,7 +512,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
...getLocalEngineArguments(),
'--machine',
if (!spawnDdsInstance)
'--disable-dds',
'--no-dds',
'-d',
'flutter-tester',
'--debug-port',