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