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