Support disabling animations in the CLI (#132239)
This commit is contained in:
@@ -238,6 +238,9 @@ class FakeTerminal implements Terminal {
|
||||
@override
|
||||
bool get supportsColor => terminal.supportsColor;
|
||||
|
||||
@override
|
||||
bool get isCliAnimationEnabled => terminal.isCliAnimationEnabled;
|
||||
|
||||
@override
|
||||
bool get supportsEmoji => terminal.supportsEmoji;
|
||||
|
||||
|
||||
@@ -882,6 +882,9 @@ class FakeTerminal extends Fake implements AnsiTerminal {
|
||||
@override
|
||||
final bool supportsColor;
|
||||
|
||||
@override
|
||||
bool get isCliAnimationEnabled => supportsColor;
|
||||
|
||||
@override
|
||||
bool singleCharMode = false;
|
||||
|
||||
|
||||
@@ -1228,4 +1228,7 @@ class FakeDevice extends Fake implements Device {
|
||||
class FakeTerminal extends Fake implements AnsiTerminal {
|
||||
@override
|
||||
final bool supportsColor = false;
|
||||
|
||||
@override
|
||||
bool get isCliAnimationEnabled => supportsColor;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ void main() {
|
||||
group('CommandHelp', () {
|
||||
group('toString', () {
|
||||
testWithoutContext('ends with a resetBold when it has parenthetical text', () {
|
||||
// This is apparently required to work around bugs in some terminal clients.
|
||||
final Platform platform = FakePlatform(stdoutSupportsAnsi: true);
|
||||
final AnsiTerminal terminal = AnsiTerminal(stdio: FakeStdio(), platform: platform);
|
||||
|
||||
@@ -131,19 +132,19 @@ void main() {
|
||||
wrapColumn: maxLineWidth,
|
||||
);
|
||||
|
||||
expect(commandHelp.I.toString(), endsWith('\x1B[90m(debugInvertOversizedImages)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.L.toString(), endsWith('\x1B[90m(debugDumpLayerTree)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.P.toString(), endsWith('\x1B[90m(WidgetsApp.showPerformanceOverlay)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.S.toString(), endsWith('\x1B[90m(debugDumpSemantics)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.U.toString(), endsWith('\x1B[90m(debugDumpSemantics)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.a.toString(), endsWith('\x1B[90m(debugProfileWidgetBuilds)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.b.toString(), endsWith('\x1B[90m(debugBrightnessOverride)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.f.toString(), endsWith('\x1B[90m(debugDumpFocusTree)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.i.toString(), endsWith('\x1B[90m(WidgetsApp.showWidgetInspectorOverride)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.o.toString(), endsWith('\x1B[90m(defaultTargetPlatform)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.p.toString(), endsWith('\x1B[90m(debugPaintSizeEnabled)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.t.toString(), endsWith('\x1B[90m(debugDumpRenderTree)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.w.toString(), endsWith('\x1B[90m(debugDumpApp)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.I.toString(), contains('\x1B[90m(debugInvertOversizedImages)\x1B[39m'));
|
||||
expect(commandHelp.L.toString(), contains('\x1B[90m(debugDumpLayerTree)\x1B[39m'));
|
||||
expect(commandHelp.P.toString(), contains('\x1B[90m(WidgetsApp.showPerformanceOverlay)\x1B[39m'));
|
||||
expect(commandHelp.S.toString(), contains('\x1B[90m(debugDumpSemantics)\x1B[39m'));
|
||||
expect(commandHelp.U.toString(), contains('\x1B[90m(debugDumpSemantics)\x1B[39m'));
|
||||
expect(commandHelp.a.toString(), contains('\x1B[90m(debugProfileWidgetBuilds)\x1B[39m'));
|
||||
expect(commandHelp.b.toString(), contains('\x1B[90m(debugBrightnessOverride)\x1B[39m'));
|
||||
expect(commandHelp.f.toString(), contains('\x1B[90m(debugDumpFocusTree)\x1B[39m'));
|
||||
expect(commandHelp.i.toString(), contains('\x1B[90m(WidgetsApp.showWidgetInspectorOverride)\x1B[39m'));
|
||||
expect(commandHelp.o.toString(), contains('\x1B[90m(defaultTargetPlatform)\x1B[39m'));
|
||||
expect(commandHelp.p.toString(), contains('\x1B[90m(debugPaintSizeEnabled)\x1B[39m'));
|
||||
expect(commandHelp.t.toString(), contains('\x1B[90m(debugDumpRenderTree)\x1B[39m'));
|
||||
expect(commandHelp.w.toString(), contains('\x1B[90m(debugDumpApp)\x1B[39m'));
|
||||
});
|
||||
|
||||
testWithoutContext('should not create a help text longer than maxLineWidth without ansi support', () {
|
||||
@@ -184,6 +185,7 @@ void main() {
|
||||
wrapColumn: maxLineWidth,
|
||||
);
|
||||
|
||||
// The trailing \x1B[22m is to work around reported bugs in some terminal clients.
|
||||
expect(commandHelp.I.toString(), equals('\x1B[1mI\x1B[22m Toggle oversized image inversion. \x1B[90m(debugInvertOversizedImages)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.L.toString(), equals('\x1B[1mL\x1B[22m Dump layer tree to the console. \x1B[90m(debugDumpLayerTree)\x1B[39m\x1B[22m'));
|
||||
expect(commandHelp.M.toString(), equals('\x1B[1mM\x1B[22m Write SkSL shaders to a unique file in the project directory.'));
|
||||
|
||||
@@ -1286,6 +1286,46 @@ void main() {
|
||||
expect(mockLogger.traceText, 'Oooh, I do I do I do\n');
|
||||
expect(mockLogger.errorText, 'Helpless!\n$stackTrace\n');
|
||||
});
|
||||
|
||||
testWithoutContext('Animations are disabled when, uh, disabled.', () async {
|
||||
final Logger logger = StdoutLogger(
|
||||
terminal: AnsiTerminal(
|
||||
stdio: fakeStdio,
|
||||
platform: _kNoAnsiPlatform,
|
||||
isCliAnimationEnabled: false,
|
||||
),
|
||||
stdio: fakeStdio,
|
||||
outputPreferences: OutputPreferences.test(wrapText: true, wrapColumn: 40),
|
||||
);
|
||||
logger.startProgress('po').stop();
|
||||
expect(outputStderr(), <String>['']);
|
||||
expect(outputStdout(), <String>[
|
||||
'po 0ms',
|
||||
'',
|
||||
]);
|
||||
logger.startProgress('ta')
|
||||
..pause()
|
||||
..resume()
|
||||
..stop();
|
||||
expect(outputStderr(), <String>['']);
|
||||
expect(outputStdout(), <String>[
|
||||
'po 0ms',
|
||||
'ta ',
|
||||
'ta 0ms',
|
||||
'',
|
||||
]);
|
||||
logger.startSpinner()
|
||||
..pause()
|
||||
..resume()
|
||||
..stop();
|
||||
expect(outputStderr(), <String>['']);
|
||||
expect(outputStdout(), <String>[
|
||||
'po 0ms',
|
||||
'ta ',
|
||||
'ta 0ms',
|
||||
'',
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2884,6 +2884,9 @@ class FakeTerminal extends Fake implements AnsiTerminal {
|
||||
@override
|
||||
final bool supportsColor;
|
||||
|
||||
@override
|
||||
bool get isCliAnimationEnabled => supportsColor;
|
||||
|
||||
@override
|
||||
bool usesTerminalUi = true;
|
||||
|
||||
|
||||
@@ -448,6 +448,7 @@ class TestFeatureFlags implements FeatureFlags {
|
||||
this.isFuchsiaEnabled = false,
|
||||
this.areCustomDevicesEnabled = false,
|
||||
this.isFlutterWebWasmEnabled = false,
|
||||
this.isCliAnimationEnabled = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -477,6 +478,9 @@ class TestFeatureFlags implements FeatureFlags {
|
||||
@override
|
||||
final bool isFlutterWebWasmEnabled;
|
||||
|
||||
@override
|
||||
final bool isCliAnimationEnabled;
|
||||
|
||||
@override
|
||||
bool isEnabled(Feature feature) {
|
||||
switch (feature) {
|
||||
@@ -496,6 +500,8 @@ class TestFeatureFlags implements FeatureFlags {
|
||||
return isFuchsiaEnabled;
|
||||
case flutterCustomDevicesFeature:
|
||||
return areCustomDevicesEnabled;
|
||||
case cliAnimation:
|
||||
return isCliAnimationEnabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user