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() { ...@@ -71,7 +71,7 @@ void main() {
'The null value was thrown CONTEXTING.\n' 'The null value was thrown CONTEXTING.\n'
'\n' '\n'
'INFO\n' 'INFO\n'
'═════════════════════════════════════════════════════════════════\n' '═════════════════════════════════════════════════════════════════\n',
); );
expect( expect(
FlutterErrorDetails( FlutterErrorDetails(
...@@ -116,7 +116,7 @@ void main() { ...@@ -116,7 +116,7 @@ void main() {
FlutterErrorDetails(exception: NullThrownError()).toString(), FlutterErrorDetails(exception: NullThrownError()).toString(),
'══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════\n' '══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞══════════════════════\n'
'The null value was thrown.\n' 'The null value was thrown.\n'
'═════════════════════════════════════════════════════════════════\n' '═════════════════════════════════════════════════════════════════\n',
); );
}); });
...@@ -138,7 +138,7 @@ void main() { ...@@ -138,7 +138,7 @@ void main() {
FlutterError error = FlutterError( FlutterError error = FlutterError(
'My Error Summary.\n' 'My Error Summary.\n'
'My first description.\n' 'My first description.\n'
'My second description.' 'My second description.',
); );
expect(error.diagnostics.length, equals(3)); expect(error.diagnostics.length, equals(3));
expect(error.diagnostics[0].level, DiagnosticLevel.summary); expect(error.diagnostics[0].level, DiagnosticLevel.summary);
...@@ -159,7 +159,7 @@ void main() { ...@@ -159,7 +159,7 @@ void main() {
'My Error Summary.\n' 'My Error Summary.\n'
'My first description.\n' 'My first description.\n'
'My second description.\n' 'My second description.\n'
'\n' '\n',
); );
expect(error.diagnostics.length, equals(5)); expect(error.diagnostics.length, equals(5));
...@@ -185,7 +185,7 @@ void main() { ...@@ -185,7 +185,7 @@ void main() {
'My Error Summary.\n' 'My Error Summary.\n'
'My first description.\n' 'My first description.\n'
'\n' '\n'
'My second description.' 'My second description.',
); );
expect(error.diagnostics.length, equals(4)); expect(error.diagnostics.length, equals(4));
expect(error.diagnostics[0].level, DiagnosticLevel.summary); expect(error.diagnostics[0].level, DiagnosticLevel.summary);
...@@ -238,7 +238,8 @@ void main() { ...@@ -238,7 +238,8 @@ void main() {
final AssertionError error; final AssertionError error;
try { try {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
(ErrorDescription('Error description without a summary'))]); ErrorDescription('Error description without a summary'),
]);
} on AssertionError catch (e) { } on AssertionError catch (e) {
error = e; error = e;
} }
......
...@@ -172,8 +172,7 @@ void main() { ...@@ -172,8 +172,7 @@ void main() {
log.clear(); 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 TestNotifier source = TestNotifier();
final List<String> log = <String>[]; final List<String> log = <String>[];
...@@ -201,7 +200,8 @@ void main() { ...@@ -201,7 +200,8 @@ void main() {
test( test(
'If a listener in the middle of the list of listeners removes itself, ' 'If a listener in the middle of the list of listeners removes itself, '
'notifyListeners still notifies all listeners', () { 'notifyListeners still notifies all listeners',
() {
final TestNotifier source = TestNotifier(); final TestNotifier source = TestNotifier();
final List<String> log = <String>[]; final List<String> log = <String>[];
...@@ -221,11 +221,10 @@ void main() { ...@@ -221,11 +221,10 @@ void main() {
source.notify(); source.notify();
expect(log, <String>['listener1', 'selfRemovingListener', 'listener1']); expect(log, <String>['listener1', 'selfRemovingListener', 'listener1']);
}); },
);
test( test('If the first listener removes itself, notifyListeners still notify all listeners', () {
'If the first listener removes itself, notifyListeners still notify all listeners',
() {
final TestNotifier source = TestNotifier(); final TestNotifier source = TestNotifier();
final List<String> log = <String>[]; final List<String> log = <String>[];
...@@ -458,10 +457,13 @@ void main() { ...@@ -458,10 +457,13 @@ void main() {
expect(error!, isFlutterError); expect(error!, isFlutterError);
expect( expect(
error.toStringDeep(), error.toStringDeep(),
equalsIgnoringHashCodes('FlutterError\n' equalsIgnoringHashCodes(
'FlutterError\n'
' A TestNotifier was used after being disposed.\n' ' A TestNotifier was used after being disposed.\n'
' Once you have called dispose() on a TestNotifier, it can no\n' ' Once you have called dispose() on a TestNotifier, it can no\n'
' longer be used.\n')); ' longer be used.\n',
),
);
}); });
test('notifyListener can be called recursively', () { test('notifyListener can be called recursively', () {
...@@ -524,7 +526,7 @@ void main() { ...@@ -524,7 +526,7 @@ void main() {
8, 8,
9, 9,
10, 10,
11 11,
]; ];
final List<String> expectedLog = final List<String> expectedLog =
remainingListenerIndexes.map((int i) => 'listener$i').toList(); remainingListenerIndexes.map((int i) => 'listener$i').toList();
......
...@@ -82,7 +82,9 @@ void main() { ...@@ -82,7 +82,9 @@ void main() {
// collisions are guaranteed. These should be sorted so that the 'order' // collisions are guaranteed. These should be sorted so that the 'order'
// part of the objects are still in order. // part of the objects are still in order.
final List<OrderedComparable> list = List<OrderedComparable>.generate( 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); mergeSort(list);
OrderedComparable prev = list[0]; OrderedComparable prev = list[0];
for (int i = 1; i < size; i++) { for (int i = 1; i < size; i++) {
...@@ -121,8 +123,7 @@ void main() { ...@@ -121,8 +123,7 @@ void main() {
test('MergeSortSpecialCases', () { test('MergeSortSpecialCases', () {
for (final int size in <int>[511, 512, 513]) { for (final int size in <int>[511, 512, 513]) {
// All equal. // All equal.
final List<OrderedComparable> list = List<OrderedComparable>.generate( final List<OrderedComparable> list = List<OrderedComparable>.generate(size, (int i) => OrderedComparable(0, i));
size, (int i) => OrderedComparable(0, i));
mergeSort(list); mergeSort(list);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
expect(list[i].order, equals(i)); expect(list[i].order, equals(i));
......
...@@ -166,16 +166,14 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse { ...@@ -166,16 +166,14 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
@override @override
StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) { StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) {
if (error != null) { if (error != null) {
return Stream<List<int>>.fromFuture( return Stream<List<int>>.fromFuture(Future<List<int>>.error(error as Object)).listen(
Future<List<int>>.error(error as Object)).listen(
onData, onData,
onDone: onDone, onDone: onDone,
onError: onError, onError: onError,
cancelOnError: cancelOnError, cancelOnError: cancelOnError,
); );
} }
return Stream<List<int>>.fromIterable( return Stream<List<int>>.fromIterable(<List<int>>[chunkOne, chunkTwo]).listen(
<List<int>>[chunkOne, chunkTwo]).listen(
onData, onData,
onDone: onDone, onDone: onDone,
onError: onError, onError: onError,
......
...@@ -905,8 +905,8 @@ void main() { ...@@ -905,8 +905,8 @@ void main() {
throwsA(isAssertionError.having( throwsA(isAssertionError.having(
(AssertionError e) => e.message, (AssertionError e) => e.message,
'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() { ...@@ -1882,7 +1882,7 @@ void main() {
final StackTrace stack = StackTrace.fromString( final StackTrace stack = StackTrace.fromString(
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\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( expect(
...@@ -1891,7 +1891,7 @@ void main() { ...@@ -1891,7 +1891,7 @@ void main() {
'Stack trace:\n' 'Stack trace:\n'
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\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() { ...@@ -1901,7 +1901,7 @@ void main() {
'-- callback 2 --\n' '-- callback 2 --\n'
'#0 someMethod (file:///diagnostics_test.dart:42:19)\n' '#0 someMethod (file:///diagnostics_test.dart:42:19)\n'
'#1 someMethod2 (file:///diagnostics_test.dart:12:3)\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,7 +2164,7 @@ void main() { ...@@ -2164,7 +2164,7 @@ void main() {
' [1.0, 0.0, 0.0, 1.0]\n' ' [1.0, 0.0, 0.0, 1.0]\n'
' --- example property at max length --\n' ' --- example property at max length --\n'
' diagnosis: insufficient data to draw\n' ' diagnosis: insufficient data to draw\n'
' conclusion (less than five repaints)\n' ' conclusion (less than five repaints)\n',
), ),
); );
...@@ -2239,7 +2239,7 @@ void main() { ...@@ -2239,7 +2239,7 @@ void main() {
'diagnosis:\n' 'diagnosis:\n'
' insufficient data to draw conclusion\n' ' insufficient data to draw conclusion\n'
' (less than five repaints)\n' ' (less than five repaints)\n'
'════════════════════════════════════════\n' '════════════════════════════════════════\n',
), ),
); );
}); });
......
...@@ -78,7 +78,7 @@ Future<void> main() async { ...@@ -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'#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'#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'#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(); console.clear();
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
...@@ -145,7 +145,7 @@ Future<void> main() async { ...@@ -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'#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'#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'#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(); console.clear();
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
...@@ -158,8 +158,7 @@ Future<void> main() async { ...@@ -158,8 +158,7 @@ Future<void> main() async {
test('Error reporting - NoSuchMethodError', () async { test('Error reporting - NoSuchMethodError', () async {
expect(console, isEmpty); expect(console, isEmpty);
final Object exception = NoSuchMethodError.withInvocation(5, final Object exception = NoSuchMethodError.withInvocation(5, Invocation.method(#foo, <dynamic>[2, 4]));
Invocation.method(#foo, <dynamic>[2, 4]));
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception, exception: exception,
...@@ -174,8 +173,10 @@ Future<void> main() async { ...@@ -174,8 +173,10 @@ Future<void> main() async {
FlutterError.dumpErrorToConsole(FlutterErrorDetails( FlutterError.dumpErrorToConsole(FlutterErrorDetails(
exception: exception, exception: exception,
)); ));
expect(console.join('\n'), expect(
'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)'); console.join('\n'),
'Another exception was thrown: NoSuchMethodError: int has no foo method accepting arguments (_, _)',
);
console.clear(); console.clear();
FlutterError.resetErrorCount(); FlutterError.resetErrorCount();
}); });
......
...@@ -245,7 +245,7 @@ void main() { ...@@ -245,7 +245,7 @@ void main() {
r' window size: Size\(2400\.0, 1800\.0\) \(in physical pixels\)\n' 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' 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' configuration: Size\(800\.0, 600\.0\) at 3\.0x \(in logical pixels\)\n'
r'$' r'$',
), ),
}); });
}); });
...@@ -267,7 +267,7 @@ void main() { ...@@ -267,7 +267,7 @@ void main() {
r' \[1] 0\.0,3\.0,0\.0,0\.0\n' r' \[1] 0\.0,3\.0,0\.0,0\.0\n'
r' \[2] 0\.0,0\.0,1\.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' \[3] 0\.0,0\.0,0\.0,1\.0\n'
r'$' r'$',
), ),
}); });
}); });
...@@ -277,7 +277,7 @@ void main() { ...@@ -277,7 +277,7 @@ void main() {
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{}); final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{});
expect(result, <String, String>{ expect(result, <String, String>{
'data': 'Semantics not collected.' 'data': 'Semantics not collected.',
}); });
}); });
...@@ -286,7 +286,7 @@ void main() { ...@@ -286,7 +286,7 @@ void main() {
final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', <String, String>{}); final Map<String, dynamic> result = await binding.testExtension('debugDumpSemanticsTreeInInverseHitTestOrder', <String, String>{});
expect(result, <String, String>{ expect(result, <String, String>{
'data': 'Semantics not collected.' 'data': 'Semantics not collected.',
}); });
}); });
......
...@@ -92,8 +92,7 @@ void main() { ...@@ -92,8 +92,7 @@ void main() {
expect(events[0], isA<PointerHoverEvent>()); expect(events[0], isA<PointerHoverEvent>());
expect(events[1], isA<PointerHoverEvent>()); expect(events[1], isA<PointerHoverEvent>());
expect(events[2], isA<PointerHoverEvent>()); expect(events[2], isA<PointerHoverEvent>());
expect(pointerRouterEvents.length, 6, expect(pointerRouterEvents.length, 6, reason: 'pointerRouterEvents contains: $pointerRouterEvents');
reason: 'pointerRouterEvents contains: $pointerRouterEvents');
expect(pointerRouterEvents[0], isA<PointerAddedEvent>()); expect(pointerRouterEvents[0], isA<PointerAddedEvent>());
expect(pointerRouterEvents[1], isA<PointerHoverEvent>()); expect(pointerRouterEvents[1], isA<PointerHoverEvent>());
expect(pointerRouterEvents[2], isA<PointerHoverEvent>()); expect(pointerRouterEvents[2], isA<PointerHoverEvent>());
...@@ -151,8 +150,7 @@ void main() { ...@@ -151,8 +150,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5); expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>()); expect(events[0], isA<PointerAddedEvent>());
...@@ -170,8 +168,7 @@ void main() { ...@@ -170,8 +168,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 2); expect(events.length, 2);
expect(events[0], isA<PointerAddedEvent>()); expect(events[0], isA<PointerAddedEvent>());
...@@ -191,8 +188,7 @@ void main() { ...@@ -191,8 +188,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5); expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>()); expect(events[0], isA<PointerAddedEvent>());
...@@ -224,8 +220,7 @@ void main() { ...@@ -224,8 +220,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5); expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>()); expect(events[0], isA<PointerAddedEvent>());
...@@ -254,8 +249,7 @@ void main() { ...@@ -254,8 +249,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5); expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>()); expect(events[0], isA<PointerAddedEvent>());
...@@ -285,8 +279,7 @@ void main() { ...@@ -285,8 +279,7 @@ void main() {
], ],
); );
final List<PointerEvent> events = PointerEventConverter.expand( final List<PointerEvent> events = PointerEventConverter.expand(packet.data, ui.window.devicePixelRatio).toList();
packet.data, ui.window.devicePixelRatio).toList();
expect(events.length, 5); expect(events.length, 5);
expect(events[0], isA<PointerAddedEvent>()); 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