mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Handle#6537 first grouped tests (#182077)
This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the following widgets: AnimatedOpacity AnimatedDefaultTextStyle AnimatedPhysicalModel AnimatedFractionallySizedBox InteractiveViewer LayoutBuilder ListWheelScrollView ListWheelViewport Localizations RawMagnifier ModalBarrier --------- Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This commit is contained in:
parent
1f506886e1
commit
76f70d21da
@ -370,4 +370,18 @@ void main() {
|
||||
);
|
||||
expect(tester.getSize(find.byType(CupertinoMagnifier)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('RawMagnifier does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: RawMagnifier(size: Size.square(2), child: Text('X')),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(RawMagnifier)), Size.zero);
|
||||
});
|
||||
}
|
||||
|
||||
@ -713,6 +713,81 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(find.byType(AnimatedRotation)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedOpacity does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
child: AnimatedOpacity(opacity: 0.5, duration: Duration(milliseconds: 300)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(find.byType(AnimatedOpacity)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedDefaultTextStyle does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: AnimatedDefaultTextStyle(
|
||||
style: TextStyle(fontStyle: FontStyle.italic),
|
||||
duration: Duration(milliseconds: 300),
|
||||
child: Text('X'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(find.byType(AnimatedDefaultTextStyle)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPhysicalModel does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: AnimatedPhysicalModel(
|
||||
color: Colors.teal,
|
||||
shadowColor: Colors.tealAccent,
|
||||
duration: Duration(milliseconds: 300),
|
||||
child: Text('X'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(find.byType(AnimatedPhysicalModel)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedFractionallySizedBox does not crash at zero area', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: AnimatedFractionallySizedBox(
|
||||
duration: Duration(milliseconds: 300),
|
||||
widthFactor: 0.5,
|
||||
heightFactor: 0.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.getSize(find.byType(AnimatedFractionallySizedBox)), Size.zero);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> tapTest2and3(
|
||||
|
||||
@ -1941,6 +1941,18 @@ void main() {
|
||||
expect(nearestPoint.y, moreOrLessEquals(10.8, epsilon: 0.1));
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('InteractiveViewer does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(child: InteractiveViewer(child: const Text('X'))),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(InteractiveViewer)), Size.zero);
|
||||
});
|
||||
}
|
||||
|
||||
Rect _axisAlignedBoundingBox(Quad quad) {
|
||||
|
||||
@ -38,6 +38,18 @@ void main() {
|
||||
expect(childBox.size, equals(const Size(50.0, 100.0)));
|
||||
});
|
||||
|
||||
testWidgets('LayoutBuilder does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(child: LayoutBuilder(builder: (_, _) => const Text('X'))),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(LayoutBuilder)), Size.zero);
|
||||
});
|
||||
|
||||
testWidgets('SliverLayoutBuilder parent geometry', (WidgetTester tester) async {
|
||||
late SliverConstraints parentConstraints1;
|
||||
late SliverConstraints parentConstraints2;
|
||||
|
||||
@ -2040,13 +2040,15 @@ void main() {
|
||||
});
|
||||
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/140780.
|
||||
// and https://github.com/flutter/flutter/issues/6537.
|
||||
testWidgets(
|
||||
'ListWheelScrollView in an AnimatedContainer with zero height does not throw an error',
|
||||
'ListWheelScrollView in an AnimatedContainer with zero width and height does not throw an error',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: AnimatedContainer(
|
||||
width: 0,
|
||||
height: 0,
|
||||
duration: Duration.zero,
|
||||
child: ListWheelScrollView(
|
||||
@ -2059,6 +2061,8 @@ void main() {
|
||||
);
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(tester.getSize(find.byType(ListWheelScrollView)), Size.zero);
|
||||
expect(tester.getSize(find.byType(ListWheelViewport)), Size.zero);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -210,6 +210,24 @@ void main() {
|
||||
expect(node3.getSemanticsData().locale, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Localizations does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(
|
||||
child: SizedBox.shrink(
|
||||
child: Localizations(
|
||||
locale: const Locale('fo'),
|
||||
delegates: <LocalizationsDelegate<dynamic>>[WidgetsLocalizationsDelegate()],
|
||||
child: const Text('X'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(Localizations)), Size.zero);
|
||||
});
|
||||
}
|
||||
|
||||
class FakeLocalizationsDelegate extends LocalizationsDelegate<String> {
|
||||
|
||||
@ -498,6 +498,16 @@ void main() {
|
||||
TargetPlatform.android,
|
||||
}),
|
||||
);
|
||||
|
||||
testWidgets('ModalBarrier does not crash at zero area', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Center(child: SizedBox.shrink(child: ModalBarrier())),
|
||||
),
|
||||
);
|
||||
expect(tester.getSize(find.byType(ModalBarrier)), Size.zero);
|
||||
});
|
||||
});
|
||||
group('AnimatedModalBarrier', () {
|
||||
testWidgets('prevents interactions with widgets behind it', (WidgetTester tester) async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user