Unverified Commit 38e0c258 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] reland: enable --null-assertions for flutter framework tests (#64120)

Reland of acdb909f with fixes to semantics.dart

#61042
parent 266b9f99
...@@ -538,7 +538,7 @@ Future<void> _runAddToAppLifeCycleTests() async { ...@@ -538,7 +538,7 @@ Future<void> _runAddToAppLifeCycleTests() async {
Future<void> _runFrameworkTests() async { Future<void> _runFrameworkTests() async {
final bq.BigqueryApi bigqueryApi = await _getBigqueryApi(); final bq.BigqueryApi bigqueryApi = await _getBigqueryApi();
final List<String> nullSafetyOptions = <String>['--enable-experiment=non-nullable']; final List<String> nullSafetyOptions = <String>['--enable-experiment=non-nullable', '--null-assertions'];
final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation']; final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation'];
Future<void> runWidgets() async { Future<void> runWidgets() async {
......
...@@ -3624,7 +3624,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox { ...@@ -3624,7 +3624,7 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
RenderSemanticsAnnotations({ RenderSemanticsAnnotations({
RenderBox child, RenderBox child,
bool container = false, bool container = false,
bool explicitChildNodes, bool explicitChildNodes = false,
bool excludeSemantics = false, bool excludeSemantics = false,
bool enabled, bool enabled,
bool checked, bool checked,
......
...@@ -36,7 +36,7 @@ class RawKeyEventDataWeb extends RawKeyEventData { ...@@ -36,7 +36,7 @@ class RawKeyEventDataWeb extends RawKeyEventData {
/// ///
/// See <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key> /// See <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key>
/// for more information. /// for more information.
final String key; final String? key;
/// The modifiers that were present when the key event occurred. /// The modifiers that were present when the key event occurred.
/// ///
...@@ -56,7 +56,7 @@ class RawKeyEventDataWeb extends RawKeyEventData { ...@@ -56,7 +56,7 @@ class RawKeyEventDataWeb extends RawKeyEventData {
final int metaState; final int metaState;
@override @override
String get keyLabel => key; String? get keyLabel => key;
@override @override
PhysicalKeyboardKey get physicalKey { PhysicalKeyboardKey get physicalKey {
......
...@@ -149,7 +149,7 @@ void main() { ...@@ -149,7 +149,7 @@ void main() {
test('TextPainter error test', () { test('TextPainter error test', () {
final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); final TextPainter painter = TextPainter(textDirection: TextDirection.ltr);
expect(() { painter.paint(null, Offset.zero); }, throwsFlutterError); expect(() { painter.paint(null, Offset.zero); }, anyOf(throwsFlutterError, throwsAssertionError));
}); });
test('TextPainter requires textDirection', () { test('TextPainter requires textDirection', () {
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import '../flutter_test_alternative.dart';
void main() { void main() {
test('TextSpan equals', () { test('TextSpan equals', () {
...@@ -44,7 +43,6 @@ void main() { ...@@ -44,7 +43,6 @@ void main() {
TextSpan(), TextSpan(),
], ],
), ),
null,
TextSpan( TextSpan(
text: 'c', text: 'c',
), ),
...@@ -59,7 +57,6 @@ void main() { ...@@ -59,7 +57,6 @@ void main() {
' "b"\n' ' "b"\n'
' TextSpan:\n' ' TextSpan:\n'
' (empty)\n' ' (empty)\n'
' <null child>\n'
' TextSpan:\n' ' TextSpan:\n'
' "c"\n' ' "c"\n'
)); ));
...@@ -245,21 +242,7 @@ void main() { ...@@ -245,21 +242,7 @@ void main() {
null, null,
], ],
); );
FlutterError error; expect(() => text.computeToPlainText(StringBuffer()), anyOf(throwsFlutterError, throwsAssertionError));
try {
text.computeToPlainText(StringBuffer());
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(error.toStringDeep(),
'FlutterError\n'
' TextSpan contains a null child.\n'
' A TextSpan object with a non-null child list should not have any\n'
' nulls in its child list.\n'
' The full text in question was:\n'
' TextSpan("foo bar")\n'
);
}); });
} }
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