Unverified Commit c5a3ee7f authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

add trailing commas in flutter/test/{foundation,gestures} (#80926)

parent 7769b000
......@@ -71,7 +71,7 @@ void main() {
'The null value was thrown CONTEXTING.\n'
'\n'
'INFO\n'
'═════════════════════════════════════════════════════════════════\n'
'═════════════════════════════════════════════════════════════════\n',
);
expect(
FlutterErrorDetails(
......@@ -116,7 +116,7 @@ void main() {
FlutterErrorDetails(exception: NullThrownError()).toString(),
'══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════\n'
'The null value was thrown.\n'
'═════════════════════════════════════════════════════════════════\n'
'═════════════════════════════════════════════════════════════════\n',
);
});
......@@ -138,7 +138,7 @@ void main() {
FlutterError error = FlutterError(
'My Error Summary.\n'
'My first description.\n'
'My second description.'
'My second description.',
);
expect(error.diagnostics.length, equals(3));
expect(error.diagnostics[0].level, DiagnosticLevel.summary);
......@@ -159,7 +159,7 @@ void main() {
'My Error Summary.\n'
'My first description.\n'
'My second description.\n'
'\n'
'\n',
);
expect(error.diagnostics.length, equals(5));
......@@ -185,7 +185,7 @@ void main() {
'My Error Summary.\n'
'My first description.\n'
'\n'
'My second description.'
'My second description.',
);
expect(error.diagnostics.length, equals(4));
expect(error.diagnostics[0].level, DiagnosticLevel.summary);
......@@ -238,7 +238,8 @@ void main() {
final AssertionError error;
try {
throw FlutterError.fromParts(<DiagnosticsNode>[
(ErrorDescription('Error description without a summary'))]);
ErrorDescription('Error description without a summary'),
]);
} on AssertionError catch (e) {
error = e;
}
......
......@@ -172,8 +172,7 @@ void main() {
log.clear();
});
test('During notifyListeners, a listener was added and removed immediately',
() {
test('During notifyListeners, a listener was added and removed immediately', () {
final TestNotifier source = TestNotifier();
final List<String> log = <String>[];
......@@ -200,32 +199,32 @@ void main() {
});
test(
'If a listener in the middle of the list of listeners removes itself, '
'notifyListeners still notifies all listeners', () {
final TestNotifier source = TestNotifier();
final List<String> log = <String>[];
void selfRemovingListener() {
log.add('selfRemovingListener');
source.removeListener(selfRemovingListener);
}
'If a listener in the middle of the list of listeners removes itself, '
'notifyListeners still notifies all listeners',
() {
final TestNotifier source = TestNotifier();
final List<String> log = <String>[];
void selfRemovingListener() {
log.add('selfRemovingListener');
source.removeListener(selfRemovingListener);
}
void listener1() {
log.add('listener1');
}
void listener1() {
log.add('listener1');
}
source.addListener(listener1);
source.addListener(selfRemovingListener);
source.addListener(listener1);
source.addListener(listener1);
source.addListener(selfRemovingListener);
source.addListener(listener1);
source.notify();
source.notify();
expect(log, <String>['listener1', 'selfRemovingListener', 'listener1']);
});
expect(log, <String>['listener1', 'selfRemovingListener', 'listener1']);
},
);
test(
'If the first listener removes itself, notifyListeners still notify all listeners',
() {
test('If the first listener removes itself, notifyListeners still notify all listeners', () {
final TestNotifier source = TestNotifier();
final List<String> log = <String>[];
......@@ -457,11 +456,14 @@ void main() {
expect(error, isNotNull);
expect(error!, isFlutterError);
expect(
error.toStringDeep(),
equalsIgnoringHashCodes('FlutterError\n'
' A TestNotifier was used after being disposed.\n'
' Once you have called dispose() on a TestNotifier, it can no\n'
' longer be used.\n'));
error.toStringDeep(),
equalsIgnoringHashCodes(
'FlutterError\n'
' A TestNotifier was used after being disposed.\n'
' Once you have called dispose() on a TestNotifier, it can no\n'
' longer be used.\n',
),
);
});
test('notifyListener can be called recursively', () {
......@@ -524,7 +526,7 @@ void main() {
8,
9,
10,
11
11,
];
final List<String> expectedLog =
remainingListenerIndexes.map((int i) => 'listener$i').toList();
......
......@@ -82,7 +82,9 @@ void main() {
// collisions are guaranteed. These should be sorted so that the 'order'
// part of the objects are still in order.
final List<OrderedComparable> list = List<OrderedComparable>.generate(
size, (int i) => OrderedComparable(random.nextInt(size >> 2), i));
size,
(int i) => OrderedComparable(random.nextInt(size >> 2), i),
);
mergeSort(list);
OrderedComparable prev = list[0];
for (int i = 1; i < size; i++) {
......@@ -121,8 +123,7 @@ void main() {
test('MergeSortSpecialCases', () {
for (final int size in <int>[511, 512, 513]) {
// All equal.
final List<OrderedComparable> list = List<OrderedComparable>.generate(
size, (int i) => OrderedComparable(0, i));
final List<OrderedComparable> list = List<OrderedComparable>.generate(size, (int i) => OrderedComparable(0, i));
mergeSort(list);
for (int i = 0; i < size; i++) {
expect(list[i].order, equals(i));
......
......@@ -166,16 +166,14 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
@override
StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) {
if (error != null) {
return Stream<List<int>>.fromFuture(
Future<List<int>>.error(error as Object)).listen(
return Stream<List<int>>.fromFuture(Future<List<int>>.error(error as Object)).listen(
onData,
onDone: onDone,
onError: onError,
cancelOnError: cancelOnError,
);
}
return Stream<List<int>>.fromIterable(
<List<int>>[chunkOne, chunkTwo]).listen(
return Stream<List<int>>.fromIterable(<List<int>>[chunkOne, chunkTwo]).listen(
onData,
onDone: onDone,
onError: onError,
......
......@@ -905,8 +905,8 @@ void main() {
throwsA(isAssertionError.having(
(AssertionError e) => e.message,
'message',
'The provided object "Hello World" is not an enum.'),
),
'The provided object "Hello World" is not an enum.',
)),
);
});
......@@ -1882,7 +1882,7 @@ void main() {
final StackTrace stack = StackTrace.fromString(
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n',
);
expect(
......@@ -1891,7 +1891,7 @@ void main() {
'Stack trace:\n'
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n',
),
);
......@@ -1901,7 +1901,7 @@ void main() {
'-- callback 2 --\n'
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n'
'#2 someMethod3 (file:///foo.dart:4:1)\n',
),
);
});
......@@ -2164,83 +2164,83 @@ void main() {
' [1.0, 0.0, 0.0, 1.0]\n'
' --- example property at max length --\n'
' diagnosis: insufficient data to draw\n'
' conclusion (less than five repaints)\n'
' conclusion (less than five repaints)\n',
),
);
// This case matches the styles that should generally be used for error
// messages
expect(
renderer.render(createTreeWithWrappingNodes(
rootStyle: DiagnosticsTreeStyle.error,
propertyStyle: DiagnosticsTreeStyle.errorProperty,
)),
equalsIgnoringHashCodes(
'══╡ TESTTREE#00000 ╞════════════════════\n'
'--- example property at max length --\n'
'This is a very long message that must\n'
'wrap as it cannot fit on one line. This\n'
'is a very long message that must wrap as\n'
'it cannot fit on one line. This is a\n'
'very long message that must wrap as it\n'
'cannot fit on one line.\n'
'--- example property at max length --\n'
'Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap.\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' https://goo.gl/\n'
'Click on the following url:\n'
' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n'
'Click on the following url\n'
' https://goo.gl/\n'
'--- example property at max length --\n'
'multi-line value:\n'
' [1.0, 0.0, 0.0, 0.0]\n'
' [1.0, 1.0, 0.0, 0.0]\n'
' [1.0, 0.0, 1.0, 0.0]\n'
' [1.0, 0.0, 0.0, 1.0]\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' [1.0, 0.0, 0.0, 0.0]\n'
' [1.0, 1.0, 0.0, 0.0]\n'
' [1.0, 0.0, 1.0, 0.0]\n'
' [1.0, 0.0, 0.0, 1.0]\n'
'--- example property at max length --\n'
'diagnosis:\n'
' insufficient data to draw conclusion\n'
' (less than five repaints)\n'
'════════════════════════════════════════\n'
),
renderer.render(createTreeWithWrappingNodes(
rootStyle: DiagnosticsTreeStyle.error,
propertyStyle: DiagnosticsTreeStyle.errorProperty,
)),
equalsIgnoringHashCodes(
'══╡ TESTTREE#00000 ╞════════════════════\n'
'--- example property at max length --\n'
'This is a very long message that must\n'
'wrap as it cannot fit on one line. This\n'
'is a very long message that must wrap as\n'
'it cannot fit on one line. This is a\n'
'very long message that must wrap as it\n'
'cannot fit on one line.\n'
'--- example property at max length --\n'
'Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap even though it is very long. Message that is not allowed to wrap.\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' https://goo.gl/\n'
'Click on the following url:\n'
' http://someverylongurl.com/that-might-be-tempting-to-wrap-even-though-it-is-a-url-so-should-not-wrap.html\n'
'Click on the following url\n'
' https://goo.gl/\n'
'--- example property at max length --\n'
'multi-line value:\n'
' [1.0, 0.0, 0.0, 0.0]\n'
' [1.0, 1.0, 0.0, 0.0]\n'
' [1.0, 0.0, 1.0, 0.0]\n'
' [1.0, 0.0, 0.0, 1.0]\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
' This is a very long message that must\n'
' wrap as it cannot fit on one line.\n'
'--- example property at max length --\n'
'This property has a very long property\n'
'name that will be allowed to wrap unlike\n'
'most property names. This property has a\n'
'very long property name that will be\n'
'allowed to wrap unlike most property\n'
'names:\n'
' [1.0, 0.0, 0.0, 0.0]\n'
' [1.0, 1.0, 0.0, 0.0]\n'
' [1.0, 0.0, 1.0, 0.0]\n'
' [1.0, 0.0, 0.0, 1.0]\n'
'--- example property at max length --\n'
'diagnosis:\n'
' insufficient data to draw conclusion\n'
' (less than five repaints)\n'
'════════════════════════════════════════\n',
),
);
});
......
......@@ -78,7 +78,7 @@ Future<void> main() async {
r'#0 getSampleStack\.<anonymous closure> \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'#2 getSampleStack \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'#3 main \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
r'(.+\n)+', // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
));
console.clear();
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
......@@ -145,7 +145,7 @@ Future<void> main() async {
r'#0 getSampleStack\.<anonymous closure> \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'#2 getSampleStack \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'#3 main \([^)]+flutter/test/foundation/error_reporting_test\.dart:[0-9]+:[0-9]+\)\n'
r'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
r'(.+\n)+', // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
));
console.clear();
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
......@@ -158,8 +158,7 @@ Future<void> main() async {
test('Error reporting - NoSuchMethodError', () async {
expect(console, isEmpty);
final Object exception = NoSuchMethodError.withInvocation(5,
Invocation.method(#foo, <dynamic>[2, 4]));
final Object exception = NoSuchMethodError.withInvocation(5, Invocation.method(#foo, <dynamic>[2, 4]));
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception,
......@@ -174,8 +173,10 @@ Future<void> main() async {
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception,
));
expect(console.join('\n'),
'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)');
expect(
console.join('\n'),
'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)',
);
console.clear();
FlutterError.resetErrorCount();
});
......
......@@ -245,7 +245,7 @@ void main() {
r' window size: Size\(2400\.0, 1800\.0\) \(in physical pixels\)\n'
r' device pixel ratio: 3\.0 \(physical pixels per logical pixel\)\n'
r' configuration: Size\(800\.0, 600\.0\) at 3\.0x \(in logical pixels\)\n'
r'$'
r'$',
),
});
});
......@@ -267,7 +267,7 @@ void main() {
r' \[1] 0\.0,3\.0,0\.0,0\.0\n'
r' \[2] 0\.0,0\.0,1\.0,0\.0\n'
r' \[3] 0\.0,0\.0,0\.0,1\.0\n'
r'$'
r'$',
),
});
});
......@@ -277,7 +277,7 @@ void main() {
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{});
expect(result, <String, String>{
'data': 'Semantics not collected.'
'data': 'Semantics not collected.',
});
});
......@@ -286,7 +286,7 @@ void main() {
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', <String, String>{});
expect(result, <String, String>{
'data': 'Semantics not collected.'
'data': 'Semantics not collected.',
});
});
......
......@@ -92,8 +92,7 @@ void main() {
expect(events[0], isA<PointerHoverEvent>());
expect(events[1], isA<PointerHoverEvent>());
expect(events[2], isA<PointerHoverEvent>());
expect(pointerRouterEvents.length, 6,
reason: 'pointerRouterEvents contains: $pointerRouterEvents');
expect(pointerRouterEvents.length, 6, reason: 'pointerRouterEvents contains: $pointerRouterEvents');
expect(pointerRouterEvents[0], isA<PointerAddedEvent>());
expect(pointerRouterEvents[1], isA<PointerHoverEvent>());
expect(pointerRouterEvents[2], isA<PointerHoverEvent>());
......@@ -151,8 +150,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>());
......@@ -170,8 +168,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 2);
expect(events[0], isA<PointerAddedEvent>());
......@@ -191,8 +188,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>());
......@@ -224,8 +220,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>());
......@@ -254,8 +249,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>());
......@@ -285,8 +279,7 @@ void main() {
],
);
final List<PointerEvent> events = PointerEventConverter.expand(
packet.data, ui.window.devicePixelRatio).toList();
final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment