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 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class MyNotification extends Notification { }
void main() {
testWidgets('Notification basics - toString', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Notification basics - toString', (WidgetTester tester) async {
expect(MyNotification(), hasOneLineDescription);
});
testWidgets('Notification basics - dispatch', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Notification basics - dispatch', (WidgetTester tester) async {
final List<dynamic> log = <dynamic>[];
final GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>(
......@@ -36,7 +37,7 @@ void main() {
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 GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>(
......@@ -60,7 +61,7 @@ void main() {
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 GlobalKey key = GlobalKey();
await tester.pumpWidget(NotificationListener<MyNotification>(
......@@ -77,7 +78,7 @@ void main() {
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());
final ScrollMetricsNotification n1 = ScrollMetricsNotification(
metrics: FixedScrollMetrics(
......
......@@ -8,6 +8,7 @@ import 'dart:ui' as ui show Image;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart';
import '../painting/fake_codec.dart';
......@@ -17,7 +18,7 @@ Future<void> main() async {
final FakeCodec fakeCodec = await FakeCodec.fromData(Uint8List.fromList(kAnimatedGif));
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();
await tester.pumpWidget(
MaterialApp(
......
......@@ -5,9 +5,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
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;
await tester.pumpWidget(
const ColoredBox(
......@@ -46,7 +47,7 @@ void main() {
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;
await tester.pumpWidget(
......
......@@ -7,14 +7,17 @@
@Tags(<String>['reduced-test-set'])
library;
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'semantics_tester.dart';
void main() {
testWidgets('Opacity', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Opacity', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
// Opacity 1.0: Semantics and painting
......@@ -151,7 +154,7 @@ void main() {
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(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -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(
RepaintBoundary(child: Opacity(opacity: 0.5, child: Container())),
);
......@@ -192,10 +195,11 @@ void main() {
// The following line will send the layer to engine and cause crash if an
// empty opacity layer is sent.
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
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;
final GlobalKey key = GlobalKey();
await tester.pumpWidget(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('OverflowBar documented defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OverflowBar documented defaults', (WidgetTester tester) async {
const OverflowBar bar = OverflowBar();
expect(bar.spacing, 0);
expect(bar.alignment, null);
......@@ -17,7 +18,7 @@ void main() {
expect(bar.children, const <Widget>[]);
});
testWidgets('Empty OverflowBar', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Empty OverflowBar', (WidgetTester tester) async {
const Size size = Size(16, 24);
await tester.pumpWidget(
......@@ -46,7 +47,7 @@ void main() {
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 child2Key = UniqueKey();
final Key child3Key = UniqueKey();
......@@ -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));
});
testWidgets('OverflowBar vertical layout', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OverflowBar vertical layout', (WidgetTester tester) async {
final Key child1Key = UniqueKey();
final Key child2Key = UniqueKey();
final Key child3Key = UniqueKey();
......@@ -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));
});
testWidgets('OverflowBar intrinsic width', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OverflowBar intrinsic width', (WidgetTester tester) async {
Widget buildFrame({ required double width }) {
return Directionality(
textDirection: TextDirection.ltr,
......@@ -205,7 +206,7 @@ void main() {
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 }) {
return Directionality(
textDirection: TextDirection.ltr,
......@@ -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 key1 = UniqueKey();
final Key key2 = UniqueKey();
......@@ -273,7 +274,7 @@ void main() {
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 key1 = UniqueKey();
final Key key2 = UniqueKey();
......
......@@ -5,9 +5,10 @@
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('OverflowBox control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('OverflowBox control test', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Align(
alignment: Alignment.bottomRight,
......@@ -30,7 +31,7 @@ void main() {
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();
const OverflowBox(
minWidth: 1.0,
......@@ -50,7 +51,7 @@ void main() {
]);
});
testWidgets('SizedOverflowBox alignment', (WidgetTester tester) async {
testWidgetsWithLeakTracking('SizedOverflowBox alignment', (WidgetTester tester) async {
final GlobalKey inner = GlobalKey();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl,
......@@ -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();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.rtl,
......
......@@ -6,6 +6,7 @@ import 'dart:math' as math;
import 'package:flutter/widgets.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());
......@@ -19,7 +20,7 @@ Future<void> slowDrag(WidgetTester tester, Offset start, Offset offset) async {
}
void main() {
testWidgets('Overscroll indicator color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Overscroll indicator color', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -55,7 +56,7 @@ void main() {
expect(painter, doesNotOverscroll);
});
testWidgets('Nested scrollable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Nested scrollable', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -86,7 +87,7 @@ void main() {
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(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -128,7 +129,7 @@ void main() {
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(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -166,7 +167,7 @@ void main() {
});
group("Flipping direction of scrollable doesn't change overscroll behavior", () {
testWidgets('down', (WidgetTester tester) async {
testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -186,7 +187,7 @@ void main() {
expect(painter, doesNotOverscroll);
});
testWidgets('up', (WidgetTester tester) async {
testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -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(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -231,7 +232,7 @@ void main() {
expect(painter, doesNotOverscroll);
});
testWidgets('Overscroll ignored from alternate axis', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Overscroll ignored from alternate axis', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -260,7 +261,7 @@ void main() {
expect(painter, doesNotOverscroll);
});
testWidgets('Overscroll horizontally', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Overscroll horizontally', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -291,7 +292,7 @@ void main() {
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(
textDirection: TextDirection.ltr,
child: PageView(
......@@ -313,7 +314,7 @@ void main() {
await tester.pumpAndSettle();
});
testWidgets('Changing settings', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Changing settings', (WidgetTester tester) async {
RenderObject painter;
await tester.pumpWidget(
......@@ -359,7 +360,7 @@ void main() {
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();
await tester.pumpWidget(
Directionality(
......@@ -398,7 +399,7 @@ void main() {
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();
await tester.pumpWidget(
Directionality(
......@@ -445,7 +446,7 @@ void main() {
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
await tester.pumpWidget(
Directionality(
......@@ -508,7 +509,7 @@ void main() {
});
group('[OverscrollIndicatorNotification.paintOffset] test', () {
testWidgets('Leading', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Leading', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -538,7 +539,7 @@ void main() {
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(
Directionality(
textDirection: TextDirection.ltr,
......
......@@ -4,6 +4,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestTransition extends AnimatedWidget {
const TestTransition({
......@@ -57,7 +58,7 @@ void main() {
const Duration kTwoTenthsOfTheTransitionDuration = Duration(milliseconds: 30);
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();
......@@ -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(
MaterialApp(
onGenerateRoute: (RouteSettings settings) {
......
......@@ -9,6 +9,7 @@ library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestPage extends StatelessWidget {
const TestPage({ super.key, this.useMaterial3 });
......@@ -93,7 +94,7 @@ class ModalPage extends StatelessWidget {
}
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.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle();
......@@ -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.tap(find.byType(FloatingActionButton));
await tester.pumpAndSettle();
......
......@@ -4,9 +4,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('PageStorage read and write', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageStorage read and write', (WidgetTester tester) async {
const Key builderKey = PageStorageKey<String>('builderKey');
late StateSetter setState;
int storedValue = 0;
......@@ -37,7 +38,7 @@ void main() {
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;
int storedValue = 0;
......
......@@ -4,6 +4,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestOverlayRoute extends OverlayRoute<void> {
TestOverlayRoute({ super.settings });
......@@ -47,7 +48,7 @@ class PersistentBottomSheetTestState extends State<PersistentBottomSheetTest> {
}
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 containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
......@@ -129,7 +130,7 @@ void main() {
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 containerKey2 = GlobalKey();
const String kHeroTag = 'hero';
......@@ -198,7 +199,7 @@ void main() {
expect(settingsOffset.dy, 100.0);
}, 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 containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
......@@ -242,7 +243,7 @@ void main() {
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
// 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 containerKey2 = GlobalKey();
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
......@@ -295,7 +296,7 @@ void main() {
expect(sheet.setStateCalled, isFalse);
}, 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>{
'/': (_) => const Center(child: Text('home')),
'/next': (_) => const Center(child: Text('next')),
......
......@@ -4,6 +4,7 @@
import 'package:flutter/widgets.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);
const List<int> defaultPages = <int>[0, 1, 2, 3, 4, 5];
......@@ -59,7 +60,7 @@ Future<void> pageRight(WidgetTester tester) {
}
void main() {
testWidgets('PageView default control', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageView default control', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
......@@ -70,7 +71,7 @@ void main() {
);
});
testWidgets('PageView control test (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageView control test (LTR)', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(textDirection: TextDirection.ltr));
expect(currentPage, isNull);
......@@ -98,7 +99,7 @@ void main() {
expect(currentPage, equals(0));
});
testWidgets('PageView with reverse (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageView with reverse (LTR)', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.ltr));
await pageRight(tester);
......@@ -132,7 +133,7 @@ void main() {
expect(find.text('5'), findsNothing);
});
testWidgets('PageView control test (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageView control test (RTL)', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(textDirection: TextDirection.rtl));
await pageRight(tester);
......@@ -166,7 +167,7 @@ void main() {
expect(find.text('5'), findsNothing);
});
testWidgets('PageView with reverse (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageView with reverse (RTL)', (WidgetTester tester) async {
currentPage = null;
await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.rtl));
expect(currentPage, isNull);
......
......@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'test_widgets.dart';
......@@ -49,7 +50,7 @@ void checkTree(WidgetTester tester, List<TestParentData> expectedParentData) {
final TestParentData kNonPositioned = TestParentData();
void main() {
testWidgets('ParentDataWidget control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ParentDataWidget control test', (WidgetTester tester) async {
await tester.pumpWidget(
const Stack(
textDirection: TextDirection.ltr,
......@@ -249,7 +250,7 @@ void main() {
checkTree(tester, <TestParentData>[]);
});
testWidgets('ParentDataWidget conflicting data', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ParentDataWidget conflicting data', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -331,7 +332,7 @@ void main() {
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();
await tester.pumpWidget(
......@@ -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(
textDirection: TextDirection.ltr,
child: Row(
......@@ -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(
OneAncestorWidget(
child: Container(),
......
......@@ -5,14 +5,15 @@
import 'package:flutter/src/rendering/performance_overlay.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
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(PerformanceOverlay.allEnabled());
});
testWidgets('update widget field checkerboardRasterCacheImages',
testWidgetsWithLeakTracking('update widget field checkerboardRasterCacheImages',
(WidgetTester tester) async {
await tester.pumpWidget(const PerformanceOverlay());
await tester.pumpWidget(
......@@ -25,7 +26,7 @@ void main() {
true);
});
testWidgets('update widget field checkerboardOffscreenLayers',
testWidgetsWithLeakTracking('update widget field checkerboardOffscreenLayers',
(WidgetTester tester) async {
await tester.pumpWidget(const PerformanceOverlay());
await tester.pumpWidget(
......
......@@ -10,9 +10,10 @@ library;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('PhysicalModel updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PhysicalModel updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: PhysicalModel(color: Colors.red)),
);
......@@ -28,7 +29,7 @@ void main() {
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(
const MaterialApp(home: PhysicalShape(color: Colors.red, clipper: ShapeBorderClipper(shape: CircleBorder()))),
);
......@@ -44,7 +45,7 @@ void main() {
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');
await tester.pumpWidget(
Theme(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Placeholder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Placeholder', (WidgetTester tester) async {
await tester.pumpWidget(const Placeholder());
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).size, const Size(800.0, 600.0));
await tester.pumpWidget(const Center(child: Placeholder()));
......@@ -19,21 +20,21 @@ void main() {
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());
expect(tester.renderObject(find.byType(Placeholder)), paints..path(color: const Color(0xFF455A64)));
await tester.pumpWidget(const Placeholder(color: 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());
expect(tester.renderObject(find.byType(Placeholder)), paints..path(strokeWidth: 2.0));
await tester.pumpWidget(const Placeholder(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());
expect(find.text('Label'), findsNothing);
await tester.pumpWidget(const MaterialApp(home: Placeholder(child: Text('Label'))));
......
......@@ -8,6 +8,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/foundation/diagnostics.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
......@@ -47,7 +48,7 @@ void main() {
group('PlatformMenuBar', () {
group('basic menu structure is transmitted to platform', () {
testWidgets('using onSelected', (WidgetTester tester) async {
testWidgetsWithLeakTracking('using onSelected', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -78,7 +79,7 @@ void main() {
equals(expectedStructure),
);
});
testWidgets('using onSelectedIntent', (WidgetTester tester) async {
testWidgetsWithLeakTracking('using onSelectedIntent', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
......@@ -126,7 +127,7 @@ void main() {
);
expect(tester.takeException(), isA<AssertionError>());
});
testWidgets('diagnostics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('diagnostics', (WidgetTester tester) async {
const PlatformMenuItem item = PlatformMenuItem(
label: 'label2',
shortcut: SingleActivator(LogicalKeyboardKey.keyA),
......@@ -158,7 +159,7 @@ void main() {
});
});
group('MenuBarItem', () {
testWidgets('diagnostics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('diagnostics', (WidgetTester tester) async {
const PlatformMenuItem childItem = PlatformMenuItem(
label: 'label',
);
......@@ -182,7 +183,7 @@ void main() {
});
group('ShortcutSerialization', () {
testWidgets('character constructor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('character constructor', (WidgetTester tester) async {
final ShortcutSerialization serialization = ShortcutSerialization.character('?');
expect(serialization.toChannelRepresentation(), equals(<String, Object?>{
'shortcutCharacter': '?',
......@@ -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);
expect(serialization.toChannelRepresentation(), equals(<String, Object?>{
'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