Unverified Commit ef119187 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Convert some widgets tests to NNBD (#67782)

Migrating some more widget tests to NNBD.
parent 085f1daa
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math;
import 'package:flutter_test/flutter_test.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -12,8 +10,8 @@ void main() {
testWidgets('FadeTransition', (WidgetTester tester) async {
final DebugPrintCallback oldPrint = debugPrint;
final List<String> log = <String>[];
debugPrint = (String message, { int wrapWidth }) {
log.add(message);
debugPrint = (String? message, { int? wrapWidth }) {
log.add(message!);
};
debugPrintBuildScope = true;
final AnimationController controller = AnimationController(
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
......@@ -595,12 +593,11 @@ void main() {
List<Type> getLayers() {
final List<Type> layers = <Type>[];
Layer layer = RendererBinding.instance.renderView.debugLayer;
while (layer is ContainerLayer) {
final ContainerLayer container = layer as ContainerLayer;
Layer? container = RendererBinding.instance!.renderView.debugLayer;
while (container is ContainerLayer) {
layers.add(container.runtimeType);
expect(container.firstChild, same(container.lastChild));
layer = container.firstChild;
container = container.firstChild;
}
return layers;
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
......@@ -63,18 +61,6 @@ void main() {
expect(box.size.width, 100.0);
});
testWidgets('Can pass null for flex', (WidgetTester tester) async {
await tester.pumpWidget(
Row(
textDirection: TextDirection.ltr,
children: const <Widget>[
Expanded(flex: null, child: Text('one', textDirection: TextDirection.ltr)),
Flexible(flex: null, child: Text('two', textDirection: TextDirection.ltr)),
],
),
);
});
testWidgets("Doesn't overflow because of floating point accumulated error", (WidgetTester tester) async {
// both of these cases have failed in the past due to floating point issues
await tester.pumpWidget(
......
......@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
class TestFlowDelegate extends FlowDelegate {
TestFlowDelegate({this.startOffset}) : super(repaint: startOffset);
TestFlowDelegate({required this.startOffset}) : super(repaint: startOffset);
final Animation<double> startOffset;
......@@ -23,7 +21,7 @@ class TestFlowDelegate extends FlowDelegate {
double dy = startOffset.value;
for (int i = 0; i < context.childCount; ++i) {
context.paintChild(i, transform: Matrix4.translationValues(0.0, dy, 0.0));
dy += 0.75 * context.getChildSize(i).height;
dy += 0.75 * context.getChildSize(i)!.height;
}
}
......@@ -149,13 +147,13 @@ void main() {
],
),
);
ContainerLayer layer = RendererBinding.instance.renderView.debugLayer;
ContainerLayer? layer = RendererBinding.instance!.renderView.debugLayer;
while (layer != null && layer is! OpacityLayer)
layer = layer.firstChild as ContainerLayer;
layer = layer.firstChild as ContainerLayer?;
expect(layer, isA<OpacityLayer>());
final OpacityLayer opacityLayer = layer as OpacityLayer;
expect(opacityLayer.alpha, equals(opacity * 255));
expect(layer.firstChild, isA<TransformLayer>());
final OpacityLayer? opacityLayer = layer as OpacityLayer?;
expect(opacityLayer!.alpha, equals(opacity * 255));
expect(layer!.firstChild, isA<TransformLayer>());
});
testWidgets('Flow can set and update clipBehavior', (WidgetTester tester) async {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
......@@ -18,7 +16,7 @@ void main() {
final GlobalKey widgetKey = GlobalKey();
Future<BuildContext> setupWidget(WidgetTester tester) async {
await tester.pumpWidget(Container(key: widgetKey));
return widgetKey.currentContext;
return widgetKey.currentContext!;
}
group(FocusNode, () {
......@@ -931,7 +929,7 @@ void main() {
}, variant: TargetPlatformVariant.all());
testWidgets('Mouse events change initial focus highlight mode on mobile.', (WidgetTester tester) async {
expect(FocusManager.instance.highlightMode, equals(FocusHighlightMode.touch));
RendererBinding.instance.initMouseTracker(); // Clear out the mouse state.
RendererBinding.instance!.initMouseTracker(); // Clear out the mouse state.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 0);
addTearDown(gesture.removePointer);
await gesture.moveTo(Offset.zero);
......@@ -939,7 +937,7 @@ void main() {
}, variant: TargetPlatformVariant.mobile());
testWidgets('Mouse events change initial focus highlight mode on desktop.', (WidgetTester tester) async {
expect(FocusManager.instance.highlightMode, equals(FocusHighlightMode.traditional));
RendererBinding.instance.initMouseTracker(); // Clear out the mouse state.
RendererBinding.instance!.initMouseTracker(); // Clear out the mouse state.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 0);
addTearDown(gesture.removePointer);
await gesture.moveTo(Offset.zero);
......@@ -952,7 +950,7 @@ void main() {
testWidgets('Events change focus highlight mode.', (WidgetTester tester) async {
await setupWidget(tester);
int callCount = 0;
FocusHighlightMode lastMode;
FocusHighlightMode? lastMode;
void handleModeChange(FocusHighlightMode mode) {
lastMode = mode;
callCount++;
......
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