[flutter_tool] Report analytics as disabled when suppressed (#71728)
This commit is contained in:
parent
a12c22b296
commit
cd3aec3660
@ -84,9 +84,11 @@ class ConfigCommand extends FlutterCommand {
|
||||
if (values.isEmpty) {
|
||||
values = ' No settings have been configured.';
|
||||
}
|
||||
final bool analyticsEnabled = globals.flutterUsage.enabled &&
|
||||
!globals.flutterUsage.suppressAnalytics;
|
||||
return
|
||||
'\nSettings:\n$values\n\n'
|
||||
'Analytics reporting is currently ${globals.flutterUsage.enabled ? 'enabled' : 'disabled'}.';
|
||||
'Analytics reporting is currently ${analyticsEnabled ? 'enabled' : 'disabled'}.';
|
||||
}
|
||||
|
||||
/// Return null to disable analytics recording of the `config` command.
|
||||
|
@ -288,6 +288,24 @@ void main() {
|
||||
}, overrides: <Type, Generator>{
|
||||
Usage: () => mockUsage,
|
||||
});
|
||||
|
||||
testUsingContext('analytics reported disabled when suppressed', () async {
|
||||
final ConfigCommand configCommand = ConfigCommand();
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
|
||||
|
||||
mockUsage.suppressAnalytics = true;
|
||||
|
||||
await commandRunner.run(<String>[
|
||||
'config',
|
||||
]);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
containsIgnoringWhitespace('Analytics reporting is currently disabled'),
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Usage: () => mockUsage,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -306,4 +324,7 @@ class MockFlutterVersion extends Mock implements FlutterVersion {}
|
||||
class MockUsage extends Mock implements Usage {
|
||||
@override
|
||||
bool enabled = true;
|
||||
|
||||
@override
|
||||
bool suppressAnalytics = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user