Test cover some leak-free code. (#130543)
This commit is contained in:
committed by
GitHub
parent
9391923276
commit
d5e7f407e1
@@ -5,6 +5,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
|
||||
Widget wrap({ required Widget child, ThemeData? theme }) {
|
||||
return MaterialApp(
|
||||
theme: theme,
|
||||
@@ -15,7 +17,7 @@ Widget wrap({ required Widget child, ThemeData? theme }) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('ExpandIcon test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon test', (WidgetTester tester) async {
|
||||
bool expanded = false;
|
||||
IconTheme iconTheme;
|
||||
|
||||
@@ -73,7 +75,7 @@ void main() {
|
||||
expect(iconTheme.data.color, equals(Colors.white60));
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon disabled', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon disabled', (WidgetTester tester) async {
|
||||
IconTheme iconTheme;
|
||||
// Light mode test
|
||||
await tester.pumpWidget(wrap(
|
||||
@@ -96,7 +98,7 @@ void main() {
|
||||
expect(iconTheme.data.color, equals(Colors.white38));
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon test isExpanded does not trigger callback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon test isExpanded does not trigger callback', (WidgetTester tester) async {
|
||||
bool expanded = false;
|
||||
|
||||
await tester.pumpWidget(wrap(
|
||||
@@ -119,7 +121,7 @@ void main() {
|
||||
expect(expanded, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon is rotated initially if isExpanded is true on first build', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon is rotated initially if isExpanded is true on first build', (WidgetTester tester) async {
|
||||
bool expanded = true;
|
||||
|
||||
await tester.pumpWidget(wrap(
|
||||
@@ -134,7 +136,7 @@ void main() {
|
||||
expect(rotation.turns.value, 0.5);
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon default size is 24', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon default size is 24', (WidgetTester tester) async {
|
||||
final ExpandIcon expandIcon = ExpandIcon(
|
||||
onPressed: (bool isExpanded) {},
|
||||
);
|
||||
@@ -147,7 +149,7 @@ void main() {
|
||||
expect(icon.size, 24);
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon has the correct given size', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon has the correct given size', (WidgetTester tester) async {
|
||||
ExpandIcon expandIcon = ExpandIcon(
|
||||
size: 36,
|
||||
onPressed: (bool isExpanded) {},
|
||||
@@ -173,7 +175,7 @@ void main() {
|
||||
expect(icon.size, 48);
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon has correct semantic hints', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon has correct semantic hints', (WidgetTester tester) async {
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations();
|
||||
await tester.pumpWidget(wrap(
|
||||
@@ -210,7 +212,7 @@ void main() {
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon uses custom icon color and expanded icon color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon uses custom icon color and expanded icon color', (WidgetTester tester) async {
|
||||
bool expanded = false;
|
||||
IconTheme iconTheme;
|
||||
|
||||
@@ -271,7 +273,7 @@ void main() {
|
||||
expect(iconTheme.data.color, equals(Colors.indigo));
|
||||
});
|
||||
|
||||
testWidgets('ExpandIcon uses custom disabled icon color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ExpandIcon uses custom disabled icon color', (WidgetTester tester) async {
|
||||
IconTheme iconTheme;
|
||||
|
||||
await tester.pumpWidget(wrap(
|
||||
|
||||
@@ -8,9 +8,11 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
|
||||
void main() {
|
||||
group('Basic floating action button locations', () {
|
||||
testWidgets('still animates motion when the floating action button is null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('still animates motion when the floating action button is null', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_buildFrame(fab: null));
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
@@ -27,7 +29,7 @@ void main() {
|
||||
expect(tester.binding.transientCallbackCount, greaterThan(0));
|
||||
});
|
||||
|
||||
testWidgets('moves fab from center to end and back', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('moves fab from center to end and back', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_buildFrame(location: FloatingActionButtonLocation.endFloat));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(756.0, 356.0));
|
||||
@@ -52,7 +54,7 @@ void main() {
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('moves to and from custom-defined positions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('moves to and from custom-defined positions', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_buildFrame(location: const _StartTopFloatingActionButtonLocation()));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(44.0, 56.0));
|
||||
@@ -173,7 +175,7 @@ void main() {
|
||||
previousRotations = null;
|
||||
});
|
||||
|
||||
testWidgets('moving the fab to centerFloat', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('moving the fab to centerFloat', (WidgetTester tester) async {
|
||||
// Create a scaffold with the fab at endFloat
|
||||
await tester.pumpWidget(_buildFrame(location: FloatingActionButtonLocation.endFloat, listener: geometryListener));
|
||||
setupListener(tester);
|
||||
@@ -183,7 +185,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('interrupting motion towards the StartTop location.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('interrupting motion towards the StartTop location.', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_buildFrame(location: FloatingActionButtonLocation.centerFloat, listener: geometryListener));
|
||||
setupListener(tester);
|
||||
|
||||
@@ -196,7 +198,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('interrupting entrance to remove the fab.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('interrupting entrance to remove the fab.', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_buildFrame(fab: null, location: FloatingActionButtonLocation.centerFloat, listener: geometryListener));
|
||||
setupListener(tester);
|
||||
|
||||
@@ -215,7 +217,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('interrupting entrance of a new fab.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('interrupting entrance of a new fab.', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
_buildFrame(
|
||||
fab: null,
|
||||
@@ -241,7 +243,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Docked floating action button locations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Docked floating action button locations', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
_buildFrame(
|
||||
location: FloatingActionButtonLocation.endDocked,
|
||||
@@ -276,7 +278,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(756.0, 500.0));
|
||||
});
|
||||
|
||||
testWidgets('Docked floating action button locations: no BAB, small BAB', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Docked floating action button locations: no BAB, small BAB', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
_buildFrame(
|
||||
location: FloatingActionButtonLocation.endDocked,
|
||||
@@ -295,7 +297,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(756.0, 572.0));
|
||||
});
|
||||
|
||||
testWidgets('Contained floating action button locations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Contained floating action button locations', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
_buildFrame(
|
||||
location: FloatingActionButtonLocation.endContained,
|
||||
@@ -310,7 +312,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(756.0, 550.0));
|
||||
});
|
||||
|
||||
testWidgets('Mini-start-top floating action button location', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Mini-start-top floating action button location', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -331,7 +333,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)).dy, kToolbarHeight);
|
||||
});
|
||||
|
||||
testWidgets('Start-top floating action button location LTR', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Start-top floating action button location LTR', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -344,7 +346,7 @@ void main() {
|
||||
expect(tester.getRect(find.byType(FloatingActionButton)), rectMoreOrLessEquals(const Rect.fromLTWH(16.0, 28.0, 56.0, 56.0)));
|
||||
});
|
||||
|
||||
testWidgets('End-top floating action button location RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('End-top floating action button location RTL', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Directionality(
|
||||
@@ -360,7 +362,7 @@ void main() {
|
||||
expect(tester.getRect(find.byType(FloatingActionButton)), rectMoreOrLessEquals(const Rect.fromLTWH(16.0, 28.0, 56.0, 56.0)));
|
||||
});
|
||||
|
||||
testWidgets('Start-top floating action button location RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Start-top floating action button location RTL', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Directionality(
|
||||
@@ -376,7 +378,7 @@ void main() {
|
||||
expect(tester.getRect(find.byType(FloatingActionButton)), rectMoreOrLessEquals(const Rect.fromLTWH(800.0 - 56.0 - 16.0, 28.0, 56.0, 56.0)));
|
||||
});
|
||||
|
||||
testWidgets('End-top floating action button location LTR', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('End-top floating action button location LTR', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -390,19 +392,19 @@ void main() {
|
||||
});
|
||||
|
||||
group('New Floating Action Button Locations', () {
|
||||
testWidgets('startTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('startTop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.startTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _topOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('centerTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('centerTop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.centerTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _topOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('endTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('endTop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX, _topOffsetY));
|
||||
@@ -438,25 +440,25 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _dockedOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('endDocked', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('endDocked', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endDocked));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX, _dockedOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('endContained', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('endContained', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endContained));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX, _containedOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('miniStartTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('miniStartTop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.miniStartTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_miniLeftOffsetX, _topOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('miniEndTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('miniEndTop', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.miniEndTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_miniRightOffsetX, _topOffsetY));
|
||||
@@ -494,7 +496,7 @@ void main() {
|
||||
|
||||
// Test a few RTL cases.
|
||||
|
||||
testWidgets('endTop, RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('endTop, RTL', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endTop, textDirection: TextDirection.rtl));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _topOffsetY));
|
||||
@@ -508,25 +510,25 @@ void main() {
|
||||
});
|
||||
|
||||
group('Custom Floating Action Button Locations', () {
|
||||
testWidgets('Almost end float', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Almost end float', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(_AlmostEndFloatFabLocation()));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX - 50, _floatOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('Almost end float, RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Almost end float, RTL', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(_AlmostEndFloatFabLocation(), textDirection: TextDirection.rtl));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX + 50, _floatOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('Quarter end top', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Quarter end top', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(_QuarterEndTopFabLocation()));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX * 0.75 + _leftOffsetX * 0.25, _topOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('Quarter end top, RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Quarter end top, RTL', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(_QuarterEndTopFabLocation(), textDirection: TextDirection.rtl));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX * 0.75 + _rightOffsetX * 0.25, _topOffsetY));
|
||||
@@ -534,7 +536,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Moves involving new locations', () {
|
||||
testWidgets('Moves between new locations and new locations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Moves between new locations and new locations', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.centerTop));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _topOffsetY));
|
||||
@@ -556,7 +558,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _dockedOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('Moves between new locations and old locations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Moves between new locations and old locations', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endDocked));
|
||||
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX, _dockedOffsetY));
|
||||
@@ -586,7 +588,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _topOffsetY));
|
||||
});
|
||||
|
||||
testWidgets('Moves between new locations and old locations with custom animator', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Moves between new locations and old locations with custom animator', (WidgetTester tester) async {
|
||||
final FloatingActionButtonAnimator animator = _LinearMovementFabAnimator();
|
||||
const Offset begin = Offset(_centerOffsetX, _topOffsetY);
|
||||
const Offset end = Offset(_rightOffsetX - 50, _floatOffsetY);
|
||||
@@ -628,7 +630,7 @@ void main() {
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('Animator can be updated', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Animator can be updated', (WidgetTester tester) async {
|
||||
FloatingActionButtonAnimator fabAnimator = FloatingActionButtonAnimator.scaling;
|
||||
FloatingActionButtonLocation fabLocation = FloatingActionButtonLocation.startFloat;
|
||||
|
||||
@@ -1511,7 +1513,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('startTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('startTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(16.0, 50.0, 72.0, 106.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(16.0, 28.0, 72.0, 84.0);
|
||||
@@ -1523,7 +1525,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('miniStartTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('miniStartTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(12.0, 50.0, 60.0, 98.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(12.0, 32.0, 60.0, 80.0);
|
||||
@@ -1536,7 +1538,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('centerTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('centerTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(372.0, 50.0, 428.0, 106.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(372.0, 28.0, 428.0, 84.0);
|
||||
@@ -1548,7 +1550,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('miniCenterTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('miniCenterTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(376.0, 50.0, 424.0, 98.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(376.0, 32.0, 424.0, 80.0);
|
||||
@@ -1561,7 +1563,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('endTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('endTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(728.0, 50.0, 784.0, 106.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(728.0, 28.0, 784.0, 84.0);
|
||||
@@ -1573,7 +1575,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('miniEndTop', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('miniEndTop', (WidgetTester tester) async {
|
||||
const Rect defaultRect = Rect.fromLTRB(740.0, 50.0, 788.0, 98.0);
|
||||
// Positioned relative to AppBar
|
||||
const Rect appBarRect = Rect.fromLTRB(740.0, 32.0, 788.0, 80.0);
|
||||
|
||||
@@ -11,10 +11,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/src/foundation/constants.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('InkSparkle in a Button compiles and does not crash', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle in a Button compiles and does not crash', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@@ -34,7 +35,7 @@ void main() {
|
||||
skip: kIsWeb, // [intended] shaders are not yet supported for web.
|
||||
);
|
||||
|
||||
testWidgets('InkSparkle default splashFactory paints with drawRect when bounded', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle default splashFactory paints with drawRect when bounded', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@@ -65,7 +66,7 @@ void main() {
|
||||
skip: kIsWeb, // [intended] shaders are not yet supported for web.
|
||||
);
|
||||
|
||||
testWidgets('InkSparkle default splashFactory paints with drawPaint when unbounded', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle default splashFactory paints with drawPaint when unbounded', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@@ -92,19 +93,19 @@ void main() {
|
||||
// Goldens //
|
||||
/////////////
|
||||
|
||||
testWidgets('InkSparkle renders with sparkles when top left of button is tapped', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle renders with sparkles when top left of button is tapped', (WidgetTester tester) async {
|
||||
await _runTest(tester, 'top_left', 0.2);
|
||||
},
|
||||
skip: kIsWeb, // [intended] shaders are not yet supported for web.
|
||||
);
|
||||
|
||||
testWidgets('InkSparkle renders with sparkles when center of button is tapped', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle renders with sparkles when center of button is tapped', (WidgetTester tester) async {
|
||||
await _runTest(tester, 'center', 0.5);
|
||||
},
|
||||
skip: kIsWeb, // [intended] shaders are not yet supported for web.
|
||||
);
|
||||
|
||||
testWidgets('InkSparkle renders with sparkles when bottom right of button is tapped', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('InkSparkle renders with sparkles when bottom right of button is tapped', (WidgetTester tester) async {
|
||||
await _runTest(tester, 'bottom_right', 0.8);
|
||||
},
|
||||
skip: kIsWeb, // [intended] shaders are not yet supported for web.
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
import '../widgets/test_border.dart' show TestBorder;
|
||||
|
||||
@@ -72,7 +73,7 @@ class ElevationColor {
|
||||
|
||||
void main() {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/81504
|
||||
testWidgets('MaterialApp.home nullable and update test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('MaterialApp.home nullable and update test', (WidgetTester tester) async {
|
||||
// _WidgetsAppState._usesNavigator == true
|
||||
await tester.pumpWidget(const MaterialApp(home: SizedBox.shrink()));
|
||||
|
||||
@@ -85,7 +86,7 @@ void main() {
|
||||
expect(tester.takeException(), null);
|
||||
});
|
||||
|
||||
testWidgets('default Material debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('default Material debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
const Material().debugFillProperties(builder);
|
||||
|
||||
@@ -97,7 +98,7 @@ void main() {
|
||||
expect(description, <String>['type: canvas']);
|
||||
});
|
||||
|
||||
testWidgets('Material implements debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material implements debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
const Material(
|
||||
color: Color(0xFFFFFFFF),
|
||||
@@ -123,7 +124,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('LayoutChangedNotification test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('LayoutChangedNotification test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Material(
|
||||
child: NotifyMaterial(),
|
||||
@@ -131,7 +132,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ListView scroll does not repaint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ListView scroll does not repaint', (WidgetTester tester) async {
|
||||
final List<Size> log = <Size>[];
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -190,7 +191,7 @@ void main() {
|
||||
expect(log, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('Shadow color defaults', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Shadow color defaults', (WidgetTester tester) async {
|
||||
Widget buildWithShadow(Color? shadowColor) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
@@ -242,7 +243,7 @@ void main() {
|
||||
expect(getModel(tester).shadowColor, Colors.transparent);
|
||||
});
|
||||
|
||||
testWidgets('Shadows animate smoothly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Shadows animate smoothly', (WidgetTester tester) async {
|
||||
// This code verifies that the PhysicalModel's elevation animates over
|
||||
// a kThemeChangeDuration time interval.
|
||||
|
||||
@@ -267,7 +268,7 @@ void main() {
|
||||
expect(modelE.elevation, equals(9.0));
|
||||
});
|
||||
|
||||
testWidgets('Shadow colors animate smoothly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Shadow colors animate smoothly', (WidgetTester tester) async {
|
||||
// This code verifies that the PhysicalModel's shadowColor animates over
|
||||
// a kThemeChangeDuration time interval.
|
||||
|
||||
@@ -292,7 +293,7 @@ void main() {
|
||||
expect(modelE.shadowColor, equals(const Color(0xFFFF0000)));
|
||||
});
|
||||
|
||||
testWidgets('Transparent material widget does not absorb hit test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Transparent material widget does not absorb hit test', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/58665.
|
||||
bool pressed = false;
|
||||
await tester.pumpWidget(
|
||||
@@ -323,7 +324,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Surface Tint Overlay', () {
|
||||
testWidgets('applyElevationOverlayColor does not effect anything with useMaterial3 set to true', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('applyElevationOverlayColor does not effect anything with useMaterial3 set to true', (WidgetTester tester) async {
|
||||
const Color surfaceColor = Color(0xFF121212);
|
||||
await tester.pumpWidget(Theme(
|
||||
data: ThemeData(
|
||||
@@ -337,7 +338,7 @@ void main() {
|
||||
expect(model.color, equals(surfaceColor));
|
||||
});
|
||||
|
||||
testWidgets('surfaceTintColor is used to as an overlay to indicate elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('surfaceTintColor is used to as an overlay to indicate elevation', (WidgetTester tester) async {
|
||||
const Color baseColor = Color(0xFF121212);
|
||||
const Color surfaceTintColor = Color(0xff44CCFF);
|
||||
|
||||
@@ -400,7 +401,7 @@ void main() {
|
||||
group('Elevation Overlay M2', () {
|
||||
// These tests only apply to the Material 2 overlay mechanism. This group
|
||||
// can be removed after migration to Material 3 is complete.
|
||||
testWidgets('applyElevationOverlayColor set to false does not change surface color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('applyElevationOverlayColor set to false does not change surface color', (WidgetTester tester) async {
|
||||
const Color surfaceColor = Color(0xFF121212);
|
||||
await tester.pumpWidget(Theme(
|
||||
data: ThemeData(
|
||||
@@ -414,7 +415,7 @@ void main() {
|
||||
expect(model.color, equals(surfaceColor));
|
||||
});
|
||||
|
||||
testWidgets('applyElevationOverlayColor set to true applies a semi-transparent onSurface color to the surface color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('applyElevationOverlayColor set to true applies a semi-transparent onSurface color to the surface color', (WidgetTester tester) async {
|
||||
const Color surfaceColor = Color(0xFF121212);
|
||||
const Color onSurfaceColor = Colors.greenAccent;
|
||||
|
||||
@@ -456,7 +457,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('overlay will not apply to materials using a non-surface color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('overlay will not apply to materials using a non-surface color', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Theme(
|
||||
data: ThemeData(
|
||||
@@ -475,7 +476,7 @@ void main() {
|
||||
expect(model.color, equals(Colors.cyan));
|
||||
});
|
||||
|
||||
testWidgets('overlay will not apply to materials using a light theme', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('overlay will not apply to materials using a light theme', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Theme(
|
||||
data: ThemeData(
|
||||
@@ -494,7 +495,7 @@ void main() {
|
||||
expect(model.color, equals(Colors.cyan));
|
||||
});
|
||||
|
||||
testWidgets('overlay will apply to materials with a non-opaque surface color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('overlay will apply to materials with a non-opaque surface color', (WidgetTester tester) async {
|
||||
const Color surfaceColor = Color(0xFF121212);
|
||||
const Color surfaceColorWithOverlay = Color(0xC6353535);
|
||||
|
||||
@@ -517,7 +518,7 @@ void main() {
|
||||
expect(model.color, isNot(equals(surfaceColor)));
|
||||
});
|
||||
|
||||
testWidgets('Expected overlay color can be computed using colorWithOverlay', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Expected overlay color can be computed using colorWithOverlay', (WidgetTester tester) async {
|
||||
const Color surfaceColor = Color(0xFF123456);
|
||||
const Color onSurfaceColor = Color(0xFF654321);
|
||||
const double elevation = 8.0;
|
||||
@@ -550,7 +551,7 @@ void main() {
|
||||
}); // Elevation Overlay M2 group
|
||||
|
||||
group('Transparency clipping', () {
|
||||
testWidgets('No clip by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('No clip by default', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -564,7 +565,7 @@ void main() {
|
||||
expect(renderClip.clipBehavior, equals(Clip.none));
|
||||
});
|
||||
|
||||
testWidgets('clips to bounding rect by default given Clip.antiAlias', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('clips to bounding rect by default given Clip.antiAlias', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -578,7 +579,7 @@ void main() {
|
||||
expect(find.byKey(materialKey), clipsWithBoundingRect);
|
||||
});
|
||||
|
||||
testWidgets('clips to rounded rect when borderRadius provided given Clip.antiAlias', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('clips to rounded rect when borderRadius provided given Clip.antiAlias', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -598,7 +599,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('clips to shape when provided given Clip.antiAlias', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('clips to shape when provided given Clip.antiAlias', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -618,7 +619,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('supports directional clips', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('supports directional clips', (WidgetTester tester) async {
|
||||
final List<String> logs = <String>[];
|
||||
final ShapeBorder shape = TestBorder((String message) { logs.add(message); });
|
||||
Widget buildMaterial() {
|
||||
@@ -683,7 +684,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('PhysicalModels', () {
|
||||
testWidgets('canvas', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('canvas', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -699,7 +700,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('canvas with borderRadius and elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('canvas with borderRadius and elevation', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -717,7 +718,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('canvas with shape and elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('canvas with shape and elevation', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -734,7 +735,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('card', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('card', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -751,7 +752,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('card with borderRadius and elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('card with borderRadius and elevation', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -770,7 +771,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('card with shape and elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('card with shape and elevation', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -788,7 +789,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('circle', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('circle', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -805,7 +806,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('button', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('button', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -823,7 +824,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('button with elevation and borderRadius', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('button with elevation and borderRadius', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -843,7 +844,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('button with elevation and shape', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('button with elevation and shape', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -864,7 +865,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Border painting', () {
|
||||
testWidgets('border is painted on physical layers', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('border is painted on physical layers', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -885,7 +886,7 @@ void main() {
|
||||
expect(box, paints..circle());
|
||||
});
|
||||
|
||||
testWidgets('border is painted for transparent material', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('border is painted for transparent material', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -905,7 +906,7 @@ void main() {
|
||||
expect(box, paints..circle());
|
||||
});
|
||||
|
||||
testWidgets('border is not painted for when border side is none', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('border is not painted for when border side is none', (WidgetTester tester) async {
|
||||
final GlobalKey materialKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
@@ -920,7 +921,7 @@ void main() {
|
||||
expect(box, isNot(paints..circle()));
|
||||
});
|
||||
|
||||
testWidgets('border is painted above child by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('border is painted above child by default', (WidgetTester tester) async {
|
||||
final Key painterKey = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -959,7 +960,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('border is painted below child when specified', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('border is painted below child when specified', (WidgetTester tester) async {
|
||||
final Key painterKey = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -1039,7 +1040,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('LookupBoundary', () {
|
||||
testWidgets('hides Material from Material.maybeOf', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hides Material from Material.maybeOf', (WidgetTester tester) async {
|
||||
MaterialInkController? material;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -1058,7 +1059,7 @@ void main() {
|
||||
expect(material, isNull);
|
||||
});
|
||||
|
||||
testWidgets('hides Material from Material.of', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hides Material from Material.of', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
child: LookupBoundary(
|
||||
@@ -1090,7 +1091,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('hides Material from debugCheckHasMaterial', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hides Material from debugCheckHasMaterial', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
child: LookupBoundary(
|
||||
|
||||
@@ -14,10 +14,11 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Navigation bar updates destinations when tapped', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Navigation bar updates destinations when tapped', (WidgetTester tester) async {
|
||||
int mutatedIndex = -1;
|
||||
final Widget widget = _buildWidget(
|
||||
NavigationBar(
|
||||
@@ -49,7 +50,7 @@ void main() {
|
||||
expect(mutatedIndex, 0);
|
||||
});
|
||||
|
||||
testWidgets('NavigationBar can update background color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('NavigationBar can update background color', (WidgetTester tester) async {
|
||||
const Color color = Colors.yellow;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -74,7 +75,7 @@ void main() {
|
||||
expect(_getMaterial(tester).color, equals(color));
|
||||
});
|
||||
|
||||
testWidgets('NavigationBar can update elevation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('NavigationBar can update elevation', (WidgetTester tester) async {
|
||||
const double elevation = 42.0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -99,7 +100,7 @@ void main() {
|
||||
expect(_getMaterial(tester).elevation, equals(elevation));
|
||||
});
|
||||
|
||||
testWidgets('NavigationBar adds bottom padding to height', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('NavigationBar adds bottom padding to height', (WidgetTester tester) async {
|
||||
const double bottomPadding = 40.0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -148,7 +149,7 @@ void main() {
|
||||
expect(tester.getSize(find.byType(NavigationBar)).height, expectedHeight);
|
||||
});
|
||||
|
||||
testWidgets('NavigationBar respects the notch/system navigation bar in landscape mode', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('NavigationBar respects the notch/system navigation bar in landscape mode', (WidgetTester tester) async {
|
||||
const double safeAreaPadding = 40.0;
|
||||
Widget navigationBar() {
|
||||
return NavigationBar(
|
||||
@@ -246,7 +247,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - NavigationBar uses proper defaults when no parameters are given', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - NavigationBar uses proper defaults when no parameters are given', (WidgetTester tester) async {
|
||||
// M2 settings that were hand coded.
|
||||
await tester.pumpWidget(
|
||||
_buildWidget(
|
||||
@@ -275,7 +276,7 @@ void main() {
|
||||
expect(_getIndicatorDecoration(tester)?.shape, RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)));
|
||||
});
|
||||
|
||||
testWidgets('Material3 - NavigationBar uses proper defaults when no parameters are given', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - NavigationBar uses proper defaults when no parameters are given', (WidgetTester tester) async {
|
||||
// M3 settings from the token database.
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
await tester.pumpWidget(
|
||||
@@ -305,7 +306,7 @@ void main() {
|
||||
expect(_getIndicatorDecoration(tester)?.shape, const StadiumBorder());
|
||||
});
|
||||
|
||||
testWidgets('Material2 - NavigationBar shows tooltips with text scaling', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - NavigationBar shows tooltips with text scaling', (WidgetTester tester) async {
|
||||
const String label = 'A';
|
||||
|
||||
Widget buildApp({ required double textScaleFactor }) {
|
||||
@@ -364,7 +365,7 @@ void main() {
|
||||
expect(tester.getSize(find.text(label).last), Size(defaultTooltipSize.width * 4, defaultTooltipSize.height * 4));
|
||||
});
|
||||
|
||||
testWidgets('Material3 - NavigationBar shows tooltips with text scaling', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - NavigationBar shows tooltips with text scaling', (WidgetTester tester) async {
|
||||
const String label = 'A';
|
||||
|
||||
Widget buildApp({ required double textScaleFactor }) {
|
||||
@@ -430,7 +431,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Custom tooltips in NavigationBarDestination', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Custom tooltips in NavigationBarDestination', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -470,7 +471,7 @@ void main() {
|
||||
});
|
||||
|
||||
|
||||
testWidgets('Navigation bar semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Navigation bar semantics', (WidgetTester tester) async {
|
||||
Widget widget({int selectedIndex = 0}) {
|
||||
return _buildWidget(
|
||||
NavigationBar(
|
||||
@@ -534,7 +535,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Navigation bar semantics with some labels hidden', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Navigation bar semantics with some labels hidden', (WidgetTester tester) async {
|
||||
Widget widget({int selectedIndex = 0}) {
|
||||
return _buildWidget(
|
||||
NavigationBar(
|
||||
@@ -599,7 +600,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Navigation bar does not grow with text scale factor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Navigation bar does not grow with text scale factor', (WidgetTester tester) async {
|
||||
const int animationMilliseconds = 800;
|
||||
|
||||
Widget widget({double textScaleFactor = 1}) {
|
||||
@@ -632,7 +633,7 @@ void main() {
|
||||
expect(newHeight, equals(initialHeight));
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Navigation indicator renders ripple', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Navigation indicator renders ripple', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/116751.
|
||||
int selectedIndex = 0;
|
||||
|
||||
@@ -833,7 +834,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Navigation indicator ripple golden test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Navigation indicator ripple golden test', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/117420.
|
||||
|
||||
Widget buildWidget({ NavigationDestinationLabelBehavior? labelBehavior }) {
|
||||
@@ -890,7 +891,7 @@ void main() {
|
||||
await expectLater(find.byType(NavigationBar), matchesGoldenFile('indicator_onlyShowSelected_unselected_m3.png'));
|
||||
});
|
||||
|
||||
testWidgets('Navigation indicator scale transform', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Navigation indicator scale transform', (WidgetTester tester) async {
|
||||
int selectedIndex = 0;
|
||||
|
||||
Widget buildNavigationBar() {
|
||||
@@ -941,7 +942,7 @@ void main() {
|
||||
expect(transform.getColumn(0)[0], 1.0);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Navigation destination updates indicator color and shape', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Navigation destination updates indicator color and shape', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
const Color color = Color(0xff0000ff);
|
||||
const ShapeBorder shape = RoundedRectangleBorder();
|
||||
@@ -987,7 +988,7 @@ void main() {
|
||||
// support is deprecated and the APIs are removed, these tests
|
||||
// can be deleted.
|
||||
|
||||
testWidgets('Material2 - Navigation destination updates indicator color and shape', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Navigation destination updates indicator color and shape', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||
const Color color = Color(0xff0000ff);
|
||||
const ShapeBorder shape = RoundedRectangleBorder();
|
||||
@@ -1031,7 +1032,7 @@ void main() {
|
||||
expect(_getIndicatorDecoration(tester)?.shape, shape);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Navigation indicator renders ripple', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Navigation indicator renders ripple', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/116751.
|
||||
int selectedIndex = 0;
|
||||
|
||||
@@ -1232,7 +1233,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Navigation indicator ripple golden test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Navigation indicator ripple golden test', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/117420.
|
||||
|
||||
Widget buildWidget({ NavigationDestinationLabelBehavior? labelBehavior }) {
|
||||
@@ -1289,7 +1290,7 @@ void main() {
|
||||
await expectLater(find.byType(NavigationBar), matchesGoldenFile('indicator_onlyShowSelected_unselected_m2.png'));
|
||||
});
|
||||
|
||||
testWidgets('Destination icon does not rebuild when tapped', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Destination icon does not rebuild when tapped', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/122811.
|
||||
|
||||
Widget buildNavigationBar() {
|
||||
|
||||
@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
|
||||
void main() {
|
||||
// Pumps and ensures that the BottomSheet animates non-linearly.
|
||||
Future<void> checkNonLinearAnimation(WidgetTester tester) async {
|
||||
@@ -95,7 +97,7 @@ void main() {
|
||||
await tester.pumpWidget(buildFrame(const Text('I love Flutter!')));
|
||||
});
|
||||
|
||||
testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
int buildCount = 0;
|
||||
|
||||
@@ -122,7 +124,7 @@ void main() {
|
||||
expect(buildCount, equals(2));
|
||||
});
|
||||
|
||||
testWidgets('Verify that a persistent BottomSheet cannot be dismissed', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a persistent BottomSheet cannot be dismissed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
body: const Center(child: Text('body')),
|
||||
@@ -153,7 +155,7 @@ void main() {
|
||||
expect(find.text('Two'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Verify that a scrollable BottomSheet can be dismissed', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a scrollable BottomSheet can be dismissed', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -185,7 +187,7 @@ void main() {
|
||||
expect(find.text('Two'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Verify DraggableScrollableSheet.shouldCloseOnMinExtent == false prevents dismissal', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify DraggableScrollableSheet.shouldCloseOnMinExtent == false prevents dismissal', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -223,7 +225,7 @@ void main() {
|
||||
expect(find.text('Two'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Verify that a BottomSheet animates non-linearly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a BottomSheet animates non-linearly', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -297,7 +299,7 @@ void main() {
|
||||
expect(find.text('Two'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Verify that a persistent BottomSheet can fling up and hide the fab', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a persistent BottomSheet can fling up and hide the fab', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -408,7 +410,7 @@ void main() {
|
||||
expect(find.text('Item 22'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Verify that a scrollable BottomSheet hides the fab when scrolled up', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that a scrollable BottomSheet hides the fab when scrolled up', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
@@ -462,7 +464,7 @@ void main() {
|
||||
expect(find.byType(FloatingActionButton).hitTestable(), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('showBottomSheet()', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showBottomSheet()', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -486,7 +488,7 @@ void main() {
|
||||
expect(buildCount, equals(1));
|
||||
});
|
||||
|
||||
testWidgets('Scaffold removes top MediaQuery padding', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Scaffold removes top MediaQuery padding', (WidgetTester tester) async {
|
||||
late BuildContext scaffoldContext;
|
||||
late BuildContext bottomSheetContext;
|
||||
|
||||
@@ -588,7 +590,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/71435
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Scaffold.bottomSheet should be updated without creating a new RO'
|
||||
' when the new widget has the same key and type.',
|
||||
(WidgetTester tester) async {
|
||||
@@ -612,7 +614,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Verify that visual properties are passed through', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that visual properties are passed through', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
const Color color = Colors.pink;
|
||||
const double elevation = 9.0;
|
||||
@@ -647,7 +649,7 @@ void main() {
|
||||
expect(bottomSheet.clipBehavior, clipBehavior);
|
||||
});
|
||||
|
||||
testWidgets('PersistentBottomSheetController.close dismisses the bottom sheet', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PersistentBottomSheetController.close dismisses the bottom sheet', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
|
||||
@@ -17,13 +17,14 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter/src/gestures/constants.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
void main() {
|
||||
final ThemeData theme = ThemeData();
|
||||
|
||||
testWidgets('Radio control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio control test', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
@@ -84,7 +85,7 @@ void main() {
|
||||
expect(log, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('Radio can be toggled when toggleable is set', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio can be toggled when toggleable is set', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
final List<int?> log = <int?>[];
|
||||
|
||||
@@ -148,7 +149,7 @@ void main() {
|
||||
expect(log, equals(<int>[1]));
|
||||
});
|
||||
|
||||
testWidgets('Radio size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||
final Key key1 = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
Theme(
|
||||
@@ -194,7 +195,7 @@ void main() {
|
||||
expect(tester.getSize(find.byKey(key2)), const Size(40.0, 40.0));
|
||||
});
|
||||
|
||||
testWidgets('Radio selected semantics - platform adaptive', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio selected semantics - platform adaptive', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(Theme(
|
||||
@@ -229,7 +230,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
}, variant: TargetPlatformVariant.all());
|
||||
|
||||
testWidgets('Radio semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(Theme(
|
||||
@@ -360,7 +361,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('has semantic events', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has semantic events', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final Key key = UniqueKey();
|
||||
dynamic semanticEvent;
|
||||
@@ -398,7 +399,7 @@ void main() {
|
||||
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio ink ripple is displayed correctly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio ink ripple is displayed correctly', (WidgetTester tester) async {
|
||||
final Key painterKey = UniqueKey();
|
||||
const Key radioKey = Key('radio');
|
||||
|
||||
@@ -432,7 +433,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio ink ripple is displayed correctly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio ink ripple is displayed correctly', (WidgetTester tester) async {
|
||||
final Key painterKey = UniqueKey();
|
||||
const Key radioKey = Key('radio');
|
||||
|
||||
@@ -466,7 +467,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Radio with splash radius set', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio with splash radius set', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
const double splashRadius = 30;
|
||||
Widget buildApp() {
|
||||
@@ -503,7 +504,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio is focusable and has correct focus color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio is focusable and has correct focus color', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int? groupValue = 0;
|
||||
@@ -586,7 +587,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio is focusable and has correct focus color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio is focusable and has correct focus color', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int? groupValue = 0;
|
||||
@@ -664,7 +665,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int? groupValue = 0;
|
||||
const Key radioKey = Key('radio');
|
||||
@@ -747,7 +748,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio can be hovered and has correct hover color', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int? groupValue = 0;
|
||||
const Key radioKey = Key('radio');
|
||||
@@ -831,7 +832,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async {
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
int? groupValue = 1;
|
||||
const Key radioKey0 = Key('radio0');
|
||||
@@ -910,7 +911,7 @@ void main() {
|
||||
expect(groupValue, equals(2));
|
||||
});
|
||||
|
||||
testWidgets('Radio responds to density changes.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio responds to density changes.', (WidgetTester tester) async {
|
||||
const Key key = Key('test');
|
||||
Future<void> buildTest(VisualDensity visualDensity) async {
|
||||
return tester.pumpWidget(
|
||||
@@ -949,7 +950,7 @@ void main() {
|
||||
expect(box.size, equals(const Size(60, 36)));
|
||||
});
|
||||
|
||||
testWidgets('Radio changes mouse cursor when hovered', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio changes mouse cursor when hovered', (WidgetTester tester) async {
|
||||
const Key key = ValueKey<int>(1);
|
||||
// Test Radio() constructor
|
||||
await tester.pumpWidget(
|
||||
@@ -1032,7 +1033,7 @@ void main() {
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
|
||||
});
|
||||
|
||||
testWidgets('Radio button fill color resolves in enabled/disabled states', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio button fill color resolves in enabled/disabled states', (WidgetTester tester) async {
|
||||
const Color activeEnabledFillColor = Color(0xFF000001);
|
||||
const Color activeDisabledFillColor = Color(0xFF000002);
|
||||
const Color inactiveEnabledFillColor = Color(0xFF000003);
|
||||
@@ -1143,7 +1144,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
const Color hoveredFillColor = Color(0xFF000001);
|
||||
@@ -1226,7 +1227,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio fill color resolves in hovered/focused states', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
const Color hoveredFillColor = Color(0xFF000001);
|
||||
@@ -1449,7 +1450,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
|
||||
Widget buildRadio(bool show) {
|
||||
@@ -1475,7 +1476,7 @@ void main() {
|
||||
await gesture.up();
|
||||
});
|
||||
|
||||
testWidgets('disabled radio shows tooltip', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('disabled radio shows tooltip', (WidgetTester tester) async {
|
||||
const String longPressTooltip = 'long press tooltip';
|
||||
const String tapTooltip = 'tap tooltip';
|
||||
await tester.pumpWidget(
|
||||
@@ -1531,7 +1532,7 @@ void main() {
|
||||
expect(find.text(tapTooltip), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio button default colors', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio button default colors', (WidgetTester tester) async {
|
||||
Widget buildRadio({bool enabled = true, bool selected = true}) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
@@ -1577,7 +1578,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio button default colors', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio button default colors', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
Widget buildRadio({bool enabled = true, bool selected = true}) {
|
||||
return MaterialApp(
|
||||
@@ -1798,7 +1799,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Radio.adaptive shows the correct platform widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Radio.adaptive shows the correct platform widget', (WidgetTester tester) async {
|
||||
Widget buildApp(TargetPlatform platform) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
@@ -1829,7 +1830,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Material2 - Radio default overlayColor and fillColor resolves pressed state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - Radio default overlayColor and fillColor resolves pressed state', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final ThemeData theme = ThemeData(useMaterial3: false);
|
||||
@@ -1894,7 +1895,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - Radio default overlayColor and fillColor resolves pressed state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - Radio default overlayColor and fillColor resolves pressed state', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode(debugLabel: 'Radio');
|
||||
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
|
||||
@@ -9,6 +9,8 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
|
||||
bool refreshCalled = false;
|
||||
|
||||
Future<void> refresh() {
|
||||
@@ -22,7 +24,7 @@ Future<void> holdRefresh() {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('RefreshIndicator', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
await tester.pumpWidget(
|
||||
@@ -56,7 +58,7 @@ void main() {
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Refresh Indicator - nested', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Refresh Indicator - nested', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -97,7 +99,7 @@ void main() {
|
||||
expect(refreshCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - reverse', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - reverse', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -125,7 +127,7 @@ void main() {
|
||||
expect(refreshCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - top - position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - top - position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -151,7 +153,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(RefreshProgressIndicator)).dy, lessThan(300.0));
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - reverse - position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - reverse - position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -178,7 +180,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(RefreshProgressIndicator)).dy, lessThan(300.0));
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - no movement', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - no movement', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -206,7 +208,7 @@ void main() {
|
||||
expect(refreshCalled, false);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - not enough', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - not enough', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -233,7 +235,7 @@ void main() {
|
||||
expect(refreshCalled, false);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - just enough', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - just enough', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -260,7 +262,7 @@ void main() {
|
||||
expect(refreshCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - show - slow', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - show - slow', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -303,7 +305,7 @@ void main() {
|
||||
expect(refreshCalled, false);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - show - fast', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - show - fast', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -347,7 +349,7 @@ void main() {
|
||||
expect(completed, true);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - show - fast - twice', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - show - fast - twice', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -385,7 +387,7 @@ void main() {
|
||||
expect(completed2, true);
|
||||
});
|
||||
|
||||
testWidgets('Refresh starts while scroll view moves back to 0.0 after overscroll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Refresh starts while scroll view moves back to 0.0 after overscroll', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
double lastScrollOffset;
|
||||
final ScrollController controller = ScrollController();
|
||||
@@ -424,7 +426,7 @@ void main() {
|
||||
expect(refreshCalled, isTrue);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('RefreshIndicator does not force child to relayout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator does not force child to relayout', (WidgetTester tester) async {
|
||||
int layoutCount = 0;
|
||||
|
||||
Widget layoutCallback(BuildContext context, BoxConstraints constraints) {
|
||||
@@ -459,7 +461,7 @@ void main() {
|
||||
expect(layoutCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator responds to strokeWidth', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator responds to strokeWidth', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: RefreshIndicator(
|
||||
@@ -507,7 +509,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator responds to edgeOffset', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator responds to edgeOffset', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: RefreshIndicator(
|
||||
@@ -555,7 +557,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator appears at edgeOffset', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator appears at edgeOffset', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: RefreshIndicator(
|
||||
edgeOffset: kToolbarHeight,
|
||||
@@ -584,7 +586,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Top RefreshIndicator(anywhere mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Top RefreshIndicator(anywhere mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
@@ -619,7 +621,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byType(RefreshProgressIndicator)).dy, lessThan(300.0));
|
||||
});
|
||||
|
||||
testWidgets('Reverse RefreshIndicator(anywhere mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Reverse RefreshIndicator(anywhere mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
@@ -656,7 +658,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/71936
|
||||
testWidgets('RefreshIndicator(anywhere mode) should not be shown when overscroll occurs due to inertia', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator(anywhere mode) should not be shown when overscroll occurs due to inertia', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
@@ -692,7 +694,7 @@ void main() {
|
||||
expect(find.byType(RefreshProgressIndicator), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Top RefreshIndicator(onEdge mode) should not be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Top RefreshIndicator(onEdge mode) should not be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
@@ -726,7 +728,7 @@ void main() {
|
||||
expect(find.byType(RefreshProgressIndicator), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Reverse RefreshIndicator(onEdge mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Reverse RefreshIndicator(onEdge mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController();
|
||||
await tester.pumpWidget(
|
||||
@@ -761,7 +763,7 @@ void main() {
|
||||
expect(find.byType(RefreshProgressIndicator), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('ScrollController.jumpTo should not trigger the refresh indicator', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ScrollController.jumpTo should not trigger the refresh indicator', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
final ScrollController scrollController = ScrollController(initialScrollOffset: 500.0);
|
||||
await tester.pumpWidget(
|
||||
@@ -793,7 +795,7 @@ void main() {
|
||||
expect(refreshCalled, false);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator.adaptive', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator.adaptive', (WidgetTester tester) async {
|
||||
Widget buildFrame(TargetPlatform platform) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
@@ -835,7 +837,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator color defaults to ColorScheme.primary', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator color defaults to ColorScheme.primary', (WidgetTester tester) async {
|
||||
const Color primaryColor = Color(0xff4caf50);
|
||||
final ThemeData theme = ThemeData.from(colorScheme: const ColorScheme.light().copyWith(primary: primaryColor));
|
||||
await tester.pumpWidget(
|
||||
@@ -871,7 +873,7 @@ void main() {
|
||||
expect(tester.widget<RefreshProgressIndicator>(find.byType(RefreshProgressIndicator)).valueColor!.value, primaryColor);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator.color can be updated at runtime', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator.color can be updated at runtime', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
Color refreshIndicatorColor = Colors.green;
|
||||
const Color red = Colors.red;
|
||||
@@ -918,7 +920,7 @@ void main() {
|
||||
expect(tester.widget<RefreshProgressIndicator>(find.byType(RefreshProgressIndicator)).valueColor!.value, red.withOpacity(1.0));
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator - reverse - BouncingScrollPhysics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator - reverse - BouncingScrollPhysics', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -952,7 +954,7 @@ void main() {
|
||||
expect(refreshCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator disallows indicator - glow', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator disallows indicator - glow', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
bool glowAccepted = true;
|
||||
ScrollNotification? lastNotification;
|
||||
@@ -1004,7 +1006,7 @@ void main() {
|
||||
expect(glowAccepted, false);
|
||||
});
|
||||
|
||||
testWidgets('RefreshIndicator disallows indicator - stretch', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RefreshIndicator disallows indicator - stretch', (WidgetTester tester) async {
|
||||
refreshCalled = false;
|
||||
bool stretchAccepted = true;
|
||||
ScrollNotification? lastNotification;
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../foundation/leak_tracking.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
@@ -22,7 +23,7 @@ Widget boilerplate({required Widget child}) {
|
||||
|
||||
void main() {
|
||||
|
||||
testWidgets('SegmentedButton is built with Material of type MaterialType.transparency', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedButton is built with Material of type MaterialType.transparency', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -330,7 +331,7 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
|
||||
|
||||
});
|
||||
|
||||
testWidgets('SegmentedButtons have correct semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedButtons have correct semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -409,7 +410,7 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
|
||||
});
|
||||
|
||||
|
||||
testWidgets('Multi-select SegmentedButtons have correct semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Multi-select SegmentedButtons have correct semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -486,7 +487,7 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('SegmentedButton default overlayColor and foregroundColor resolve pressed state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedButton default overlayColor and foregroundColor resolve pressed state', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -534,7 +535,7 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
|
||||
expect(material.textStyle?.color, theme.colorScheme.onSurface);
|
||||
});
|
||||
|
||||
testWidgets('SegmentedButton has no tooltips by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedButton has no tooltips by default', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -558,7 +559,7 @@ testWidgets('SegmentedButton shows checkboxes for selected segments', (WidgetTes
|
||||
expect(find.byType(Tooltip), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('SegmentedButton has correct tooltips', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedButton has correct tooltips', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
Reference in New Issue
Block a user