Unverified Commit 2396a417 authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

Cover more test/widgets tests with leak tracking #6 (#134884)

parent 658710b6
...@@ -4,15 +4,16 @@ ...@@ -4,15 +4,16 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class MyNotification extends Notification { } class MyNotification extends Notification { }
void main() { void main() {
testWidgets('Notification basics - toString', (WidgetTester tester) async { testWidgetsWithLeakTracking('Notification basics - toString', (WidgetTester tester) async {
expect(MyNotification(), hasOneLineDescription); expect(MyNotification(), hasOneLineDescription);
}); });
testWidgets('Notification basics - dispatch', (WidgetTester tester) async { testWidgetsWithLeakTracking('Notification basics - dispatch', (WidgetTester tester) async {
final List<dynamic> log = <dynamic>[]; final List<dynamic> log = <dynamic>[];
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>( await tester.pumpWidget(NotificationListener<MyNotification>(
...@@ -36,7 +37,7 @@ void main() { ...@@ -36,7 +37,7 @@ void main() {
expect(log, <dynamic>['b', notification, 'a', notification]); expect(log, <dynamic>['b', notification, 'a', notification]);
}); });
testWidgets('Notification basics - cancel', (WidgetTester tester) async { testWidgetsWithLeakTracking('Notification basics - cancel', (WidgetTester tester) async {
final List<dynamic> log = <dynamic>[]; final List<dynamic> log = <dynamic>[];
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>( await tester.pumpWidget(NotificationListener<MyNotification>(
...@@ -60,7 +61,7 @@ void main() { ...@@ -60,7 +61,7 @@ void main() {
expect(log, <dynamic>['b', notification]); expect(log, <dynamic>['b', notification]);
}); });
testWidgets('Notification basics - listener null return value', (WidgetTester tester) async { testWidgetsWithLeakTracking('Notification basics - listener null return value', (WidgetTester tester) async {
final List<Type> log = <Type>[]; final List<Type> log = <Type>[];
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>( await tester.pumpWidget(NotificationListener<MyNotification>(
...@@ -77,7 +78,7 @@ void main() { ...@@ -77,7 +78,7 @@ void main() {
expect(log, <Type>[MyNotification]); expect(log, <Type>[MyNotification]);
}); });
testWidgets('Notification basics - listener null return value', (WidgetTester tester) async { testWidgetsWithLeakTracking('Notification basics - listener null return value', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
final ScrollMetricsNotification n1 = ScrollMetricsNotification( final ScrollMetricsNotification n1 = ScrollMetricsNotification(
metrics: FixedScrollMetrics( metrics: FixedScrollMetrics(
......
...@@ -8,6 +8,7 @@ import 'dart:ui' as ui show Image; ...@@ -8,6 +8,7 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
import '../painting/fake_codec.dart'; import '../painting/fake_codec.dart';
...@@ -17,7 +18,7 @@ Future<void> main() async { ...@@ -17,7 +18,7 @@ Future<void> main() async {
final FakeCodec fakeCodec = await FakeCodec.fromData(Uint8List.fromList(kAnimatedGif)); final FakeCodec fakeCodec = await FakeCodec.fromData(Uint8List.fromList(kAnimatedGif));
final FakeImageProvider fakeImageProvider = FakeImageProvider(fakeCodec); final FakeImageProvider fakeImageProvider = FakeImageProvider(fakeCodec);
testWidgets('Obscured image does not animate', (WidgetTester tester) async { testWidgetsWithLeakTracking('Obscured image does not animate', (WidgetTester tester) async {
final GlobalKey imageKey = GlobalKey(); final GlobalKey imageKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('RenderOpacity avoids repainting and does not drop layer at fully opaque', (WidgetTester tester) async { testWidgetsWithLeakTracking('RenderOpacity avoids repainting and does not drop layer at fully opaque', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
await tester.pumpWidget( await tester.pumpWidget(
const ColoredBox( const ColoredBox(
...@@ -46,7 +47,7 @@ void main() { ...@@ -46,7 +47,7 @@ void main() {
expect(RenderTestObject.paintCount, 1); expect(RenderTestObject.paintCount, 1);
}); });
testWidgets('RenderOpacity allows opacity layer to be dropped at 0 opacity', (WidgetTester tester) async { testWidgetsWithLeakTracking('RenderOpacity allows opacity layer to be dropped at 0 opacity', (WidgetTester tester) async {
RenderTestObject.paintCount = 0; RenderTestObject.paintCount = 0;
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -7,14 +7,17 @@ ...@@ -7,14 +7,17 @@
@Tags(<String>['reduced-test-set']) @Tags(<String>['reduced-test-set'])
library; library;
import 'dart:ui' as ui;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart'; import 'semantics_tester.dart';
void main() { void main() {
testWidgets('Opacity', (WidgetTester tester) async { testWidgetsWithLeakTracking('Opacity', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
// Opacity 1.0: Semantics and painting // Opacity 1.0: Semantics and painting
...@@ -151,7 +154,7 @@ void main() { ...@@ -151,7 +154,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('offset is correctly handled in Opacity', (WidgetTester tester) async { testWidgetsWithLeakTracking('offset is correctly handled in Opacity', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -184,7 +187,7 @@ void main() { ...@@ -184,7 +187,7 @@ void main() {
); );
}); });
testWidgets('empty opacity does not crash', (WidgetTester tester) async { testWidgetsWithLeakTracking('empty opacity does not crash', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
RepaintBoundary(child: Opacity(opacity: 0.5, child: Container())), RepaintBoundary(child: Opacity(opacity: 0.5, child: Container())),
); );
...@@ -192,10 +195,11 @@ void main() { ...@@ -192,10 +195,11 @@ void main() {
// The following line will send the layer to engine and cause crash if an // The following line will send the layer to engine and cause crash if an
// empty opacity layer is sent. // empty opacity layer is sent.
final OffsetLayer offsetLayer = element.renderObject!.debugLayer! as OffsetLayer; final OffsetLayer offsetLayer = element.renderObject!.debugLayer! as OffsetLayer;
await offsetLayer.toImage(const Rect.fromLTRB(0.0, 0.0, 1.0, 1.0)); final ui.Image image = await offsetLayer.toImage(const Rect.fromLTRB(0.0, 0.0, 1.0, 1.0));
image.dispose();
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/49857 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/49857
testWidgets('Child shows up in the right spot when opacity is disabled', (WidgetTester tester) async { testWidgetsWithLeakTracking('Child shows up in the right spot when opacity is disabled', (WidgetTester tester) async {
debugDisableOpacityLayers = true; debugDisableOpacityLayers = true;
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('OverflowBar documented defaults', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar documented defaults', (WidgetTester tester) async {
const OverflowBar bar = OverflowBar(); const OverflowBar bar = OverflowBar();
expect(bar.spacing, 0); expect(bar.spacing, 0);
expect(bar.alignment, null); expect(bar.alignment, null);
...@@ -17,7 +18,7 @@ void main() { ...@@ -17,7 +18,7 @@ void main() {
expect(bar.children, const <Widget>[]); expect(bar.children, const <Widget>[]);
}); });
testWidgets('Empty OverflowBar', (WidgetTester tester) async { testWidgetsWithLeakTracking('Empty OverflowBar', (WidgetTester tester) async {
const Size size = Size(16, 24); const Size size = Size(16, 24);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -46,7 +47,7 @@ void main() { ...@@ -46,7 +47,7 @@ void main() {
expect(tester.getSize(find.byType(OverflowBar)), Size.zero); expect(tester.getSize(find.byType(OverflowBar)), Size.zero);
}); });
testWidgets('OverflowBar horizontal layout', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar horizontal layout', (WidgetTester tester) async {
final Key child1Key = UniqueKey(); final Key child1Key = UniqueKey();
final Key child2Key = UniqueKey(); final Key child2Key = UniqueKey();
final Key child3Key = UniqueKey(); final Key child3Key = UniqueKey();
...@@ -93,7 +94,7 @@ void main() { ...@@ -93,7 +94,7 @@ void main() {
expect(tester.getRect(find.byKey(child1Key)), const Rect.fromLTRB(10.0 + 96 + 10.0, 8, 10.0 + 10.0 + 144, 56)); expect(tester.getRect(find.byKey(child1Key)), const Rect.fromLTRB(10.0 + 96 + 10.0, 8, 10.0 + 10.0 + 144, 56));
}); });
testWidgets('OverflowBar vertical layout', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar vertical layout', (WidgetTester tester) async {
final Key child1Key = UniqueKey(); final Key child1Key = UniqueKey();
final Key child2Key = UniqueKey(); final Key child2Key = UniqueKey();
final Key child3Key = UniqueKey(); final Key child3Key = UniqueKey();
...@@ -174,7 +175,7 @@ void main() { ...@@ -174,7 +175,7 @@ void main() {
expect(tester.getRect(find.byKey(child3Key)), const Rect.fromLTRB(100.0/2.0 - 32/2, 112, 100.0/2.0 + 32/2, 144)); expect(tester.getRect(find.byKey(child3Key)), const Rect.fromLTRB(100.0/2.0 - 32/2, 112, 100.0/2.0 + 32/2, 144));
}); });
testWidgets('OverflowBar intrinsic width', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar intrinsic width', (WidgetTester tester) async {
Widget buildFrame({ required double width }) { Widget buildFrame({ required double width }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -205,7 +206,7 @@ void main() { ...@@ -205,7 +206,7 @@ void main() {
expect(tester.getSize(find.byType(OverflowBar)).width, 150); expect(tester.getSize(find.byType(OverflowBar)).width, 150);
}); });
testWidgets('OverflowBar intrinsic height', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar intrinsic height', (WidgetTester tester) async {
Widget buildFrame({ required double maxWidth }) { Widget buildFrame({ required double maxWidth }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -237,7 +238,7 @@ void main() { ...@@ -237,7 +238,7 @@ void main() {
}); });
testWidgets('OverflowBar is wider that its intrinsic width', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar is wider that its intrinsic width', (WidgetTester tester) async {
final Key key0 = UniqueKey(); final Key key0 = UniqueKey();
final Key key1 = UniqueKey(); final Key key1 = UniqueKey();
final Key key2 = UniqueKey(); final Key key2 = UniqueKey();
...@@ -273,7 +274,7 @@ void main() { ...@@ -273,7 +274,7 @@ void main() {
expect(tester.getTopLeft(find.byKey(key2)).dx, 600); expect(tester.getTopLeft(find.byKey(key2)).dx, 600);
}); });
testWidgets('OverflowBar with alignment should match Row with mainAxisAlignment', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBar with alignment should match Row with mainAxisAlignment', (WidgetTester tester) async {
final Key key0 = UniqueKey(); final Key key0 = UniqueKey();
final Key key1 = UniqueKey(); final Key key1 = UniqueKey();
final Key key2 = UniqueKey(); final Key key2 = UniqueKey();
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('OverflowBox control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBox control test', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey(); final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Align( await tester.pumpWidget(Align(
alignment: Alignment.bottomRight, alignment: Alignment.bottomRight,
...@@ -30,7 +31,7 @@ void main() { ...@@ -30,7 +31,7 @@ void main() {
expect(box.size, equals(const Size(100.0, 50.0))); expect(box.size, equals(const Size(100.0, 50.0)));
}); });
testWidgets('OverflowBox implements debugFillProperties', (WidgetTester tester) async { testWidgetsWithLeakTracking('OverflowBox implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const OverflowBox( const OverflowBox(
minWidth: 1.0, minWidth: 1.0,
...@@ -50,7 +51,7 @@ void main() { ...@@ -50,7 +51,7 @@ void main() {
]); ]);
}); });
testWidgets('SizedOverflowBox alignment', (WidgetTester tester) async { testWidgetsWithLeakTracking('SizedOverflowBox alignment', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey(); final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
...@@ -73,7 +74,7 @@ void main() { ...@@ -73,7 +74,7 @@ void main() {
); );
}); });
testWidgets('SizedOverflowBox alignment (direction-sensitive)', (WidgetTester tester) async { testWidgetsWithLeakTracking('SizedOverflowBox alignment (direction-sensitive)', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey(); final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
......
...@@ -6,6 +6,7 @@ import 'dart:math' as math; ...@@ -6,6 +6,7 @@ import 'dart:math' as math;
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
final Matcher doesNotOverscroll = isNot(paints..circle()); final Matcher doesNotOverscroll = isNot(paints..circle());
...@@ -19,7 +20,7 @@ Future<void> slowDrag(WidgetTester tester, Offset start, Offset offset) async { ...@@ -19,7 +20,7 @@ Future<void> slowDrag(WidgetTester tester, Offset start, Offset offset) async {
} }
void main() { void main() {
testWidgets('Overscroll indicator color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll indicator color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -55,7 +56,7 @@ void main() { ...@@ -55,7 +56,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('Nested scrollable', (WidgetTester tester) async { testWidgetsWithLeakTracking('Nested scrollable', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -86,7 +87,7 @@ void main() { ...@@ -86,7 +87,7 @@ void main() {
expect(innerPainter, paints..circle()); expect(innerPainter, paints..circle());
}); });
testWidgets('Overscroll indicator changes side when you drag on the other side', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll indicator changes side when you drag on the other side', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -128,7 +129,7 @@ void main() { ...@@ -128,7 +129,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('Overscroll indicator changes side when you shift sides', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll indicator changes side when you shift sides', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -166,7 +167,7 @@ void main() { ...@@ -166,7 +167,7 @@ void main() {
}); });
group("Flipping direction of scrollable doesn't change overscroll behavior", () { group("Flipping direction of scrollable doesn't change overscroll behavior", () {
testWidgets('down', (WidgetTester tester) async { testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -186,7 +187,7 @@ void main() { ...@@ -186,7 +187,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('up', (WidgetTester tester) async { testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -208,7 +209,7 @@ void main() { ...@@ -208,7 +209,7 @@ void main() {
}); });
}); });
testWidgets('Overscroll in both directions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll in both directions', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -231,7 +232,7 @@ void main() { ...@@ -231,7 +232,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('Overscroll ignored from alternate axis', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll ignored from alternate axis', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -260,7 +261,7 @@ void main() { ...@@ -260,7 +261,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('Overscroll horizontally', (WidgetTester tester) async { testWidgetsWithLeakTracking('Overscroll horizontally', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -291,7 +292,7 @@ void main() { ...@@ -291,7 +292,7 @@ void main() {
expect(painter, doesNotOverscroll); expect(painter, doesNotOverscroll);
}); });
testWidgets('Nested overscrolls do not throw exceptions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Nested overscrolls do not throw exceptions', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: PageView( child: PageView(
...@@ -313,7 +314,7 @@ void main() { ...@@ -313,7 +314,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets('Changing settings', (WidgetTester tester) async { testWidgetsWithLeakTracking('Changing settings', (WidgetTester tester) async {
RenderObject painter; RenderObject painter;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -359,7 +360,7 @@ void main() { ...@@ -359,7 +360,7 @@ void main() {
expect(painter, isNot(paints..circle()..circle())); expect(painter, isNot(paints..circle()..circle()));
}); });
testWidgets('CustomScrollView overscroll indicator works if there is sliver before center', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView overscroll indicator works if there is sliver before center', (WidgetTester tester) async {
final Key centerKey = UniqueKey(); final Key centerKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -398,7 +399,7 @@ void main() { ...@@ -398,7 +399,7 @@ void main() {
expect(painter, paints..save()..translate(y: 0.0)..scale()..circle()); expect(painter, paints..save()..translate(y: 0.0)..scale()..circle());
}); });
testWidgets('CustomScrollView overscroll indicator works well with [CustomScrollView.center] and [OverscrollIndicatorNotification.paintOffset]', (WidgetTester tester) async { testWidgetsWithLeakTracking('CustomScrollView overscroll indicator works well with [CustomScrollView.center] and [OverscrollIndicatorNotification.paintOffset]', (WidgetTester tester) async {
final Key centerKey = UniqueKey(); final Key centerKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -445,7 +446,7 @@ void main() { ...@@ -445,7 +446,7 @@ void main() {
expect(painter, paints..save()..translate(y: 50.0)..scale()..circle()); expect(painter, paints..save()..translate(y: 50.0)..scale()..circle());
}); });
testWidgets('The OverscrollIndicator should not overflow the scrollable view edge', (WidgetTester tester) async { testWidgetsWithLeakTracking('The OverscrollIndicator should not overflow the scrollable view edge', (WidgetTester tester) async {
// Regressing test for https://github.com/flutter/flutter/issues/64149 // Regressing test for https://github.com/flutter/flutter/issues/64149
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -508,7 +509,7 @@ void main() { ...@@ -508,7 +509,7 @@ void main() {
}); });
group('[OverscrollIndicatorNotification.paintOffset] test', () { group('[OverscrollIndicatorNotification.paintOffset] test', () {
testWidgets('Leading', (WidgetTester tester) async { testWidgetsWithLeakTracking('Leading', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -538,7 +539,7 @@ void main() { ...@@ -538,7 +539,7 @@ void main() {
expect(painter, paints..save()..translate(y: 50.0 - 30.0)..scale()..circle()); expect(painter, paints..save()..translate(y: 50.0 - 30.0)..scale()..circle());
}); });
testWidgets('Trailing', (WidgetTester tester) async { testWidgetsWithLeakTracking('Trailing', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestTransition extends AnimatedWidget { class TestTransition extends AnimatedWidget {
const TestTransition({ const TestTransition({
...@@ -57,7 +58,7 @@ void main() { ...@@ -57,7 +58,7 @@ void main() {
const Duration kTwoTenthsOfTheTransitionDuration = Duration(milliseconds: 30); const Duration kTwoTenthsOfTheTransitionDuration = Duration(milliseconds: 30);
const Duration kFourTenthsOfTheTransitionDuration = Duration(milliseconds: 60); const Duration kFourTenthsOfTheTransitionDuration = Duration(milliseconds: 60);
testWidgets('Check onstage/offstage handling around transitions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Check onstage/offstage handling around transitions', (WidgetTester tester) async {
final GlobalKey insideKey = GlobalKey(); final GlobalKey insideKey = GlobalKey();
...@@ -196,7 +197,7 @@ void main() { ...@@ -196,7 +197,7 @@ void main() {
}); });
testWidgets('Check onstage/offstage handling of barriers around transitions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Check onstage/offstage handling of barriers around transitions', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
......
...@@ -9,6 +9,7 @@ library; ...@@ -9,6 +9,7 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestPage extends StatelessWidget { class TestPage extends StatelessWidget {
const TestPage({ super.key, this.useMaterial3 }); const TestPage({ super.key, this.useMaterial3 });
...@@ -93,7 +94,7 @@ class ModalPage extends StatelessWidget { ...@@ -93,7 +94,7 @@ class ModalPage extends StatelessWidget {
} }
void main() { void main() {
testWidgets('Material2 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async {
await tester.pumpWidget(const TestPage(useMaterial3: false)); await tester.pumpWidget(const TestPage(useMaterial3: false));
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -103,7 +104,7 @@ void main() { ...@@ -103,7 +104,7 @@ void main() {
); );
}); });
testWidgets('Material3 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async {
await tester.pumpWidget(const TestPage(useMaterial3: true)); await tester.pumpWidget(const TestPage(useMaterial3: true));
await tester.tap(find.byType(FloatingActionButton)); await tester.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('PageStorage read and write', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageStorage read and write', (WidgetTester tester) async {
const Key builderKey = PageStorageKey<String>('builderKey'); const Key builderKey = PageStorageKey<String>('builderKey');
late StateSetter setState; late StateSetter setState;
int storedValue = 0; int storedValue = 0;
...@@ -37,7 +38,7 @@ void main() { ...@@ -37,7 +38,7 @@ void main() {
expect(PageStorage.of(builderElement).readState(builderElement), equals(storedValue)); expect(PageStorage.of(builderElement).readState(builderElement), equals(storedValue));
}); });
testWidgets('PageStorage read and write by identifier', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageStorage read and write by identifier', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
int storedValue = 0; int storedValue = 0;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestOverlayRoute extends OverlayRoute<void> { class TestOverlayRoute extends OverlayRoute<void> {
TestOverlayRoute({ super.settings }); TestOverlayRoute({ super.settings });
...@@ -47,7 +48,7 @@ class PersistentBottomSheetTestState extends State<PersistentBottomSheetTest> { ...@@ -47,7 +48,7 @@ class PersistentBottomSheetTestState extends State<PersistentBottomSheetTest> {
} }
void main() { void main() {
testWidgets('Check onstage/offstage handling around transitions', (WidgetTester tester) async { testWidgetsWithLeakTracking('Check onstage/offstage handling around transitions', (WidgetTester tester) async {
final GlobalKey containerKey1 = GlobalKey(); final GlobalKey containerKey1 = GlobalKey();
final GlobalKey containerKey2 = GlobalKey(); final GlobalKey containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
...@@ -129,7 +130,7 @@ void main() { ...@@ -129,7 +130,7 @@ void main() {
expect(Navigator.canPop(containerKey1.currentContext!), isFalse); expect(Navigator.canPop(containerKey1.currentContext!), isFalse);
}); });
testWidgets('Check back gesture disables Heroes', (WidgetTester tester) async { testWidgetsWithLeakTracking('Check back gesture disables Heroes', (WidgetTester tester) async {
final GlobalKey containerKey1 = GlobalKey(); final GlobalKey containerKey1 = GlobalKey();
final GlobalKey containerKey2 = GlobalKey(); final GlobalKey containerKey2 = GlobalKey();
const String kHeroTag = 'hero'; const String kHeroTag = 'hero';
...@@ -198,7 +199,7 @@ void main() { ...@@ -198,7 +199,7 @@ void main() {
expect(settingsOffset.dy, 100.0); expect(settingsOffset.dy, 100.0);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets("Check back gesture doesn't start during transitions", (WidgetTester tester) async { testWidgetsWithLeakTracking("Check back gesture doesn't start during transitions", (WidgetTester tester) async {
final GlobalKey containerKey1 = GlobalKey(); final GlobalKey containerKey1 = GlobalKey();
final GlobalKey containerKey2 = GlobalKey(); final GlobalKey containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
...@@ -242,7 +243,7 @@ void main() { ...@@ -242,7 +243,7 @@ void main() {
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
// Tests bug https://github.com/flutter/flutter/issues/6451 // Tests bug https://github.com/flutter/flutter/issues/6451
testWidgets('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async { testWidgetsWithLeakTracking('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async {
final GlobalKey containerKey1 = GlobalKey(); final GlobalKey containerKey1 = GlobalKey();
final GlobalKey containerKey2 = GlobalKey(); final GlobalKey containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
...@@ -295,7 +296,7 @@ void main() { ...@@ -295,7 +296,7 @@ void main() {
expect(sheet.setStateCalled, isFalse); expect(sheet.setStateCalled, isFalse);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Test completed future', (WidgetTester tester) async { testWidgetsWithLeakTracking('Test completed future', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) => const Center(child: Text('home')), '/': (_) => const Center(child: Text('home')),
'/next': (_) => const Center(child: Text('next')), '/next': (_) => const Center(child: Text('next')),
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
Size pageSize = const Size(600.0, 300.0); Size pageSize = const Size(600.0, 300.0);
const List<int> defaultPages = <int>[0, 1, 2, 3, 4, 5]; const List<int> defaultPages = <int>[0, 1, 2, 3, 4, 5];
...@@ -59,7 +60,7 @@ Future<void> pageRight(WidgetTester tester) { ...@@ -59,7 +60,7 @@ Future<void> pageRight(WidgetTester tester) {
} }
void main() { void main() {
testWidgets('PageView default control', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageView default control', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -70,7 +71,7 @@ void main() { ...@@ -70,7 +71,7 @@ void main() {
); );
}); });
testWidgets('PageView control test (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageView control test (LTR)', (WidgetTester tester) async {
currentPage = null; currentPage = null;
await tester.pumpWidget(buildFrame(textDirection: TextDirection.ltr)); await tester.pumpWidget(buildFrame(textDirection: TextDirection.ltr));
expect(currentPage, isNull); expect(currentPage, isNull);
...@@ -98,7 +99,7 @@ void main() { ...@@ -98,7 +99,7 @@ void main() {
expect(currentPage, equals(0)); expect(currentPage, equals(0));
}); });
testWidgets('PageView with reverse (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageView with reverse (LTR)', (WidgetTester tester) async {
currentPage = null; currentPage = null;
await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.ltr)); await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.ltr));
await pageRight(tester); await pageRight(tester);
...@@ -132,7 +133,7 @@ void main() { ...@@ -132,7 +133,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
}); });
testWidgets('PageView control test (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageView control test (RTL)', (WidgetTester tester) async {
currentPage = null; currentPage = null;
await tester.pumpWidget(buildFrame(textDirection: TextDirection.rtl)); await tester.pumpWidget(buildFrame(textDirection: TextDirection.rtl));
await pageRight(tester); await pageRight(tester);
...@@ -166,7 +167,7 @@ void main() { ...@@ -166,7 +167,7 @@ void main() {
expect(find.text('5'), findsNothing); expect(find.text('5'), findsNothing);
}); });
testWidgets('PageView with reverse (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('PageView with reverse (RTL)', (WidgetTester tester) async {
currentPage = null; currentPage = null;
await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.rtl)); await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.rtl));
expect(currentPage, isNull); expect(currentPage, isNull);
......
...@@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; ...@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'test_widgets.dart'; import 'test_widgets.dart';
...@@ -49,7 +50,7 @@ void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) { ...@@ -49,7 +50,7 @@ void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) {
final TestParentData kNonPositioned = TestParentData(); final TestParentData kNonPositioned = TestParentData();
void main() { void main() {
testWidgets('ParentDataWidget control test', (WidgetTester tester) async { testWidgetsWithLeakTracking('ParentDataWidget control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Stack( const Stack(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -249,7 +250,7 @@ void main() { ...@@ -249,7 +250,7 @@ void main() {
checkTree(tester, <TestParentData>[]); checkTree(tester, <TestParentData>[]);
}); });
testWidgets('ParentDataWidget conflicting data', (WidgetTester tester) async { testWidgetsWithLeakTracking('ParentDataWidget conflicting data', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -331,7 +332,7 @@ void main() { ...@@ -331,7 +332,7 @@ void main() {
checkTree(tester, <TestParentData>[]); checkTree(tester, <TestParentData>[]);
}); });
testWidgets('ParentDataWidget interacts with global keys', (WidgetTester tester) async { testWidgetsWithLeakTracking('ParentDataWidget interacts with global keys', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -389,7 +390,7 @@ void main() { ...@@ -389,7 +390,7 @@ void main() {
]); ]);
}); });
testWidgets('Parent data invalid ancestor', (WidgetTester tester) async { testWidgetsWithLeakTracking('Parent data invalid ancestor', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Row( child: Row(
...@@ -424,7 +425,7 @@ void main() { ...@@ -424,7 +425,7 @@ void main() {
); );
}); });
testWidgets('ParentDataWidget can be used with different ancestor RenderObjectWidgets', (WidgetTester tester) async { testWidgetsWithLeakTracking('ParentDataWidget can be used with different ancestor RenderObjectWidgets', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
OneAncestorWidget( OneAncestorWidget(
child: Container(), child: Container(),
......
...@@ -5,14 +5,15 @@ ...@@ -5,14 +5,15 @@
import 'package:flutter/src/rendering/performance_overlay.dart'; import 'package:flutter/src/rendering/performance_overlay.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('Performance overlay smoke test', (WidgetTester tester) async { testWidgetsWithLeakTracking('Performance overlay smoke test', (WidgetTester tester) async {
await tester.pumpWidget(const PerformanceOverlay()); await tester.pumpWidget(const PerformanceOverlay());
await tester.pumpWidget(PerformanceOverlay.allEnabled()); await tester.pumpWidget(PerformanceOverlay.allEnabled());
}); });
testWidgets('update widget field checkerboardRasterCacheImages', testWidgetsWithLeakTracking('update widget field checkerboardRasterCacheImages',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(const PerformanceOverlay()); await tester.pumpWidget(const PerformanceOverlay());
await tester.pumpWidget( await tester.pumpWidget(
...@@ -25,7 +26,7 @@ void main() { ...@@ -25,7 +26,7 @@ void main() {
true); true);
}); });
testWidgets('update widget field checkerboardOffscreenLayers', testWidgetsWithLeakTracking('update widget field checkerboardOffscreenLayers',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(const PerformanceOverlay()); await tester.pumpWidget(const PerformanceOverlay());
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -10,9 +10,10 @@ library; ...@@ -10,9 +10,10 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('PhysicalModel updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalModel updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp(home: PhysicalModel(color: Colors.red)), const MaterialApp(home: PhysicalModel(color: Colors.red)),
); );
...@@ -28,7 +29,7 @@ void main() { ...@@ -28,7 +29,7 @@ void main() {
expect(renderPhysicalModel.clipBehavior, equals(Clip.antiAlias)); expect(renderPhysicalModel.clipBehavior, equals(Clip.antiAlias));
}); });
testWidgets('PhysicalShape updates clipBehavior in updateRenderObject', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalShape updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp(home: PhysicalShape(color: Colors.red, clipper: ShapeBorderClipper(shape: CircleBorder()))), const MaterialApp(home: PhysicalShape(color: Colors.red, clipper: ShapeBorderClipper(shape: CircleBorder()))),
); );
...@@ -44,7 +45,7 @@ void main() { ...@@ -44,7 +45,7 @@ void main() {
expect(renderPhysicalShape.clipBehavior, equals(Clip.antiAlias)); expect(renderPhysicalShape.clipBehavior, equals(Clip.antiAlias));
}); });
testWidgets('PhysicalModel - clips when overflows and elevation is 0', (WidgetTester tester) async { testWidgetsWithLeakTracking('PhysicalModel - clips when overflows and elevation is 0', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
await tester.pumpWidget( await tester.pumpWidget(
Theme( Theme(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('Placeholder', (WidgetTester tester) async { testWidgetsWithLeakTracking('Placeholder', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 600.0)); expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 600.0));
await tester.pumpWidget(const Center(child: Placeholder())); await tester.pumpWidget(const Center(child: Placeholder()));
...@@ -19,21 +20,21 @@ void main() { ...@@ -19,21 +20,21 @@ void main() {
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(200.0, 300.0)); expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(200.0, 300.0));
}); });
testWidgets('Placeholder color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Placeholder color', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
expect(tester.renderObject(find.byType(Placeholder)), paints..path(color: const Color(0xFF455A64))); expect(tester.renderObject(find.byType(Placeholder)), paints..path(color: const Color(0xFF455A64)));
await tester.pumpWidget(const Placeholder(color: Color(0xFF00FF00))); await tester.pumpWidget(const Placeholder(color: Color(0xFF00FF00)));
expect(tester.renderObject(find.byType(Placeholder)), paints..path(color: const Color(0xFF00FF00))); expect(tester.renderObject(find.byType(Placeholder)), paints..path(color: const Color(0xFF00FF00)));
}); });
testWidgets('Placeholder stroke width', (WidgetTester tester) async { testWidgetsWithLeakTracking('Placeholder stroke width', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
expect(tester.renderObject(find.byType(Placeholder)), paints..path(strokeWidth: 2.0)); expect(tester.renderObject(find.byType(Placeholder)), paints..path(strokeWidth: 2.0));
await tester.pumpWidget(const Placeholder(strokeWidth: 10.0)); await tester.pumpWidget(const Placeholder(strokeWidth: 10.0));
expect(tester.renderObject(find.byType(Placeholder)), paints..path(strokeWidth: 10.0)); expect(tester.renderObject(find.byType(Placeholder)), paints..path(strokeWidth: 10.0));
}); });
testWidgets('Placeholder child widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Placeholder child widget', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder()); await tester.pumpWidget(const Placeholder());
expect(find.text('Label'), findsNothing); expect(find.text('Label'), findsNothing);
await tester.pumpWidget(const MaterialApp(home: Placeholder(child: Text('Label')))); await tester.pumpWidget(const MaterialApp(home: Placeholder(child: Text('Label'))));
......
...@@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/src/foundation/diagnostics.dart'; import 'package:flutter/src/foundation/diagnostics.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
...@@ -47,7 +48,7 @@ void main() { ...@@ -47,7 +48,7 @@ void main() {
group('PlatformMenuBar', () { group('PlatformMenuBar', () {
group('basic menu structure is transmitted to platform', () { group('basic menu structure is transmitted to platform', () {
testWidgets('using onSelected', (WidgetTester tester) async { testWidgetsWithLeakTracking('using onSelected', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
...@@ -78,7 +79,7 @@ void main() { ...@@ -78,7 +79,7 @@ void main() {
equals(expectedStructure), equals(expectedStructure),
); );
}); });
testWidgets('using onSelectedIntent', (WidgetTester tester) async { testWidgetsWithLeakTracking('using onSelectedIntent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
...@@ -126,7 +127,7 @@ void main() { ...@@ -126,7 +127,7 @@ void main() {
); );
expect(tester.takeException(), isA<AssertionError>()); expect(tester.takeException(), isA<AssertionError>());
}); });
testWidgets('diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('diagnostics', (WidgetTester tester) async {
const PlatformMenuItem item = PlatformMenuItem( const PlatformMenuItem item = PlatformMenuItem(
label: 'label2', label: 'label2',
shortcut: SingleActivator(LogicalKeyboardKey.keyA), shortcut: SingleActivator(LogicalKeyboardKey.keyA),
...@@ -158,7 +159,7 @@ void main() { ...@@ -158,7 +159,7 @@ void main() {
}); });
}); });
group('MenuBarItem', () { group('MenuBarItem', () {
testWidgets('diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('diagnostics', (WidgetTester tester) async {
const PlatformMenuItem childItem = PlatformMenuItem( const PlatformMenuItem childItem = PlatformMenuItem(
label: 'label', label: 'label',
); );
...@@ -182,7 +183,7 @@ void main() { ...@@ -182,7 +183,7 @@ void main() {
}); });
group('ShortcutSerialization', () { group('ShortcutSerialization', () {
testWidgets('character constructor', (WidgetTester tester) async { testWidgetsWithLeakTracking('character constructor', (WidgetTester tester) async {
final ShortcutSerialization serialization = ShortcutSerialization.character('?'); final ShortcutSerialization serialization = ShortcutSerialization.character('?');
expect(serialization.toChannelRepresentation(), equals(<String, Object?>{ expect(serialization.toChannelRepresentation(), equals(<String, Object?>{
'shortcutCharacter': '?', 'shortcutCharacter': '?',
...@@ -195,7 +196,7 @@ void main() { ...@@ -195,7 +196,7 @@ void main() {
})); }));
}); });
testWidgets('modifier constructor', (WidgetTester tester) async { testWidgetsWithLeakTracking('modifier constructor', (WidgetTester tester) async {
final ShortcutSerialization serialization = ShortcutSerialization.modifier(LogicalKeyboardKey.home); final ShortcutSerialization serialization = ShortcutSerialization.modifier(LogicalKeyboardKey.home);
expect(serialization.toChannelRepresentation(), equals(<String, Object?>{ expect(serialization.toChannelRepresentation(), equals(<String, Object?>{
'shortcutTrigger': LogicalKeyboardKey.home.keyId, 'shortcutTrigger': LogicalKeyboardKey.home.keyId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment