Unverified Commit 31a2c9d4 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate missed tests (#68241)

parent 4e3f4bb6
......@@ -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/animation.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 'dart:typed_data';
import 'package:flutter/cupertino.dart';
......@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../image_data.dart';
List<int> selectedTabs;
late List<int> selectedTabs;
void main() {
setUp(() {
......@@ -170,12 +168,12 @@ void main() {
matching: find.byType(RichText),
));
// Tab 2 should still be selected after changing theme.
expect(tab1.text.style.color.value, 0xFF757575);
expect(tab1.text.style!.color!.value, 0xFF757575);
final RichText tab2 = tester.widget(find.descendant(
of: find.text('Tab 2'),
matching: find.byType(RichText),
));
expect(tab2.text.style.color.value, CupertinoColors.systemRed.darkColor.value);
expect(tab2.text.style!.color!.value, CupertinoColors.systemRed.darkColor.value);
});
testWidgets('dark mode background color', (WidgetTester tester) async {
......@@ -205,7 +203,7 @@ void main() {
)
).decoration as BoxDecoration;
expect(tabDecoration.color.value, backgroundColor.color.value);
expect(tabDecoration.color!.value, backgroundColor.color.value);
// Dark mode
await tester.pumpWidget(
......@@ -228,7 +226,7 @@ void main() {
)
).decoration as BoxDecoration;
expect(tabDecoration.color.value, backgroundColor.darkColor.value);
expect(tabDecoration.color!.value, backgroundColor.darkColor.value);
});
testWidgets('Does not lose state when focusing on text input', (WidgetTester tester) async {
......@@ -284,7 +282,7 @@ void main() {
MaterialApp(
home: Builder(builder: (BuildContext context) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(textScaleFactor: 99),
data: MediaQuery.of(context)!.copyWith(textScaleFactor: 99),
child: CupertinoTabScaffold(
tabBar: CupertinoTabBar(
items: List<BottomNavigationBarItem>.generate(
......
......@@ -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 '../../../../examples/layers/rendering/custom_coordinate_systems.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 '../flutter_test_alternative.dart';
void main() {
......
......@@ -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/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -37,10 +35,10 @@ void main() {
expect(material.color, const Color(0x00000000));
expect(material.elevation, 0.0);
expect(material.shadowColor, null);
expect(material.textStyle.color, const Color(0xdd000000));
expect(material.textStyle.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.textStyle!.color, const Color(0xdd000000));
expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle!.fontSize, 14);
expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button);
final Offset center = tester.getCenter(find.byType(OutlineButton));
......@@ -56,10 +54,10 @@ void main() {
expect(material.color, const Color(0x00000000));
expect(material.elevation, 0.0);
expect(material.shadowColor, null);
expect(material.textStyle.color, const Color(0xdd000000));
expect(material.textStyle.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.textStyle!.color, const Color(0xdd000000));
expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle!.fontSize, 14);
expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button);
// Disabled OutlineButton
......@@ -80,10 +78,10 @@ void main() {
expect(material.color, const Color(0x00000000));
expect(material.elevation, 0.0);
expect(material.shadowColor, null);
expect(material.textStyle.color, const Color(0x61000000));
expect(material.textStyle.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.textStyle!.color, const Color(0x61000000));
expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle!.fontSize, 14);
expect(material.textStyle!.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button);
});
......@@ -132,7 +130,7 @@ void main() {
addTearDown(gesture.removePointer);
await tester.pump();
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
await tester.pumpWidget(
Directionality(
......@@ -147,7 +145,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
// Test default cursor
await tester.pumpWidget(
......@@ -162,7 +160,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
// Test default cursor when disabled
await tester.pumpWidget(
......@@ -177,7 +175,7 @@ void main() {
),
);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(RendererBinding.instance!.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});
testWidgets('Does OutlineButton work with focus', (WidgetTester tester) async {
......@@ -311,9 +309,9 @@ void main() {
MaterialState.focused,
};
if (states.any(interactiveStates.contains)) {
return Colors.blue[900];
return Colors.blue[900]!;
}
return Colors.blue[800];
return Colors.blue[800]!;
}
await tester.pumpWidget(
......@@ -400,8 +398,8 @@ void main() {
),
);
Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('OutlineButton')).text.style.color;
Color? textColor() {
return tester.renderObject<RenderParagraph>(find.text('OutlineButton')).text.style!.color;
}
// Default, not disabled.
......@@ -469,7 +467,7 @@ void main() {
),
);
Color iconColor() => _iconStyle(tester, Icons.add).color;
Color? iconColor() => _iconStyle(tester, Icons.add).color;
// Default, not disabled.
expect(iconColor(), equals(defaultColor));
......@@ -526,8 +524,8 @@ void main() {
),
);
Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('OutlineButton')).text.style.color;
Color? textColor() {
return tester.renderObject<RenderParagraph>(find.text('OutlineButton')).text.style!.color;
}
// Disabled.
......@@ -672,7 +670,7 @@ void main() {
bool wasPressed;
Finder outlineButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
Widget buildFrame({ VoidCallback? onPressed, VoidCallback? onLongPress }) {
return Directionality(
textDirection: TextDirection.ltr,
child: OutlineButton(
......@@ -712,7 +710,7 @@ void main() {
});
testWidgets("Outline button doesn't crash if disabled during a gesture", (WidgetTester tester) async {
Widget buildFrame(VoidCallback onPressed) {
Widget buildFrame(VoidCallback? onPressed) {
return Directionality(
textDirection: TextDirection.ltr,
child: Theme(
......@@ -738,7 +736,7 @@ void main() {
const Color disabledBorderColor = Color(0xFFFF00FF);
const double borderWidth = 4.0;
Widget buildFrame({ VoidCallback onPressed }) {
Widget buildFrame({ VoidCallback? onPressed }) {
return Directionality(
textDirection: TextDirection.ltr,
child: Theme(
......@@ -1005,7 +1003,7 @@ void main() {
// Default value for dark Theme.of(context).canvasColor as well as
// the OutlineButton fill color when the button has been pressed.
Color fillColor = Colors.grey[850];
Color fillColor = Colors.grey[850]!;
// Initially the interior of the button is transparent.
_checkPhysicalLayer(buttonElement, fillColor.withAlpha(0x00));
......@@ -1026,7 +1024,7 @@ void main() {
// Default value for light Theme.of(context).canvasColor as well as
// the OutlineButton fill color when the button has been pressed.
fillColor = Colors.grey[50];
fillColor = Colors.grey[50]!;
// Initially the interior of the button is transparent.
// expect(button, paints..path(color: fillColor.withAlpha(0x00)));
......@@ -1228,24 +1226,25 @@ void main() {
PhysicalModelLayer _findPhysicalLayer(Element element) {
expect(element, isNotNull);
RenderObject object = element.renderObject;
RenderObject? object = element.renderObject;
while (object != null && object is! RenderRepaintBoundary && object is! RenderView) {
object = object.parent as RenderObject;
object = object.parent as RenderObject?;
}
expect(object.debugLayer, isNotNull);
expect(object.debugLayer.firstChild, isA<PhysicalModelLayer>());
final PhysicalModelLayer layer = object.debugLayer.firstChild as PhysicalModelLayer;
final Layer child = layer.firstChild;
assert(object != null);
expect(object!.debugLayer, isNotNull);
expect(object.debugLayer!.firstChild, isA<PhysicalModelLayer>());
final PhysicalModelLayer layer = object.debugLayer!.firstChild! as PhysicalModelLayer;
final Layer child = layer.firstChild!;
return child is PhysicalModelLayer ? child : layer;
}
void _checkPhysicalLayer(Element element, Color expectedColor, { Path clipPath, Rect clipRect }) {
void _checkPhysicalLayer(Element element, Color expectedColor, { Path? clipPath, Rect? clipRect }) {
final PhysicalModelLayer expectedLayer = _findPhysicalLayer(element);
expect(expectedLayer.elevation, 0.0);
expect(expectedLayer.color, expectedColor);
if (clipPath != null) {
expect(clipRect, isNotNull);
expect(expectedLayer.clipPath, coversSameAreaAs(clipPath, areaToCompare: clipRect.inflate(10.0)));
expect(expectedLayer.clipPath, coversSameAreaAs(clipPath, areaToCompare: clipRect!.inflate(10.0)));
}
}
......@@ -1253,5 +1252,5 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final RichText iconRichText = tester.widget<RichText>(
find.descendant(of: find.byIcon(icon), matching: find.byType(RichText)),
);
return iconRichText.text.style;
return iconRichText.text.style!;
}
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