Unverified Commit 5e97eed8 authored by Tong Mu's avatar Tong Mu Committed by GitHub

Migrate foundation test to nullsafety (#62616)

* Migrate
parent 8485580b
...@@ -1897,7 +1897,7 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> { ...@@ -1897,7 +1897,7 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
_NumProperty.lazy( _NumProperty.lazy(
String name, String name,
ComputePropertyValueCallback<T> computeValue, { ComputePropertyValueCallback<T?> computeValue, {
String? ifNull, String? ifNull,
this.unit, this.unit,
bool showName = true, bool showName = true,
...@@ -1984,7 +1984,7 @@ class DoubleProperty extends _NumProperty<double> { ...@@ -1984,7 +1984,7 @@ class DoubleProperty extends _NumProperty<double> {
/// The [showName] and [level] arguments must not be null. /// The [showName] and [level] arguments must not be null.
DoubleProperty.lazy( DoubleProperty.lazy(
String name, String name,
ComputePropertyValueCallback<double> computeValue, { ComputePropertyValueCallback<double?> computeValue, {
String? ifNull, String? ifNull,
bool showName = true, bool showName = true,
String? unit, String? unit,
...@@ -2480,7 +2480,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> { ...@@ -2480,7 +2480,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
/// only one flag, and is preferred if there is only one entry. /// only one flag, and is preferred if there is only one entry.
/// * [IterableProperty], which provides similar functionality describing /// * [IterableProperty], which provides similar functionality describing
/// the values a collection of objects. /// the values a collection of objects.
class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T?>> {
/// Create a summary for multiple properties, indicating whether each of them /// Create a summary for multiple properties, indicating whether each of them
/// is present (non-null) or absent (null). /// is present (non-null) or absent (null).
/// ///
...@@ -2488,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { ...@@ -2488,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
/// null. /// null.
FlagsSummary( FlagsSummary(
String name, String name,
Map<String, T> value, { Map<String, T?> value, {
String? ifEmpty, String? ifEmpty,
bool showName = true, bool showName = true,
bool showSeparator = true, bool showSeparator = true,
...@@ -2507,7 +2507,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { ...@@ -2507,7 +2507,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
); );
@override @override
Map<String, T> get value => super.value!; Map<String, T?> get value => super.value!;
@override @override
String valueToString({TextTreeConfiguration? parentConfiguration}) { String valueToString({TextTreeConfiguration? parentConfiguration}) {
...@@ -2545,7 +2545,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { ...@@ -2545,7 +2545,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
return json; return json;
} }
bool _hasNonNullEntry() => value.values.any((T o) => o != null); bool _hasNonNullEntry() => value.values.any((T? o) => o != null);
// An iterable of each entry's description in [value]. // An iterable of each entry's description in [value].
// //
...@@ -2554,7 +2554,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { ...@@ -2554,7 +2554,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
// For a null value, it is omitted unless `includeEmtpy` is true and // For a null value, it is omitted unless `includeEmtpy` is true and
// [ifEntryNull] contains a corresponding description. // [ifEntryNull] contains a corresponding description.
Iterable<String> _formattedValues() sync* { Iterable<String> _formattedValues() sync* {
for (final MapEntry<String, T> entry in value.entries) { for (final MapEntry<String, T?> entry in value.entries) {
if (entry.value != null) { if (entry.value != null) {
yield entry.key; yield entry.key;
} }
...@@ -2567,7 +2567,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> { ...@@ -2567,7 +2567,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
/// May throw exception if accessing the property would throw an exception /// May throw exception if accessing the property would throw an exception
/// and callers must handle that case gracefully. For example, accessing a /// and callers must handle that case gracefully. For example, accessing a
/// property may trigger an assert that layout constraints were violated. /// property may trigger an assert that layout constraints were violated.
typedef ComputePropertyValueCallback<T> = T Function(); typedef ComputePropertyValueCallback<T> = T? Function();
/// Property with a [value] of type [T]. /// Property with a [value] of type [T].
/// ///
...@@ -2651,7 +2651,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode { ...@@ -2651,7 +2651,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
DiagnosticLevel level = DiagnosticLevel.info, DiagnosticLevel level = DiagnosticLevel.info,
}) : assert(showName != null), }) : assert(showName != null),
assert(showSeparator != null), assert(showSeparator != null),
assert(defaultValue == kNoDefaultValue || defaultValue is T), assert(defaultValue == kNoDefaultValue || defaultValue is T?),
assert(missingIfNull != null), assert(missingIfNull != null),
assert(style != null), assert(style != null),
assert(level != null), assert(level != null),
...@@ -2848,7 +2848,8 @@ class DiagnosticsProperty<T> extends DiagnosticsNode { ...@@ -2848,7 +2848,8 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// of the property is downgraded to [DiagnosticLevel.fine] as the property /// of the property is downgraded to [DiagnosticLevel.fine] as the property
/// value is uninteresting. /// value is uninteresting.
/// ///
/// [defaultValue] has type [T] or is [kNoDefaultValue]. /// The [defaultValue] is [kNoDefaultValue] by default. Otherwise it must be of
/// type `T?`.
final Object? defaultValue; final Object? defaultValue;
final DiagnosticLevel _defaultLevel; final DiagnosticLevel _defaultLevel;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' as ui show AccessibilityFeatures, SemanticsUpdateBuilder; import 'dart:ui' as ui show AccessibilityFeatures, SemanticsUpdateBuilder;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -19,7 +17,7 @@ import '../scheduler/scheduler_tester.dart'; ...@@ -19,7 +17,7 @@ import '../scheduler/scheduler_tester.dart';
void main() { void main() {
setUp(() { setUp(() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
WidgetsBinding.instance.resetEpoch(); WidgetsBinding.instance!.resetEpoch();
ui.window.onBeginFrame = null; ui.window.onBeginFrame = null;
ui.window.onDrawFrame = null; ui.window.onDrawFrame = null;
}); });
...@@ -350,7 +348,7 @@ void main() { ...@@ -350,7 +348,7 @@ void main() {
expect(controller.repeat, throwsFlutterError); expect(controller.repeat, throwsFlutterError);
controller.dispose(); controller.dispose();
FlutterError result; FlutterError? result;
try { try {
controller.dispose(); controller.dispose();
} on FlutterError catch (e) { } on FlutterError catch (e) {
...@@ -358,7 +356,7 @@ void main() { ...@@ -358,7 +356,7 @@ void main() {
} }
expect(result, isNotNull); expect(result, isNotNull);
expect( expect(
result.toStringDeep(), result!.toStringDeep(),
equalsIgnoringHashCodes( equalsIgnoringHashCodes(
'FlutterError\n' 'FlutterError\n'
' AnimationController.dispose() called more than once.\n' ' AnimationController.dispose() called more than once.\n'
...@@ -482,7 +480,7 @@ void main() { ...@@ -482,7 +480,7 @@ void main() {
controller.forward(from: 0.2); controller.forward(from: 0.2);
expect(controller.value, 0.2); expect(controller.value, 0.2);
controller.animateTo(1.0, duration: Duration.zero); controller.animateTo(1.0, duration: Duration.zero);
expect(SchedulerBinding.instance.transientCallbackCount, equals(0), reason: 'Expected no animation.'); expect(SchedulerBinding.instance!.transientCallbackCount, equals(0), reason: 'Expected no animation.');
expect(controller.value, 1.0); expect(controller.value, 1.0);
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -84,8 +82,8 @@ class _DecuplePixels extends StatefulWidget { ...@@ -84,8 +82,8 @@ class _DecuplePixels extends StatefulWidget {
State<StatefulWidget> createState() => _DecuplePixelsState(); State<StatefulWidget> createState() => _DecuplePixelsState();
} }
class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProviderStateMixin { class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProviderStateMixin<_DecuplePixels> {
AnimationController _controller; late AnimationController _controller;
@override @override
void initState() { void initState() {
...@@ -107,7 +105,7 @@ class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProvide ...@@ -107,7 +105,7 @@ class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProvide
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AnimatedBuilder( return AnimatedBuilder(
animation: _controller.view, animation: _controller.view,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return CustomPaint( return CustomPaint(
painter: _PaintDecuplePixels(_controller.value), painter: _PaintDecuplePixels(_controller.value),
); );
...@@ -132,7 +130,7 @@ class _PaintDecuplePixels extends CustomPainter { ...@@ -132,7 +130,7 @@ class _PaintDecuplePixels extends CustomPainter {
final Rect rect = RectTween( final Rect rect = RectTween(
begin: const Rect.fromLTWH(1, 1, 1, 1), begin: const Rect.fromLTWH(1, 1, 1, 1),
end: const Rect.fromLTWH(11, 1, 1, 1), end: const Rect.fromLTWH(11, 1, 1, 1),
).transform(value); ).transform(value)!;
canvas.drawRect(rect, Paint()..color = Colors.yellow); canvas.drawRect(rect, Paint()..color = Colors.yellow);
final Paint black = Paint()..color = Colors.black; final Paint black = Paint()..color = Colors.black;
canvas canvas
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -21,7 +19,7 @@ class BogusCurve extends Curve { ...@@ -21,7 +19,7 @@ class BogusCurve extends Curve {
void main() { void main() {
setUp(() { setUp(() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
WidgetsBinding.instance.resetEpoch(); WidgetsBinding.instance!.resetEpoch();
ui.window.onBeginFrame = null; ui.window.onBeginFrame = null;
ui.window.onDrawFrame = null; ui.window.onDrawFrame = null;
}); });
...@@ -240,14 +238,14 @@ void main() { ...@@ -240,14 +238,14 @@ void main() {
vsync: const TestVSync(), vsync: const TestVSync(),
); );
final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: BogusCurve()); final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: BogusCurve());
FlutterError error; FlutterError? error;
try { try {
curved.value; curved.value;
} on FlutterError catch (e) { } on FlutterError catch (e) {
error = e; error = e;
} }
expect(error, isNotNull); expect(error, isNotNull);
expect(error.toStringDeep(), matches( expect(error!.toStringDeep(), matches(
// RegExp matcher is required here due to flutter web and flutter mobile generating // RegExp matcher is required here due to flutter web and flutter mobile generating
// slightly different floating point numbers // slightly different floating point numbers
// in Flutter web 0.0 sometimes just appears as 0. or 0 // in Flutter web 0.0 sometimes just appears as 0. or 0
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -275,9 +273,6 @@ void main() { ...@@ -275,9 +273,6 @@ void main() {
}); });
test('CatmullRomSpline enforces contract', () { test('CatmullRomSpline enforces contract', () {
expect(() {
CatmullRomSpline(null);
}, throwsAssertionError);
expect(() { expect(() {
CatmullRomSpline(const <Offset>[]); CatmullRomSpline(const <Offset>[]);
}, throwsAssertionError); }, throwsAssertionError);
...@@ -327,9 +322,6 @@ void main() { ...@@ -327,9 +322,6 @@ void main() {
}); });
test('CatmullRomSpline enforces contract when precomputed', () { test('CatmullRomSpline enforces contract when precomputed', () {
expect(() {
CatmullRomSpline.precompute(null);
}, throwsAssertionError);
expect(() { expect(() {
CatmullRomSpline.precompute(const <Offset>[]); CatmullRomSpline.precompute(const <Offset>[]);
}, throwsAssertionError); }, throwsAssertionError);
...@@ -395,9 +387,6 @@ void main() { ...@@ -395,9 +387,6 @@ void main() {
}); });
test('CatmullRomCurve enforces contract', () { test('CatmullRomCurve enforces contract', () {
expect(() {
CatmullRomCurve(null);
}, throwsAssertionError);
expect(() { expect(() {
CatmullRomCurve(const <Offset>[]); CatmullRomCurve(const <Offset>[]);
}, throwsAssertionError); }, throwsAssertionError);
...@@ -517,9 +506,6 @@ void main() { ...@@ -517,9 +506,6 @@ void main() {
}); });
test('CatmullRomCurve enforces contract when precomputed', () { test('CatmullRomCurve enforces contract when precomputed', () {
expect(() {
CatmullRomCurve.precompute(null);
}, throwsAssertionError);
expect(() { expect(() {
CatmullRomCurve.precompute(const <Offset>[]); CatmullRomCurve.precompute(const <Offset>[]);
}, throwsAssertionError); }, throwsAssertionError);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart'; ...@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
void main() { void main() {
setUp(() { setUp(() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
WidgetsBinding.instance.resetEpoch(); WidgetsBinding.instance!.resetEpoch();
}); });
test('AnimationController with mutating listener', () { test('AnimationController with mutating listener', () {
...@@ -92,7 +90,7 @@ void main() { ...@@ -92,7 +90,7 @@ void main() {
final VoidCallback listener1 = () { log.add('listener1'); }; final VoidCallback listener1 = () { log.add('listener1'); };
final VoidCallback badListener = () { final VoidCallback badListener = () {
log.add('badListener'); log.add('badListener');
throw null; throw ArgumentError();
}; };
final VoidCallback listener2 = () { log.add('listener2'); }; final VoidCallback listener2 = () { log.add('listener2'); };
...@@ -101,7 +99,7 @@ void main() { ...@@ -101,7 +99,7 @@ void main() {
controller.addListener(listener2); controller.addListener(listener2);
controller.value = 0.2; controller.value = 0.2;
expect(log, <String>['listener1', 'badListener', 'listener2']); expect(log, <String>['listener1', 'badListener', 'listener2']);
expect(tester.takeException(), isNullThrownError); expect(tester.takeException(), isArgumentError);
log.clear(); log.clear();
}); });
...@@ -115,7 +113,7 @@ void main() { ...@@ -115,7 +113,7 @@ void main() {
final AnimationStatusListener listener1 = (AnimationStatus status) { log.add('listener1'); }; final AnimationStatusListener listener1 = (AnimationStatus status) { log.add('listener1'); };
final AnimationStatusListener badListener = (AnimationStatus status) { final AnimationStatusListener badListener = (AnimationStatus status) {
log.add('badListener'); log.add('badListener');
throw null; throw ArgumentError();
}; };
final AnimationStatusListener listener2 = (AnimationStatus status) { log.add('listener2'); }; final AnimationStatusListener listener2 = (AnimationStatus status) { log.add('listener2'); };
...@@ -124,7 +122,7 @@ void main() { ...@@ -124,7 +122,7 @@ void main() {
controller.addStatusListener(listener2); controller.addStatusListener(listener2);
controller.forward(); controller.forward();
expect(log, <String>['listener1', 'badListener', 'listener2']); expect(log, <String>['listener1', 'badListener', 'listener2']);
expect(tester.takeException(), isNullThrownError); expect(tester.takeException(), isArgumentError);
log.clear(); log.clear();
controller.dispose(); controller.dispose();
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -442,7 +440,7 @@ void main() { ...@@ -442,7 +440,7 @@ void main() {
], ],
replacement: 'test', replacement: 'test',
); );
final List<String> reasons = List<String>(2); final List<String?> reasons = List<String?>.filled(2, null);
filter.filter( filter.filter(
const <StackFrame>[ const <StackFrame>[
StackFrame(className: 'TestClass', method: 'test1', packageScheme: 'package', package: 'test', packagePath: 'blah.dart', line: 1, column: 1, number: 0, source: ''), StackFrame(className: 'TestClass', method: 'test1', packageScheme: 'package', package: 'test', packagePath: 'blah.dart', line: 1, column: 1, number: 0, source: ''),
...@@ -450,6 +448,6 @@ void main() { ...@@ -450,6 +448,6 @@ void main() {
], ],
reasons, reasons,
); );
expect(reasons, List<String>(2)); expect(reasons, List<String?>.filled(2, null));
}); });
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') @TestOn('!chrome')
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
......
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
int yieldCount; int yieldCount = 0;
Iterable<int> range(int start, int end) sync* { Iterable<int> range(int start, int end) sync* {
assert(yieldCount == 0); assert(yieldCount == 0);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -41,7 +39,7 @@ void main() { ...@@ -41,7 +39,7 @@ void main() {
final VoidCallback listener2 = () { log.add('listener2'); }; final VoidCallback listener2 = () { log.add('listener2'); };
final VoidCallback badListener = () { final VoidCallback badListener = () {
log.add('badListener'); log.add('badListener');
throw null; throw ArgumentError();
}; };
final TestNotifier test = TestNotifier(); final TestNotifier test = TestNotifier();
...@@ -95,7 +93,7 @@ void main() { ...@@ -95,7 +93,7 @@ void main() {
test.addListener(badListener); test.addListener(badListener);
test.notify(); test.notify();
expect(log, <String>['listener', 'listener2', 'listener1', 'badListener']); expect(log, <String>['listener', 'listener2', 'listener1', 'badListener']);
expect(tester.takeException(), isNullThrownError); expect(tester.takeException(), isArgumentError);
log.clear(); log.clear();
test.addListener(listener1); test.addListener(listener1);
...@@ -105,7 +103,7 @@ void main() { ...@@ -105,7 +103,7 @@ void main() {
test.addListener(listener2); test.addListener(listener2);
test.notify(); test.notify();
expect(log, <String>['badListener', 'listener1', 'listener2']); expect(log, <String>['badListener', 'listener1', 'listener2']);
expect(tester.takeException(), isNullThrownError); expect(tester.takeException(), isArgumentError);
log.clear(); log.clear();
}); });
...@@ -238,7 +236,7 @@ void main() { ...@@ -238,7 +236,7 @@ void main() {
final TestNotifier source2 = TestNotifier(); final TestNotifier source2 = TestNotifier();
final List<String> log = <String>[]; final List<String> log = <String>[];
final Listenable merged = Listenable.merge(<Listenable>[null, source1, null, source2, null]); final Listenable merged = Listenable.merge(<Listenable?>[null, source1, null, source2, null]);
final VoidCallback listener = () { log.add('listener'); }; final VoidCallback listener = () { log.add('listener'); };
merged.addListener(listener); merged.addListener(listener);
...@@ -300,7 +298,7 @@ void main() { ...@@ -300,7 +298,7 @@ void main() {
Listenable listenableUnderTest = Listenable.merge(<Listenable>[]); Listenable listenableUnderTest = Listenable.merge(<Listenable>[]);
expect(listenableUnderTest.toString(), 'Listenable.merge([])'); expect(listenableUnderTest.toString(), 'Listenable.merge([])');
listenableUnderTest = Listenable.merge(<Listenable>[null]); listenableUnderTest = Listenable.merge(<Listenable?>[null]);
expect(listenableUnderTest.toString(), 'Listenable.merge([null])'); expect(listenableUnderTest.toString(), 'Listenable.merge([null])');
listenableUnderTest = Listenable.merge(<Listenable>[source1]); listenableUnderTest = Listenable.merge(<Listenable>[source1]);
...@@ -315,7 +313,7 @@ void main() { ...@@ -315,7 +313,7 @@ void main() {
"Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])", "Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])",
); );
listenableUnderTest = Listenable.merge(<Listenable>[null, source2]); listenableUnderTest = Listenable.merge(<Listenable?>[null, source2]);
expect( expect(
listenableUnderTest.toString(), listenableUnderTest.toString(),
"Listenable.merge([null, Instance of 'TestNotifier'])", "Listenable.merge([null, Instance of 'TestNotifier'])",
...@@ -382,14 +380,14 @@ void main() { ...@@ -382,14 +380,14 @@ void main() {
test('Throws FlutterError when disposed and called', () { test('Throws FlutterError when disposed and called', () {
final TestNotifier testNotifier = TestNotifier(); final TestNotifier testNotifier = TestNotifier();
testNotifier.dispose(); testNotifier.dispose();
FlutterError error; FlutterError? error;
try { try {
testNotifier.dispose(); testNotifier.dispose();
} on FlutterError catch (e) { } on FlutterError catch (e) {
error = e; error = e;
} }
expect(error, isNotNull); expect(error, isNotNull);
expect(error, isFlutterError); expect(error!, isFlutterError);
expect(error.toStringDeep(), equalsIgnoringHashCodes( expect(error.toStringDeep(), equalsIgnoringHashCodes(
'FlutterError\n' 'FlutterError\n'
' A TestNotifier was used after being disposed.\n' ' A TestNotifier was used after being disposed.\n'
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:math'; import 'dart:math';
import 'package:flutter/src/foundation/collections.dart'; import 'package:flutter/src/foundation/collections.dart';
...@@ -64,10 +63,8 @@ void main() { ...@@ -64,10 +63,8 @@ void main() {
test('MergeSortRandom', () { test('MergeSortRandom', () {
final Random random = Random(); final Random random = Random();
for (int i = 0; i < 250; i += 1) { for (int i = 0; i < 250; i += 1) {
final List<int> list = List<int>(i); // Expect some equal elements.
for (int j = 0; j < i; j++) { final List<int> list = List<int>.generate(i, (int j) => random.nextInt(i));
list[j] = random.nextInt(i); // Expect some equal elements.
}
mergeSort(list); mergeSort(list);
for (int j = 1; j < i; j++) { for (int j = 1; j < i; j++) {
expect(list[j - 1], lessThanOrEqualTo(list[j])); expect(list[j - 1], lessThanOrEqualTo(list[j]));
...@@ -80,14 +77,12 @@ void main() { ...@@ -80,14 +77,12 @@ void main() {
// larger case where the internal moving insertion sort is used // larger case where the internal moving insertion sort is used
// larger cases with multiple splittings, numbers just around a power of 2. // larger cases with multiple splittings, numbers just around a power of 2.
for (final int size in <int>[8, 50, 511, 512, 513]) { for (final int size in <int>[8, 50, 511, 512, 513]) {
final List<OrderedComparable> list = List<OrderedComparable>(size);
// Class OC compares using id. // Class OC compares using id.
// With size elements with id's in the range 0..size/4, a number of // With size elements with id's in the range 0..size/4, a number of
// 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.
for (int i = 0; i < size; i++) { final List<OrderedComparable> list = List<OrderedComparable>.generate(
list[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++) {
...@@ -126,10 +121,8 @@ void main() { ...@@ -126,10 +121,8 @@ 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>(size); final List<OrderedComparable> list = List<OrderedComparable>.generate(
for (int i = 0; i < size; i++) { size, (int i) => OrderedComparable(0, i));
list[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));
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') @TestOn('!chrome')
import 'dart:async'; import 'dart:async';
...@@ -18,7 +16,7 @@ final Uint8List chunkOne = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]); ...@@ -18,7 +16,7 @@ final Uint8List chunkOne = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]);
final Uint8List chunkTwo = Uint8List.fromList(<int>[6, 7, 8, 9, 10]); final Uint8List chunkTwo = Uint8List.fromList(<int>[6, 7, 8, 9, 10]);
void main() { void main() {
group(consolidateHttpClientResponseBytes, () { group(consolidateHttpClientResponseBytes, () {
MockHttpClientResponse response; late MockHttpClientResponse response;
setUp(() { setUp(() {
response = MockHttpClientResponse( response = MockHttpClientResponse(
...@@ -54,11 +52,11 @@ void main() { ...@@ -54,11 +52,11 @@ void main() {
test('Notifies onBytesReceived for every chunk of bytes', () async { test('Notifies onBytesReceived for every chunk of bytes', () async {
final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2; final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2;
response.contentLength = syntheticTotal; response.contentLength = syntheticTotal;
final List<int> records = <int>[]; final List<int?> records = <int?>[];
await consolidateHttpClientResponseBytes( await consolidateHttpClientResponseBytes(
response, response,
onBytesReceived: (int cumulative, int total) { onBytesReceived: (int cumulative, int? total) {
records.addAll(<int>[cumulative, total]); records.addAll(<int?>[cumulative, total]);
}, },
); );
...@@ -81,7 +79,7 @@ void main() { ...@@ -81,7 +79,7 @@ void main() {
response.contentLength = -1; response.contentLength = -1;
final Future<List<int>> result = consolidateHttpClientResponseBytes( final Future<List<int>> result = consolidateHttpClientResponseBytes(
response, response,
onBytesReceived: (int cumulative, int total) { onBytesReceived: (int cumulative, int? total) {
throw 'misbehaving callback'; throw 'misbehaving callback';
}, },
); );
...@@ -113,11 +111,11 @@ void main() { ...@@ -113,11 +111,11 @@ void main() {
test('Notifies onBytesReceived with gzipped numbers', () async { test('Notifies onBytesReceived with gzipped numbers', () async {
response.contentLength = gzipped.length; response.contentLength = gzipped.length;
final List<int> records = <int>[]; final List<int?> records = <int>[];
await consolidateHttpClientResponseBytes( await consolidateHttpClientResponseBytes(
response, response,
onBytesReceived: (int cumulative, int total) { onBytesReceived: (int cumulative, int? total) {
records.addAll(<int>[cumulative, total]); records.addAll(<int?>[cumulative, total]);
}, },
); );
...@@ -133,15 +131,15 @@ void main() { ...@@ -133,15 +131,15 @@ void main() {
final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2; final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2;
response.compressionState = HttpClientResponseCompressionState.decompressed; response.compressionState = HttpClientResponseCompressionState.decompressed;
response.contentLength = syntheticTotal; response.contentLength = syntheticTotal;
final List<int> records = <int>[]; final List<int?> records = <int?>[];
await consolidateHttpClientResponseBytes( await consolidateHttpClientResponseBytes(
response, response,
onBytesReceived: (int cumulative, int total) { onBytesReceived: (int cumulative, int? total) {
records.addAll(<int>[cumulative, total]); records.addAll(<int?>[cumulative, total]);
}, },
); );
expect(records, <int>[ expect(records, <int?>[
gzippedChunkOne.length, gzippedChunkOne.length,
null, null,
gzipped.length, gzipped.length,
...@@ -153,7 +151,7 @@ void main() { ...@@ -153,7 +151,7 @@ void main() {
} }
class MockHttpClientResponse extends Fake implements HttpClientResponse { class MockHttpClientResponse extends Fake implements HttpClientResponse {
MockHttpClientResponse({this.error, this.chunkOne, this.chunkTwo}); MockHttpClientResponse({this.error, this.chunkOne = const <int>[], this.chunkTwo = const <int>[]});
final dynamic error; final dynamic error;
final List<int> chunkOne; final List<int> chunkOne;
...@@ -166,10 +164,10 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse { ...@@ -166,10 +164,10 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
HttpClientResponseCompressionState compressionState = HttpClientResponseCompressionState.notCompressed; HttpClientResponseCompressionState compressionState = HttpClientResponseCompressionState.notCompressed;
@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)).listen( Future<List<int>>.error(error as Object)).listen(
onData, onData,
onDone: onDone, onDone: onDone,
onError: onError, onError: onError,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // This test is not intended to run on the web. @TestOn('!chrome') // This test is not intended to run on the web.
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class X {} class X {}
...@@ -11,7 +9,7 @@ class X {} ...@@ -11,7 +9,7 @@ class X {}
class Y extends X {} class Y extends X {}
class A<U extends X> { class A<U extends X> {
U u; U? u;
} }
void main() { void main() {
......
...@@ -2,21 +2,19 @@ ...@@ -2,21 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
group('debugInstrumentAction', () { group('debugInstrumentAction', () {
DebugPrintCallback originalDebugPrintCallback; late DebugPrintCallback originalDebugPrintCallback;
StringBuffer printBuffer; late StringBuffer printBuffer;
setUp(() { setUp(() {
debugInstrumentationEnabled = true; debugInstrumentationEnabled = true;
printBuffer = StringBuffer(); printBuffer = StringBuffer();
originalDebugPrintCallback = debugPrint; originalDebugPrintCallback = debugPrint;
debugPrint = (String message, { int wrapWidth }) { debugPrint = (String? message, { int? wrapWidth }) {
printBuffer.writeln(message); printBuffer.writeln(message);
}; };
}); });
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:ui'; import 'dart:ui';
...@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
class TestTree extends Object with DiagnosticableTreeMixin { class TestTree extends Object with DiagnosticableTreeMixin {
TestTree({ TestTree({
this.name, this.name = '',
this.style, this.style,
this.children = const <TestTree>[], this.children = const <TestTree>[],
this.properties = const <DiagnosticsNode>[], this.properties = const <DiagnosticsNode>[],
...@@ -21,7 +19,7 @@ class TestTree extends Object with DiagnosticableTreeMixin { ...@@ -21,7 +19,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
final String name; final String name;
final List<TestTree> children; final List<TestTree> children;
final List<DiagnosticsNode> properties; final List<DiagnosticsNode> properties;
final DiagnosticsTreeStyle style; final DiagnosticsTreeStyle? style;
@override @override
List<DiagnosticsNode> debugDescribeChildren() => <DiagnosticsNode>[ List<DiagnosticsNode> debugDescribeChildren() => <DiagnosticsNode>[
...@@ -36,8 +34,7 @@ class TestTree extends Object with DiagnosticableTreeMixin { ...@@ -36,8 +34,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
if (style != null) if (style != null)
properties.defaultDiagnosticsTreeStyle = style; properties.defaultDiagnosticsTreeStyle = style!;
this.properties.forEach(properties.add); this.properties.forEach(properties.add);
} }
} }
...@@ -65,7 +62,7 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo ...@@ -65,7 +62,7 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo
expect(json['level'] ?? describeEnum(DiagnosticLevel.info), equals(describeEnum(node.level))); expect(json['level'] ?? describeEnum(DiagnosticLevel.info), equals(describeEnum(node.level)));
expect(json['showName'] ?? true, equals(node.showName)); expect(json['showName'] ?? true, equals(node.showName));
expect(json['emptyBodyDescription'], equals(node.emptyBodyDescription)); expect(json['emptyBodyDescription'], equals(node.emptyBodyDescription));
expect(json['style'] ?? describeEnum(DiagnosticsTreeStyle.sparse), equals(describeEnum(node.style))); expect(json['style'] ?? describeEnum(DiagnosticsTreeStyle.sparse), equals(describeEnum(node.style!)));
expect(json['type'], equals(node.runtimeType.toString())); expect(json['type'], equals(node.runtimeType.toString()));
expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty)); expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty));
} }
...@@ -122,13 +119,13 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop ...@@ -122,13 +119,13 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop
validatePropertyJsonSerializationHelper(json, property); validatePropertyJsonSerializationHelper(json, property);
} }
void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object> property) { void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object> json = simulateJsonSerialization(property);
if (property.value.isNotEmpty) { if (property.value.isNotEmpty) {
expect(json['values'], equals( expect(json['values'], equals(
property.value.entries property.value.entries
.where((MapEntry<String, Object> entry) => entry.value != null) .where((MapEntry<String, Object?> entry) => entry.value != null)
.map((MapEntry<String, Object> entry) => entry.key).toList(), .map((MapEntry<String, Object?> entry) => entry.key).toList(),
)); ));
} else { } else {
expect(json.containsKey('values'), isFalse); expect(json.containsKey('values'), isFalse);
...@@ -141,7 +138,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property ...@@ -141,7 +138,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object> json = simulateJsonSerialization(property);
if (property.value != null) { if (property.value != null) {
final List<Object> valuesJson = json['values'] as List<Object>; final List<Object> valuesJson = json['values'] as List<Object>;
final List<String> expectedValues = property.value.map<String>((Object value) => value.toString()).toList(); final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList();
expect(listEquals(valuesJson, expectedValues), isTrue); expect(listEquals(valuesJson, expectedValues), isTrue);
} else { } else {
expect(json.containsKey('values'), isFalse); expect(json.containsKey('values'), isFalse);
...@@ -194,8 +191,8 @@ void main() { ...@@ -194,8 +191,8 @@ void main() {
test('TreeDiagnosticsMixin control test', () async { test('TreeDiagnosticsMixin control test', () async {
void goldenStyleTest( void goldenStyleTest(
String description, { String description, {
DiagnosticsTreeStyle style, DiagnosticsTreeStyle? style,
DiagnosticsTreeStyle lastChildStyle, DiagnosticsTreeStyle? lastChildStyle,
String golden = '', String golden = '',
}) { }) {
final TestTree tree = TestTree(children: <TestTree>[ final TestTree tree = TestTree(children: <TestTree>[
...@@ -367,11 +364,11 @@ void main() { ...@@ -367,11 +364,11 @@ void main() {
test('TreeDiagnosticsMixin tree with properties test', () async { test('TreeDiagnosticsMixin tree with properties test', () async {
void goldenStyleTest( void goldenStyleTest(
String description, { String description, {
String name, String? name,
DiagnosticsTreeStyle style, DiagnosticsTreeStyle? style,
DiagnosticsTreeStyle lastChildStyle, DiagnosticsTreeStyle? lastChildStyle,
DiagnosticsTreeStyle propertyStyle = DiagnosticsTreeStyle.singleLine, DiagnosticsTreeStyle propertyStyle = DiagnosticsTreeStyle.singleLine,
@required String golden, required String golden,
}) { }) {
final TestTree tree = TestTree( final TestTree tree = TestTree(
properties: <DiagnosticsNode>[ properties: <DiagnosticsNode>[
...@@ -1696,7 +1693,7 @@ void main() { ...@@ -1696,7 +1693,7 @@ void main() {
// Partially empty property // Partially empty property
{ {
final Function onClick = () { }; final Function onClick = () { };
final Map<String, Function> value = <String, Function>{ final Map<String, Function?> value = <String, Function?>{
'move': null, 'move': null,
'click': onClick, 'click': onClick,
}; };
...@@ -1711,7 +1708,7 @@ void main() { ...@@ -1711,7 +1708,7 @@ void main() {
// Empty property (without ifEmpty) // Empty property (without ifEmpty)
{ {
final Map<String, Function> value = <String, Function>{ final Map<String, Function?> value = <String, Function?>{
'enter': null, 'enter': null,
}; };
final FlagsSummary<Function> flags = FlagsSummary<Function>( final FlagsSummary<Function> flags = FlagsSummary<Function>(
...@@ -1724,7 +1721,7 @@ void main() { ...@@ -1724,7 +1721,7 @@ void main() {
// Empty property (without ifEmpty) // Empty property (without ifEmpty)
{ {
final Map<String, Function> value = <String, Function>{ final Map<String, Function?> value = <String, Function?>{
'enter': null, 'enter': null,
}; };
final FlagsSummary<Function> flags = FlagsSummary<Function>( final FlagsSummary<Function> flags = FlagsSummary<Function>(
...@@ -1922,14 +1919,14 @@ void main() { ...@@ -1922,14 +1919,14 @@ void main() {
expect(messageProperty.name, equals('diagnostics')); expect(messageProperty.name, equals('diagnostics'));
expect(messageProperty.value, isNull); expect(messageProperty.value, isNull);
expect(messageProperty.showName, isTrue); expect(messageProperty.showName, isTrue);
validatePropertyJsonSerialization(messageProperty as MessageProperty); validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object>);
}); });
test('error message style wrap test', () { test('error message style wrap test', () {
// This tests wrapping of properties with styles typical for error messages. // This tests wrapping of properties with styles typical for error messages.
DiagnosticsNode createTreeWithWrappingNodes({ DiagnosticsNode createTreeWithWrappingNodes({
DiagnosticsTreeStyle rootStyle, DiagnosticsTreeStyle? rootStyle,
DiagnosticsTreeStyle propertyStyle, required DiagnosticsTreeStyle propertyStyle,
}) { }) {
return TestTree( return TestTree(
name: 'Test tree', name: 'Test tree',
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // web has different stack traces @TestOn('!chrome') // web has different stack traces
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -41,13 +39,13 @@ Future<StackTrace> getSampleStack() async { ...@@ -41,13 +39,13 @@ Future<StackTrace> getSampleStack() async {
} }
Future<void> main() async { Future<void> main() async {
final List<String> console = <String>[]; final List<String?> console = <String?>[];
final StackTrace sampleStack = await getSampleStack(); final StackTrace sampleStack = await getSampleStack();
setUp(() async { setUp(() async {
expect(debugPrint, equals(debugPrintThrottled)); expect(debugPrint, equals(debugPrintThrottled));
debugPrint = (String message, { int wrapWidth }) { debugPrint = (String? message, { int? wrapWidth }) {
console.add(message); console.add(message);
}; };
}); });
...@@ -160,7 +158,7 @@ Future<void> main() async { ...@@ -160,7 +158,7 @@ Future<void> main() async {
test('Error reporting - NoSuchMethodError', () async { test('Error reporting - NoSuchMethodError', () async {
expect(console, isEmpty); expect(console, isEmpty);
final dynamic 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(
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // isolates not supported on the web. @TestOn('!chrome') // isolates not supported on the web.
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -11,7 +9,7 @@ void main() { ...@@ -11,7 +9,7 @@ void main() {
test('LicenseEntryWithLineBreaks - most cases', () { test('LicenseEntryWithLineBreaks - most cases', () {
// There's some trailing spaces in this string. // There's some trailing spaces in this string.
// To avoid IDEs stripping them, I've escaped them as \u0020. // To avoid IDEs stripping them, I've escaped them as \u0020.
final List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(null, ''' final List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(<String>[], '''
A A
A A
A A
...@@ -159,17 +157,17 @@ S ...@@ -159,17 +157,17 @@ S
}); });
test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () { test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () {
expect(const LicenseEntryWithLineBreaks(null, ' \n\n ').paragraphs.toList(), isEmpty); expect(const LicenseEntryWithLineBreaks(<String>[], ' \n\n ').paragraphs.toList(), isEmpty);
expect(const LicenseEntryWithLineBreaks(null, ' \r\n\r\n ').paragraphs.toList(), isEmpty); expect(const LicenseEntryWithLineBreaks(<String>[], ' \r\n\r\n ').paragraphs.toList(), isEmpty);
List<LicenseParagraph> paragraphs; List<LicenseParagraph> paragraphs;
paragraphs = const LicenseEntryWithLineBreaks(null, ' \nA\n ').paragraphs.toList(); paragraphs = const LicenseEntryWithLineBreaks(<String>[], ' \nA\n ').paragraphs.toList();
expect(paragraphs[0].text, 'A'); expect(paragraphs[0].text, 'A');
expect(paragraphs[0].indent, 0); expect(paragraphs[0].indent, 0);
expect(paragraphs, hasLength(1)); expect(paragraphs, hasLength(1));
paragraphs = const LicenseEntryWithLineBreaks(null, '\n\n\nA\n\n\n').paragraphs.toList(); paragraphs = const LicenseEntryWithLineBreaks(<String>[], '\n\n\nA\n\n\n').paragraphs.toList();
expect(paragraphs[0].text, 'A'); expect(paragraphs[0].text, 'A');
expect(paragraphs[0].indent, 0); expect(paragraphs[0].indent, 0);
expect(paragraphs, hasLength(1)); expect(paragraphs, hasLength(1));
...@@ -178,12 +176,12 @@ S ...@@ -178,12 +176,12 @@ S
test('LicenseRegistry', () async { test('LicenseRegistry', () async {
expect(await LicenseRegistry.licenses.toList(), isEmpty); expect(await LicenseRegistry.licenses.toList(), isEmpty);
LicenseRegistry.addLicense(() async* { LicenseRegistry.addLicense(() async* {
yield const LicenseEntryWithLineBreaks(null, 'A'); yield const LicenseEntryWithLineBreaks(<String>[], 'A');
yield const LicenseEntryWithLineBreaks(null, 'B'); yield const LicenseEntryWithLineBreaks(<String>[], 'B');
}); });
LicenseRegistry.addLicense(() async* { LicenseRegistry.addLicense(() async* {
yield const LicenseEntryWithLineBreaks(null, 'C'); yield const LicenseEntryWithLineBreaks(<String>[], 'C');
yield const LicenseEntryWithLineBreaks(null, 'D'); yield const LicenseEntryWithLineBreaks(<String>[], 'D');
}); });
expect(await LicenseRegistry.licenses.toList(), hasLength(4)); expect(await LicenseRegistry.licenses.toList(), hasLength(4));
final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList(); final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList();
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:io' show Platform; import 'dart:io' show Platform;
/// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a /// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.10
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:fake_async/fake_async.dart'; import 'package:fake_async/fake_async.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') @TestOn('!chrome')
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
class TestFoundationFlutterBinding extends BindingBase { class TestFoundationFlutterBinding extends BindingBase {
bool wasLocked; bool? wasLocked;
@override @override
Future<void> performReassemble() async { Future<void> performReassemble() async {
...@@ -21,8 +19,6 @@ class TestFoundationFlutterBinding extends BindingBase { ...@@ -21,8 +19,6 @@ class TestFoundationFlutterBinding extends BindingBase {
TestFoundationFlutterBinding binding = TestFoundationFlutterBinding(); TestFoundationFlutterBinding binding = TestFoundationFlutterBinding();
void main() { void main() {
binding ??= TestFoundationFlutterBinding();
test('Pointer events are locked during reassemble', () async { test('Pointer events are locked during reassemble', () async {
await binding.reassembleApplication(); await binding.reassembleApplication();
expect(binding.wasLocked, isTrue); expect(binding.wasLocked, isTrue);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // web does not support certain 64bit behavior @TestOn('!chrome') // web does not support certain 64bit behavior
import 'dart:typed_data'; import 'dart:typed_data';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
...@@ -31,9 +29,10 @@ class TestServiceExtensionsBinding extends BindingBase ...@@ -31,9 +29,10 @@ class TestServiceExtensionsBinding extends BindingBase
final Map<String, List<Map<String, dynamic>>> eventsDispatched = <String, List<Map<String, dynamic>>>{}; final Map<String, List<Map<String, dynamic>>> eventsDispatched = <String, List<Map<String, dynamic>>>{};
@override @override
@protected
void registerServiceExtension({ void registerServiceExtension({
@required String name, required String name,
@required ServiceExtensionCallback callback, required ServiceExtensionCallback callback,
}) { }) {
expect(extensions.containsKey(name), isFalse); expect(extensions.containsKey(name), isFalse);
extensions[name] = callback; extensions[name] = callback;
...@@ -55,7 +54,7 @@ class TestServiceExtensionsBinding extends BindingBase ...@@ -55,7 +54,7 @@ class TestServiceExtensionsBinding extends BindingBase
Future<Map<String, dynamic>> testExtension(String name, Map<String, String> arguments) { Future<Map<String, dynamic>> testExtension(String name, Map<String, String> arguments) {
expect(extensions.containsKey(name), isTrue); expect(extensions.containsKey(name), isTrue);
return extensions[name](arguments); return extensions[name]!(arguments);
} }
int reassembled = 0; int reassembled = 0;
...@@ -75,13 +74,10 @@ class TestServiceExtensionsBinding extends BindingBase ...@@ -75,13 +74,10 @@ class TestServiceExtensionsBinding extends BindingBase
} }
Future<void> doFrame() async { Future<void> doFrame() async {
frameScheduled = false; frameScheduled = false;
if (ui.window.onBeginFrame != null) ui.window.onBeginFrame?.call(Duration.zero);
ui.window.onBeginFrame(Duration.zero);
await flushMicrotasks(); await flushMicrotasks();
if (ui.window.onDrawFrame != null) ui.window.onDrawFrame?.call();
ui.window.onDrawFrame(); ui.window.onReportTimings?.call(<ui.FrameTiming>[]);
if (ui.window.onReportTimings != null)
ui.window.onReportTimings(<ui.FrameTiming>[]);
} }
@override @override
...@@ -102,7 +98,7 @@ class TestServiceExtensionsBinding extends BindingBase ...@@ -102,7 +98,7 @@ class TestServiceExtensionsBinding extends BindingBase
} }
} }
TestServiceExtensionsBinding binding; late TestServiceExtensionsBinding binding;
Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingResult) async { Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingResult) async {
bool completed = false; bool completed = false;
...@@ -120,7 +116,7 @@ Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingR ...@@ -120,7 +116,7 @@ Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingR
} }
void main() { void main() {
final List<String> console = <String>[]; final List<String?> console = <String?>[];
setUpAll(() async { setUpAll(() async {
binding = TestServiceExtensionsBinding()..scheduleFrame(); binding = TestServiceExtensionsBinding()..scheduleFrame();
...@@ -150,7 +146,7 @@ void main() { ...@@ -150,7 +146,7 @@ void main() {
expect(binding.frameScheduled, isFalse); expect(binding.frameScheduled, isFalse);
expect(debugPrint, equals(debugPrintThrottled)); expect(debugPrint, equals(debugPrintThrottled));
debugPrint = (String message, { int wrapWidth }) { debugPrint = (String? message, { int? wrapWidth }) {
console.add(message); console.add(message);
}; };
}); });
...@@ -208,7 +204,7 @@ void main() { ...@@ -208,7 +204,7 @@ void main() {
bool lastValue = false; bool lastValue = false;
Future<void> _updateAndCheck(bool newValue) async { Future<void> _updateAndCheck(bool newValue) async {
Map<String, dynamic> result; Map<String, dynamic>? result;
binding.testExtension( binding.testExtension(
'debugCheckElevationsEnabled', 'debugCheckElevationsEnabled',
<String, String>{'enabled': '$newValue'}, <String, String>{'enabled': '$newValue'},
...@@ -458,8 +454,8 @@ void main() { ...@@ -458,8 +454,8 @@ void main() {
bool completed; bool completed;
completed = false; completed = false;
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData message) async { ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async {
expect(utf8.decode(message.buffer.asUint8List()), 'test'); expect(utf8.decode(message!.buffer.asUint8List()), 'test');
completed = true; completed = true;
return ByteData(5); // 0x0000000000 return ByteData(5); // 0x0000000000
}); });
...@@ -472,8 +468,7 @@ void main() { ...@@ -472,8 +468,7 @@ void main() {
expect(completed, isTrue); expect(completed, isTrue);
completed = false; completed = false;
data = await rootBundle.loadStructuredData('test', (String value) async { data = await rootBundle.loadStructuredData('test', (String value) async {
expect(true, isFalse); throw Error();
return null;
}); });
expect(data, isTrue); expect(data, isTrue);
expect(completed, isFalse); expect(completed, isFalse);
...@@ -486,7 +481,7 @@ void main() { ...@@ -486,7 +481,7 @@ void main() {
}); });
expect(data, isFalse); expect(data, isFalse);
expect(completed, isTrue); expect(completed, isTrue);
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null); ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null);
}); });
test('Service extensions - exit', () async { test('Service extensions - exit', () async {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
@TestOn('!chrome') // web has different stack traces @TestOn('!chrome') // web has different stack traces
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import '../flutter_test_alternative.dart'; import '../flutter_test_alternative.dart';
...@@ -11,7 +9,7 @@ void main() { ...@@ -11,7 +9,7 @@ void main() {
test('SynchronousFuture control test', () async { test('SynchronousFuture control test', () async {
final Future<int> future = SynchronousFuture<int>(42); final Future<int> future = SynchronousFuture<int>(42);
int result; int? result;
future.then<void>((int value) { result = value; }); future.then<void>((int value) { result = value; });
expect(result, equals(42)); expect(result, equals(42));
...@@ -39,16 +37,16 @@ void main() { ...@@ -39,16 +37,16 @@ void main() {
expect(await completeResult, equals(42)); expect(await completeResult, equals(42));
Object exception; Object? exception;
try { try {
await future.whenComplete(() { await future.whenComplete(() {
throw null; throw ArgumentError();
}); });
// Unreached. // Unreached.
expect(false, isTrue); expect(false, isTrue);
} catch (e) { } catch (e) {
exception = e; exception = e;
} }
expect(exception, isNullThrownError); expect(exception, isArgumentError);
}); });
} }
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