Unverified Commit 4513e96a authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Migrate more material tests (#67591)

parent b79e3462
......@@ -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/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -37,10 +35,10 @@ void main() {
expect(material.elevation, 0.0);
expect(material.shadowColor, const Color(0xff000000));
expect(material.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0)));
expect(material.textStyle.color, colorScheme.primary);
expect(material.textStyle.fontFamily, 'Roboto');
expect(material.textStyle.fontSize, 14);
expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.textStyle!.color, colorScheme.primary);
expect(material.textStyle!.fontFamily, 'Roboto');
expect(material.textStyle!.fontSize, 14);
expect(material.textStyle!.fontWeight, FontWeight.w500);
});
group('[Theme, TextTheme, TextButton style overrides]', () {
......@@ -78,7 +76,7 @@ void main() {
enableFeedback: enableFeedback,
);
Widget buildFrame({ ButtonStyle buttonStyle, ButtonStyle themeStyle, ButtonStyle overallStyle }) {
Widget buildFrame({ ButtonStyle? buttonStyle, ButtonStyle? themeStyle, ButtonStyle? overallStyle }) {
final Widget child = Builder(
builder: (BuildContext context) {
return TextButton(
......@@ -123,15 +121,15 @@ void main() {
void checkButton(WidgetTester tester) {
final Material material = tester.widget<Material>(findMaterial);
final InkWell inkWell = tester.widget<InkWell>(findInkWell);
expect(material.textStyle.color, primaryColor);
expect(material.textStyle.fontSize, 12);
expect(material.textStyle!.color, primaryColor);
expect(material.textStyle!.fontSize, 12);
expect(material.color, backgroundColor);
expect(material.shadowColor, shadowColor);
expect(material.elevation, elevation);
expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor, enabled), enabledMouseCursor);
expect(MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor, disabled), disabledMouseCursor);
expect(inkWell.overlayColor.resolve(hovered), primaryColor.withOpacity(0.04));
expect(inkWell.overlayColor.resolve(focused), primaryColor.withOpacity(0.12));
expect(MaterialStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, enabled), enabledMouseCursor);
expect(MaterialStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, disabled), disabledMouseCursor);
expect(inkWell.overlayColor!.resolve(hovered), primaryColor.withOpacity(0.04));
expect(inkWell.overlayColor!.resolve(focused), primaryColor.withOpacity(0.12));
expect(inkWell.enableFeedback, enableFeedback);
expect(material.borderRadius, null);
expect(material.shape, shape);
......@@ -183,7 +181,7 @@ void main() {
const Color shadowColor = Color(0xff000001);
const Color overiddenColor = Color(0xff000002);
Widget buildFrame({ Color overallShadowColor, Color themeShadowColor, Color shadowColor }) {
Widget buildFrame({ Color? overallShadowColor, Color? themeShadowColor, Color? shadowColor }) {
return MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme).copyWith(
shadowColor: overallShadowColor,
......
......@@ -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/material.dart';
......@@ -40,7 +38,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse);
Navigator.of(tester.element(find.text('Dialog'))).pop();
Navigator.of(tester.element(find.text('Dialog')))!.pop();
await tester.pump();
expect(focusNode.hasPrimaryFocus, isTrue);
......@@ -177,7 +175,7 @@ void main() {
testWidgets('Focus keep-alive works with GlobalKey reparenting', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
Widget makeTest(String prefix) {
Widget makeTest(String? prefix) {
return MaterialApp(
home: Material(
child: ListView(
......
......@@ -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/material.dart';
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/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -74,7 +72,7 @@ Future<void> restoreAndVerify(WidgetTester tester) async {
}
class TestWidget extends StatefulWidget {
const TestWidget({Key key, this.useExternal = false}) : super(key: key);
const TestWidget({Key? key, this.useExternal = false}) : super(key: key);
final bool useExternal;
......@@ -89,7 +87,7 @@ class TestWidgetState extends State<TestWidget> with RestorationMixin {
String get restorationId => 'widget';
@override
void restoreState(RestorationBucket oldBucket, bool initialRestore) {
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
registerForRestoration(controller, 'controller');
}
......
......@@ -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' show kPressTimeout;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -14,17 +12,17 @@ bool cancelCalled = false;
class TestInkSplash extends InkSplash {
TestInkSplash({
MaterialInkController controller,
RenderBox referenceBox,
Offset position,
Color color,
required MaterialInkController controller,
required RenderBox referenceBox,
Offset? position,
required Color color,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
ShapeBorder customBorder,
double radius,
VoidCallback onRemoved,
TextDirection textDirection,
RectCallback? rectCallback,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
double? radius,
VoidCallback? onRemoved,
required TextDirection textDirection,
}) : super(
controller: controller,
referenceBox: referenceBox,
......@@ -57,17 +55,17 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
@override
InteractiveInkFeature create({
MaterialInkController controller,
RenderBox referenceBox,
Offset position,
Color color,
required MaterialInkController controller,
required RenderBox referenceBox,
Offset? position,
required Color color,
bool containedInkWell = false,
RectCallback rectCallback,
BorderRadius borderRadius,
ShapeBorder customBorder,
double radius,
VoidCallback onRemoved,
TextDirection textDirection,
RectCallback? rectCallback,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
double? radius,
VoidCallback? onRemoved,
required TextDirection textDirection,
}) {
return TestInkSplash(
controller: controller,
......
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