forked from firka/flutter
Cover some test/widgets tests with leak tracking (#133803)
This commit is contained in:
committed by
GitHub
parent
0d198c7ba6
commit
aca91df6b7
@@ -4,11 +4,12 @@
|
||||
|
||||
import 'package:flutter/material.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('AbsorbPointers do not block siblings', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AbsorbPointers do not block siblings', (WidgetTester tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(
|
||||
Column(
|
||||
@@ -29,7 +30,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('AbsorbPointer semantics', () {
|
||||
testWidgets('does not change semantics when not absorbing', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('does not change semantics when not absorbing', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -56,7 +57,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('drops semantics when its ignoreSemantics is true', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drops semantics when its ignoreSemantics is true', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
@@ -75,7 +76,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('ignores user interactions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ignores user interactions', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
@@ -8,10 +8,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
void main() {
|
||||
group(ActionDispatcher, () {
|
||||
testWidgets('ActionDispatcher invokes actions when asked.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ActionDispatcher invokes actions when asked.', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Container());
|
||||
bool invoked = false;
|
||||
const ActionDispatcher dispatcher = ActionDispatcher();
|
||||
@@ -48,7 +49,7 @@ void main() {
|
||||
|
||||
setUp(clear);
|
||||
|
||||
testWidgets('Actions widget can invoke actions with default dispatcher', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions widget can invoke actions with default dispatcher', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
|
||||
@@ -75,7 +76,7 @@ void main() {
|
||||
expect(invoked, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Actions widget can invoke actions with default dispatcher and maybeInvoke', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions widget can invoke actions with default dispatcher and maybeInvoke', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
|
||||
@@ -102,7 +103,7 @@ void main() {
|
||||
expect(invoked, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('maybeInvoke returns null when no action is found', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('maybeInvoke returns null when no action is found', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
|
||||
@@ -129,7 +130,7 @@ void main() {
|
||||
expect(invoked, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('invoke throws when no action is found', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('invoke throws when no action is found', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
|
||||
@@ -156,7 +157,7 @@ void main() {
|
||||
expect(invoked, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Actions widget can invoke actions with custom dispatcher', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions widget can invoke actions with custom dispatcher', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
const TestIntent intent = TestIntent();
|
||||
@@ -187,7 +188,7 @@ void main() {
|
||||
expect(invokedIntent, equals(intent));
|
||||
});
|
||||
|
||||
testWidgets('Actions can invoke actions in ancestor dispatcher', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions can invoke actions in ancestor dispatcher', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
const TestIntent intent = TestIntent();
|
||||
@@ -224,7 +225,7 @@ void main() {
|
||||
expect(invokedDispatcher.runtimeType, equals(TestDispatcher1));
|
||||
});
|
||||
|
||||
testWidgets("Actions can invoke actions in ancestor dispatcher if a lower one isn't specified", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("Actions can invoke actions in ancestor dispatcher if a lower one isn't specified", (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
const TestIntent intent = TestIntent();
|
||||
@@ -260,7 +261,7 @@ void main() {
|
||||
expect(invokedDispatcher.runtimeType, equals(TestDispatcher1));
|
||||
});
|
||||
|
||||
testWidgets('Actions widget can be found with of', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions widget can be found with of', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
final ActionDispatcher testDispatcher = TestDispatcher1(postInvoke: collect);
|
||||
|
||||
@@ -277,7 +278,7 @@ void main() {
|
||||
expect(dispatcher, equals(testDispatcher));
|
||||
});
|
||||
|
||||
testWidgets('Action can be found with find', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Action can be found with find', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
final ActionDispatcher testDispatcher = TestDispatcher1(postInvoke: collect);
|
||||
bool invoked = false;
|
||||
@@ -324,7 +325,7 @@ void main() {
|
||||
expect(Actions.maybeFind<DoNothingIntent>(containerKey.currentContext!), isNull);
|
||||
});
|
||||
|
||||
testWidgets('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
||||
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
@@ -339,6 +340,8 @@ void main() {
|
||||
bool hovering = false;
|
||||
bool focusing = false;
|
||||
|
||||
addTearDown(focusNode.dispose);
|
||||
|
||||
Future<void> buildTest(bool enabled) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
@@ -394,7 +397,7 @@ void main() {
|
||||
expect(focusing, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('FocusableActionDetector changes mouse cursor when hovered', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector changes mouse cursor when hovered', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors.forbidden,
|
||||
@@ -427,7 +430,7 @@ void main() {
|
||||
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
|
||||
});
|
||||
|
||||
testWidgets('Actions.invoke returns the value of Action.invoke', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions.invoke returns the value of Action.invoke', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
final Object sentinel = Object();
|
||||
bool invoked = false;
|
||||
@@ -458,7 +461,7 @@ void main() {
|
||||
expect(invoked, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('ContextAction can return null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ContextAction can return null', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
const TestIntent intent = TestIntent();
|
||||
final TestContextAction testAction = TestContextAction();
|
||||
@@ -485,7 +488,7 @@ void main() {
|
||||
expect(testAction.capturedContexts.single, containerKey.currentContext);
|
||||
});
|
||||
|
||||
testWidgets('Disabled actions stop propagation to an ancestor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Disabled actions stop propagation to an ancestor', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked = false;
|
||||
const TestIntent intent = TestIntent();
|
||||
@@ -534,7 +537,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Listening', () {
|
||||
testWidgets('can listen to enabled state of Actions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can listen to enabled state of Actions', (WidgetTester tester) async {
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
bool invoked1 = false;
|
||||
bool invoked2 = false;
|
||||
@@ -756,7 +759,11 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
||||
tearDown(() async {
|
||||
focusNode.dispose();
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector keeps track of focus and hover even when disabled.', (WidgetTester tester) async {
|
||||
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
|
||||
@@ -790,7 +797,7 @@ void main() {
|
||||
expect(focusing, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('FocusableActionDetector shows focus highlight appropriately when focused and disabled', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector shows focus highlight appropriately when focused and disabled', (WidgetTester tester) async {
|
||||
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
|
||||
@@ -821,7 +828,7 @@ void main() {
|
||||
expect(focusing, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('FocusableActionDetector can be used without callbacks', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector can be used without callbacks', (WidgetTester tester) async {
|
||||
FocusManager.instance.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
|
||||
final GlobalKey containerKey = GlobalKey();
|
||||
|
||||
@@ -855,11 +862,13 @@ void main() {
|
||||
expect(focusing, isFalse);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'FocusableActionDetector can prevent its descendants from being focusable',
|
||||
(WidgetTester tester) async {
|
||||
final FocusNode buttonNode = FocusNode(debugLabel: 'Test');
|
||||
|
||||
addTearDown(buttonNode.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: FocusableActionDetector(
|
||||
@@ -899,16 +908,23 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'FocusableActionDetector can prevent its descendants from being traversable',
|
||||
(WidgetTester tester) async {
|
||||
final FocusNode buttonNode1 = FocusNode(debugLabel: 'Button Node 1');
|
||||
final FocusNode buttonNode2 = FocusNode(debugLabel: 'Button Node 2');
|
||||
final FocusNode skipTraversalNode = FocusNode(skipTraversal: true);
|
||||
|
||||
addTearDown(() {
|
||||
buttonNode1.dispose();
|
||||
buttonNode2.dispose();
|
||||
skipTraversalNode.dispose();
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: FocusableActionDetector(
|
||||
focusNode: FocusNode(skipTraversal: true),
|
||||
focusNode: skipTraversalNode,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
ElevatedButton(
|
||||
@@ -939,7 +955,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: FocusableActionDetector(
|
||||
focusNode: FocusNode(skipTraversal: true),
|
||||
focusNode: skipTraversalNode,
|
||||
descendantsAreTraversable: false,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
@@ -970,7 +986,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('FocusableActionDetector can exclude Focus semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FocusableActionDetector can exclude Focus semantics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: FocusableActionDetector(
|
||||
@@ -1076,7 +1092,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Action subclasses', () {
|
||||
testWidgets('CallbackAction passes correct intent when invoked.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CallbackAction passes correct intent when invoked.', (WidgetTester tester) async {
|
||||
late Intent passedIntent;
|
||||
final TestAction action = TestAction(onInvoke: (Intent intent) {
|
||||
passedIntent = intent;
|
||||
@@ -1087,7 +1103,7 @@ void main() {
|
||||
expect(passedIntent, equals(intent));
|
||||
});
|
||||
|
||||
testWidgets('VoidCallbackAction', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('VoidCallbackAction', (WidgetTester tester) async {
|
||||
bool called = false;
|
||||
void testCallback() {
|
||||
called = true;
|
||||
@@ -1097,7 +1113,7 @@ void main() {
|
||||
action.invoke(intent);
|
||||
expect(called, isTrue);
|
||||
});
|
||||
testWidgets('Base Action class default toKeyEventResult delegates to consumesKey', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Base Action class default toKeyEventResult delegates to consumesKey', (WidgetTester tester) async {
|
||||
expect(
|
||||
DefaultToKeyEventResultAction(consumesKey: false).toKeyEventResult(const DefaultToKeyEventResultIntent(), null),
|
||||
KeyEventResult.skipRemainingHandlers,
|
||||
@@ -1110,7 +1126,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Diagnostics', () {
|
||||
testWidgets('default Intent debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('default Intent debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
|
||||
// ignore: invalid_use_of_protected_member
|
||||
@@ -1126,7 +1142,7 @@ void main() {
|
||||
expect(description, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('default Actions debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('default Actions debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
|
||||
Actions(
|
||||
@@ -1152,7 +1168,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Actions implements debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Actions implements debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
|
||||
Actions(
|
||||
@@ -1191,7 +1207,7 @@ void main() {
|
||||
invokingContext = null;
|
||||
});
|
||||
|
||||
testWidgets('Basic usage', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Basic usage', (WidgetTester tester) async {
|
||||
late BuildContext invokingContext2;
|
||||
late BuildContext invokingContext3;
|
||||
await tester.pumpWidget(
|
||||
@@ -1256,7 +1272,7 @@ void main() {
|
||||
expect(invocations, <String>['action1.invoke']);
|
||||
});
|
||||
|
||||
testWidgets('Does not break after use', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Does not break after use', (WidgetTester tester) async {
|
||||
late BuildContext invokingContext2;
|
||||
late BuildContext invokingContext3;
|
||||
await tester.pumpWidget(
|
||||
@@ -1323,7 +1339,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('Does not override if not overridable', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Does not override if not overridable', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
@@ -1366,7 +1382,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('The final override controls isEnabled', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('The final override controls isEnabled', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
@@ -1453,7 +1469,7 @@ void main() {
|
||||
expect(invocations, <String>[]);
|
||||
});
|
||||
|
||||
testWidgets('The override can choose to defer isActionEnabled to the overridable', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('The override can choose to defer isActionEnabled to the overridable', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
@@ -1543,7 +1559,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('Throws on infinite recursions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Throws on infinite recursions', (WidgetTester tester) async {
|
||||
late StateSetter setState;
|
||||
BuildContext? action2LookupContext;
|
||||
await tester.pumpWidget(
|
||||
@@ -1602,7 +1618,7 @@ void main() {
|
||||
expect(exception?.toString(), contains('debugAssertIsEnabledMutuallyRecursive'));
|
||||
});
|
||||
|
||||
testWidgets('Throws on invoking invalid override', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Throws on invoking invalid override', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context) {
|
||||
@@ -1640,7 +1656,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Make an overridable action overridable', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Make an overridable action overridable', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
@@ -1696,7 +1712,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('Overriding Actions can change the intent', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Overriding Actions can change the intent', (WidgetTester tester) async {
|
||||
final List<String> newLogChannel = <String>[];
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
@@ -1746,7 +1762,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('Override non-context overridable Actions with a ContextAction', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Override non-context overridable Actions with a ContextAction', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
@@ -1799,7 +1815,7 @@ void main() {
|
||||
expect(LogInvocationContextAction.invokeContext, invokingContext);
|
||||
});
|
||||
|
||||
testWidgets('Override a ContextAction with a regular Action', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Override a ContextAction with a regular Action', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context1) {
|
||||
|
||||
@@ -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('Align smoke test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Align smoke test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Align(
|
||||
alignment: const Alignment(0.50, 0.50),
|
||||
@@ -38,7 +39,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Align control test (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Align control test (LTR)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -62,7 +63,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
|
||||
});
|
||||
|
||||
testWidgets('Align control test (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Align control test (RTL)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.rtl,
|
||||
child: Align(
|
||||
@@ -86,7 +87,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(SizedBox)).dx, 100.0);
|
||||
});
|
||||
|
||||
testWidgets('Shrink wraps in finite space', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Shrink wraps in finite space', (WidgetTester tester) async {
|
||||
final GlobalKey alignKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
SingleChildScrollView(
|
||||
@@ -105,7 +106,7 @@ void main() {
|
||||
expect(size.height, equals(10.0));
|
||||
});
|
||||
|
||||
testWidgets('Align widthFactor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Align widthFactor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -128,7 +129,7 @@ void main() {
|
||||
expect(box.size.width, equals(50.0));
|
||||
});
|
||||
|
||||
testWidgets('Align heightFactor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Align heightFactor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
||||
@@ -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('AnimatedAlign.debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign.debugFillProperties', (WidgetTester tester) async {
|
||||
const AnimatedAlign box = AnimatedAlign(
|
||||
alignment: Alignment.topCenter,
|
||||
curve: Curves.ease,
|
||||
@@ -15,7 +16,7 @@ void main() {
|
||||
expect(box, hasOneLineDescription);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedAlign alignment visual-to-directional animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign alignment visual-to-directional animation', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -57,7 +58,7 @@ void main() {
|
||||
expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedAlign widthFactor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign widthFactor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -82,7 +83,7 @@ void main() {
|
||||
expect(box.size.width, equals(50.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedAlign heightFactor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign heightFactor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -106,7 +107,7 @@ void main() {
|
||||
expect(box.size.height, equals( 50.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedAlign null height factor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign null height factor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -130,7 +131,7 @@ void main() {
|
||||
expect(box.size, equals(const Size(100.0, 100)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedAlign null widthFactor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedAlign null widthFactor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
||||
@@ -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('AnimatedContainer.debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer.debugFillProperties', (WidgetTester tester) async {
|
||||
final AnimatedContainer container = AnimatedContainer(
|
||||
constraints: const BoxConstraints.tightFor(width: 17.0, height: 23.0),
|
||||
decoration: const BoxDecoration(color: Color(0xFF00FF00)),
|
||||
@@ -24,7 +25,7 @@ void main() {
|
||||
expect(container, hasOneLineDescription);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer control test', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
const BoxDecoration decorationA = BoxDecoration(
|
||||
@@ -102,7 +103,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer overanimate test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer overanimate test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
@@ -139,7 +140,7 @@ void main() {
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer padding visual-to-directional animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer padding visual-to-directional animation', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -181,7 +182,7 @@ void main() {
|
||||
expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer alignment visual-to-directional animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer alignment visual-to-directional animation', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -223,7 +224,7 @@ void main() {
|
||||
expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 400.0));
|
||||
});
|
||||
|
||||
testWidgets('Animation rerun', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Animation rerun', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: AnimatedContainer(
|
||||
@@ -291,7 +292,7 @@ void main() {
|
||||
expect(text.size.height, equals(100.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer sets transformAlignment', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer sets transformAlignment', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -339,7 +340,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.byKey(target)), const Offset(400.0, 300.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedContainer sets clipBehavior', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedContainer sets clipBehavior', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
AnimatedContainer(
|
||||
decoration: const BoxDecoration(
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('AnimatedCrossFade test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -61,7 +62,7 @@ void main() {
|
||||
expect(box.size.height, equals(150.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade test showSecond', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade test showSecond', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -88,7 +89,7 @@ void main() {
|
||||
expect(box.size.height, equals(200.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade alignment (VISUAL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade alignment (VISUAL)', (WidgetTester tester) async {
|
||||
final Key firstKey = UniqueKey();
|
||||
final Key secondKey = UniqueKey();
|
||||
|
||||
@@ -146,7 +147,7 @@ void main() {
|
||||
expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade alignment (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade alignment (LTR)', (WidgetTester tester) async {
|
||||
final Key firstKey = UniqueKey();
|
||||
final Key secondKey = UniqueKey();
|
||||
|
||||
@@ -204,7 +205,7 @@ void main() {
|
||||
expect(box2.localToGlobal(Offset.zero), const Offset(275.0, 175.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade alignment (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade alignment (RTL)', (WidgetTester tester) async {
|
||||
final Key firstKey = UniqueKey();
|
||||
final Key secondKey = UniqueKey();
|
||||
|
||||
@@ -274,7 +275,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('AnimatedCrossFade preserves widget state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade preserves widget state', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(crossFadeWithWatcher());
|
||||
|
||||
_TickerWatchingWidgetState findState() => tester.state(find.byType(_TickerWatchingWidget));
|
||||
@@ -287,7 +288,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade switches off TickerMode and semantics on faded out widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade switches off TickerMode and semantics on faded out widget', (WidgetTester tester) async {
|
||||
ExcludeSemantics findSemantics() {
|
||||
return tester.widget(find.descendant(
|
||||
of: find.byKey(const ValueKey<CrossFadeState>(CrossFadeState.showFirst)),
|
||||
@@ -317,7 +318,7 @@ void main() {
|
||||
expect(findSemantics().excluding, true);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade.layoutBuilder', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -361,7 +362,7 @@ void main() {
|
||||
expect(find.text('AAA'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade test focus', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade test focus', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -385,7 +386,7 @@ void main() {
|
||||
expect(hiddenNode.hasPrimaryFocus, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade bottom child can have focus', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade bottom child can have focus', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -410,7 +411,7 @@ void main() {
|
||||
expect(hiddenNode.hasPrimaryFocus, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedCrossFade second child do not receive touch events',
|
||||
testWidgetsWithLeakTracking('AnimatedCrossFade second child do not receive touch events',
|
||||
(WidgetTester tester) async {
|
||||
int numberOfTouchEventNoticed = 0;
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
import 'package:flutter/src/foundation/diagnostics.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() {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/100451
|
||||
testWidgets('SliverAnimatedGrid.builder respects findChildIndexCallback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SliverAnimatedGrid.builder respects findChildIndexCallback', (WidgetTester tester) async {
|
||||
bool finderCalled = false;
|
||||
int itemCount = 7;
|
||||
late StateSetter stateSetter;
|
||||
@@ -50,7 +51,7 @@ void main() {
|
||||
expect(finderCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedGrid', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedGrid', (WidgetTester tester) async {
|
||||
Widget builder(BuildContext context, int index, Animation<double> animation) {
|
||||
return SizedBox(
|
||||
height: 100.0,
|
||||
@@ -132,7 +133,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('SliverAnimatedGrid', () {
|
||||
testWidgets('initialItemCount', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('initialItemCount', (WidgetTester tester) async {
|
||||
final Map<int, Animation<double>> animations = <int, Animation<double>>{};
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -170,7 +171,7 @@ void main() {
|
||||
expect(animations[1]!.value, 1.0);
|
||||
});
|
||||
|
||||
testWidgets('insert', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('insert', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -250,7 +251,7 @@ void main() {
|
||||
expect(itemRight(2), 300.0);
|
||||
});
|
||||
|
||||
testWidgets('insertAll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('insertAll', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -306,7 +307,7 @@ void main() {
|
||||
expect(itemRight(1), 200.0);
|
||||
});
|
||||
|
||||
testWidgets('remove', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('remove', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
final List<int> items = <int>[0, 1, 2];
|
||||
|
||||
@@ -384,7 +385,7 @@ void main() {
|
||||
expect(itemRight(2), 200.0);
|
||||
});
|
||||
|
||||
testWidgets('removeAll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('removeAll', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
final List<int> items = <int>[0, 1, 2];
|
||||
|
||||
@@ -436,7 +437,7 @@ void main() {
|
||||
expect(find.text('item 2'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('works in combination with other slivers', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('works in combination with other slivers', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -505,7 +506,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('item 0')).dx, 0);
|
||||
});
|
||||
|
||||
testWidgets('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate',
|
||||
testWidgetsWithLeakTracking('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate',
|
||||
(WidgetTester tester) async {
|
||||
final List<int> items = <int>[0, 1, 2, 3];
|
||||
final GlobalKey<SliverAnimatedGridState> listKey = GlobalKey<SliverAnimatedGridState>();
|
||||
@@ -573,7 +574,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'AnimatedGrid.of() and maybeOf called with a context that does not contain AnimatedGrid',
|
||||
(WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
@@ -618,7 +619,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('AnimatedGrid.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedGrid.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
const Clip clipBehavior = Clip.none;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -647,7 +648,7 @@ void main() {
|
||||
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedGrid applies MediaQuery padding', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedGrid applies MediaQuery padding', (WidgetTester tester) async {
|
||||
const EdgeInsets padding = EdgeInsets.all(30.0);
|
||||
EdgeInsets? innerMediaQueryPadding;
|
||||
await tester.pumpWidget(
|
||||
|
||||
@@ -7,9 +7,10 @@ import 'dart: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';
|
||||
|
||||
void main() {
|
||||
testWidgets('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ImageFiltered avoids repainting child as it animates', (WidgetTester tester) async {
|
||||
RenderTestObject.paintCount = 0;
|
||||
await tester.pumpWidget(
|
||||
ColoredBox(
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
import 'package:flutter/src/foundation/diagnostics.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() {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/100451
|
||||
testWidgets('SliverAnimatedList.builder respects findChildIndexCallback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SliverAnimatedList.builder respects findChildIndexCallback', (WidgetTester tester) async {
|
||||
bool finderCalled = false;
|
||||
int itemCount = 7;
|
||||
late StateSetter stateSetter;
|
||||
@@ -47,7 +48,7 @@ void main() {
|
||||
expect(finderCalled, true);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedList', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedList', (WidgetTester tester) async {
|
||||
Widget builder(BuildContext context, int index, Animation<double> animation) {
|
||||
return SizedBox(
|
||||
height: 100.0,
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('SliverAnimatedList', () {
|
||||
testWidgets('initialItemCount', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('initialItemCount', (WidgetTester tester) async {
|
||||
final Map<int, Animation<double>> animations = <int, Animation<double>>{};
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -159,7 +160,7 @@ void main() {
|
||||
expect(animations[1]!.value, 1.0);
|
||||
});
|
||||
|
||||
testWidgets('insert', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('insert', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -245,7 +246,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Test for insertAllItems with SliverAnimatedList
|
||||
testWidgets('insertAll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('insertAll', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -302,7 +303,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Test for removeAllItems with SliverAnimatedList
|
||||
testWidgets('remove', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('remove', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
final List<int> items = <int>[0, 1, 2];
|
||||
|
||||
@@ -379,7 +380,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Test for removeAllItems with SliverAnimatedList
|
||||
testWidgets('removeAll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('removeAll', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
final List<int> items = <int>[0, 1, 2];
|
||||
|
||||
@@ -429,7 +430,7 @@ void main() {
|
||||
expect(find.text('item 2'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('works in combination with other slivers', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('works in combination with other slivers', (WidgetTester tester) async {
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -494,7 +495,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('item 0')).dy, 200);
|
||||
});
|
||||
|
||||
testWidgets('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('passes correctly derived index of findChildIndexCallback to the inner SliverChildBuilderDelegate', (WidgetTester tester) async {
|
||||
final List<int> items = <int>[0, 1, 2, 3];
|
||||
final GlobalKey<SliverAnimatedListState> listKey = GlobalKey<SliverAnimatedListState>();
|
||||
|
||||
@@ -556,7 +557,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'AnimatedList.of() and maybeOf called with a context that does not contain AnimatedList',
|
||||
(WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
@@ -601,7 +602,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('AnimatedList.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedList.clipBehavior is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
const Clip clipBehavior = Clip.none;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -625,9 +626,12 @@ void main() {
|
||||
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).clipBehavior, clipBehavior);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedList.shrinkwrap is forwarded to its inner CustomScrollView', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/115040
|
||||
final ScrollController controller = ScrollController();
|
||||
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -650,7 +654,7 @@ void main() {
|
||||
expect(tester.widget<CustomScrollView>(find.byType(CustomScrollView)).shrinkWrap, true);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedList applies MediaQuery padding', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedList applies MediaQuery padding', (WidgetTester tester) async {
|
||||
const EdgeInsets padding = EdgeInsets.all(30.0);
|
||||
EdgeInsets? innerMediaQueryPadding;
|
||||
await tester.pumpWidget(
|
||||
|
||||
@@ -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('RenderAnimatedOpacityMixin does not drop layer when animating to 1', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin does not drop layer when animating to 1', (WidgetTester tester) async {
|
||||
RenderTestObject.paintCount = 0;
|
||||
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
|
||||
final Tween<double> opacityTween = Tween<double>(begin: 0, end: 1);
|
||||
@@ -40,7 +41,7 @@ void main() {
|
||||
expect(RenderTestObject.paintCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('RenderAnimatedOpacityMixin avoids repainting child as it animates', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin avoids repainting child as it animates', (WidgetTester tester) async {
|
||||
RenderTestObject.paintCount = 0;
|
||||
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
|
||||
final Tween<double> opacityTween = Tween<double>(begin: 0, end: 0.99); // Layer is dropped at 1
|
||||
@@ -73,10 +74,13 @@ void main() {
|
||||
expect(RenderTestObject.paintCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('RenderAnimatedOpacityMixin allows opacity layer to be disposed when animating to 0 opacity', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('RenderAnimatedOpacityMixin allows opacity layer to be disposed when animating to 0 opacity', (WidgetTester tester) async {
|
||||
RenderTestObject.paintCount = 0;
|
||||
final AnimationController controller = AnimationController(vsync: const TestVSync(), duration: const Duration(seconds: 1));
|
||||
final Tween<double> opacityTween = Tween<double>(begin: 0.99, end: 0);
|
||||
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ColoredBox(
|
||||
color: Colors.red,
|
||||
|
||||
@@ -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('AnimatedPadding.debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPadding.debugFillProperties', (WidgetTester tester) async {
|
||||
final AnimatedPadding padding = AnimatedPadding(
|
||||
padding: const EdgeInsets.all(7.0),
|
||||
curve: Curves.ease,
|
||||
@@ -16,7 +17,7 @@ void main() {
|
||||
expect(padding, hasOneLineDescription);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPadding padding visual-to-directional animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPadding padding visual-to-directional animation', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -58,7 +59,7 @@ void main() {
|
||||
expect(tester.getTopRight(find.byKey(target)), const Offset(700.0, 0.0));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPadding animated padding clamped to positive values', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPadding animated padding clamped to positive values', (WidgetTester tester) async {
|
||||
final Key target = UniqueKey();
|
||||
|
||||
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('AnimatedPositioned.fromRect control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositioned.fromRect control test', (WidgetTester tester) async {
|
||||
final AnimatedPositioned positioned = AnimatedPositioned.fromRect(
|
||||
rect: const Rect.fromLTWH(7.0, 5.0, 12.0, 16.0),
|
||||
duration: const Duration(milliseconds: 200),
|
||||
@@ -20,7 +21,7 @@ void main() {
|
||||
expect(positioned, hasOneLineDescription);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositioned - basics (VISUAL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositioned - basics (VISUAL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -102,7 +103,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - basics (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - basics (LTR)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -188,7 +189,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - basics (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - basics (RTL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -274,7 +275,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositioned - interrupted animation (VISUAL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositioned - interrupted animation (VISUAL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -357,7 +358,7 @@ void main() {
|
||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositioned - switching variables (VISUAL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositioned - switching variables (VISUAL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -416,7 +417,7 @@ void main() {
|
||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - interrupted animation (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - interrupted animation (LTR)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -505,7 +506,7 @@ void main() {
|
||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - switching variables (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - switching variables (LTR)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -568,7 +569,7 @@ void main() {
|
||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - interrupted animation (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - interrupted animation (RTL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
@@ -657,7 +658,7 @@ void main() {
|
||||
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedPositionedDirectional - switching variables (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedPositionedDirectional - switching variables (RTL)', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
|
||||
RenderBox box;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
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';
|
||||
|
||||
class TestPaintingContext implements PaintingContext {
|
||||
final List<Invocation> invocations = <Invocation>[];
|
||||
@@ -17,7 +18,7 @@ class TestPaintingContext implements PaintingContext {
|
||||
|
||||
void main() {
|
||||
group('AnimatedSize', () {
|
||||
testWidgets('animates forwards then backwards with stable-sized children', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('animates forwards then backwards with stable-sized children', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: AnimatedSize(
|
||||
@@ -87,7 +88,7 @@ void main() {
|
||||
expect(box.size.height, equals(100.0));
|
||||
});
|
||||
|
||||
testWidgets('clamps animated size to constraints', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('clamps animated size to constraints', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: SizedBox (
|
||||
@@ -132,7 +133,7 @@ void main() {
|
||||
expect(box.size.height, equals(100.0));
|
||||
});
|
||||
|
||||
testWidgets('tracks unstable child, then resumes animation when child stabilizes', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tracks unstable child, then resumes animation when child stabilizes', (WidgetTester tester) async {
|
||||
Future<void> pumpMillis(int millis) async {
|
||||
await tester.pump(Duration(milliseconds: millis));
|
||||
}
|
||||
@@ -215,7 +216,7 @@ void main() {
|
||||
verify(size: 100.0, state: RenderAnimatedSizeState.stable);
|
||||
});
|
||||
|
||||
testWidgets('resyncs its animation controller', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('resyncs its animation controller', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: AnimatedSize(
|
||||
@@ -246,7 +247,7 @@ void main() {
|
||||
expect(box.size.width, equals(150.0));
|
||||
});
|
||||
|
||||
testWidgets('does not run animation unnecessarily', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('does not run animation unnecessarily', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: AnimatedSize(
|
||||
@@ -269,7 +270,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('can set and update clipBehavior', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can set and update clipBehavior', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: AnimatedSize(
|
||||
@@ -303,7 +304,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('works wrapped in IntrinsicHeight and Wrap', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('works wrapped in IntrinsicHeight and Wrap', (WidgetTester tester) async {
|
||||
Future<void> pumpWidget(Size size, [Duration? duration]) async {
|
||||
return tester.pumpWidget(
|
||||
Center(
|
||||
@@ -350,7 +351,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(IntrinsicHeight)).size, const Size(222, 222));
|
||||
});
|
||||
|
||||
testWidgets('re-attach with interrupted animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('re-attach with interrupted animation', (WidgetTester tester) async {
|
||||
const Key key1 = ValueKey<String>('key1');
|
||||
const Key key2 = ValueKey<String>('key2');
|
||||
late StateSetter setState;
|
||||
|
||||
@@ -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('AnimatedSwitcher fades in a new child.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher fades in a new child.', (WidgetTester tester) async {
|
||||
final UniqueKey containerOne = UniqueKey();
|
||||
final UniqueKey containerTwo = UniqueKey();
|
||||
final UniqueKey containerThree = UniqueKey();
|
||||
@@ -50,7 +51,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher can handle back-to-back changes.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher can handle back-to-back changes.', (WidgetTester tester) async {
|
||||
final UniqueKey container1 = UniqueKey();
|
||||
final UniqueKey container2 = UniqueKey();
|
||||
final UniqueKey container3 = UniqueKey();
|
||||
@@ -85,7 +86,7 @@ void main() {
|
||||
expect(find.byKey(container3), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets("AnimatedSwitcher doesn't transition in a new child of the same type.", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("AnimatedSwitcher doesn't transition in a new child of the same type.", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
@@ -111,7 +112,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher handles null children.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher handles null children.', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 100),
|
||||
@@ -166,7 +167,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
|
||||
testWidgets("AnimatedSwitcher doesn't start any animations after dispose.", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("AnimatedSwitcher doesn't start any animations after dispose.", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
child: Container(color: const Color(0xff000000)),
|
||||
@@ -178,7 +179,7 @@ void main() {
|
||||
expect(await tester.pumpAndSettle(), equals(1));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async {
|
||||
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
@@ -199,7 +200,7 @@ void main() {
|
||||
expect(find.byType(Column), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher uses custom transitions.', (WidgetTester tester) async {
|
||||
late List<Widget> foundChildren;
|
||||
Widget newLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
|
||||
foundChildren = <Widget>[
|
||||
@@ -254,7 +255,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets("AnimatedSwitcher doesn't reset state of the children in transitions.", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("AnimatedSwitcher doesn't reset state of the children in transitions.", (WidgetTester tester) async {
|
||||
final UniqueKey statefulOne = UniqueKey();
|
||||
final UniqueKey statefulTwo = UniqueKey();
|
||||
final UniqueKey statefulThree = UniqueKey();
|
||||
@@ -305,7 +306,7 @@ void main() {
|
||||
expect(StatefulTestState.generation, equals(3));
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async {
|
||||
Future<void> pumpChild(Widget child) async {
|
||||
return tester.pumpWidget(
|
||||
Directionality(
|
||||
@@ -332,7 +333,7 @@ void main() {
|
||||
expect(find.text('2'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher updates previous child transitions if the transitionBuilder changes.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher updates previous child transitions if the transitionBuilder changes.', (WidgetTester tester) async {
|
||||
final UniqueKey containerOne = UniqueKey();
|
||||
final UniqueKey containerTwo = UniqueKey();
|
||||
final UniqueKey containerThree = UniqueKey();
|
||||
@@ -416,7 +417,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('AnimatedSwitcher does not duplicate animations if the same child is entered twice.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedSwitcher does not duplicate animations if the same child is entered twice.', (WidgetTester tester) async {
|
||||
Future<void> pumpChild(Widget child) async {
|
||||
return tester.pumpWidget(
|
||||
Directionality(
|
||||
|
||||
@@ -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('provides a value to the layer tree', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('provides a value to the layer tree', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const AnnotatedRegion<int>(
|
||||
value: 1,
|
||||
@@ -18,7 +19,8 @@ void main() {
|
||||
final AnnotatedRegionLayer<int> layer = layers.whereType<AnnotatedRegionLayer<int>>().first;
|
||||
expect(layer.value, 1);
|
||||
});
|
||||
testWidgets('provides a value to the layer tree in a particular region', (WidgetTester tester) async {
|
||||
|
||||
testWidgetsWithLeakTracking('provides a value to the layer tree in a particular region', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Transform.translate(
|
||||
offset: const Offset(25.0, 25.0),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:ui';
|
||||
import 'package:flutter/services.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() {
|
||||
late AppLifecycleListener listener;
|
||||
@@ -47,13 +48,13 @@ void main() {
|
||||
'There were ${TestAppLifecycleListener.registerCount} listeners that were not disposed of in tests.');
|
||||
});
|
||||
|
||||
testWidgets('Default Diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Default Diagnostics', (WidgetTester tester) async {
|
||||
listener = TestAppLifecycleListener(binding: tester.binding);
|
||||
expect(listener.toString(),
|
||||
equalsIgnoringHashCodes('TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>)'));
|
||||
});
|
||||
|
||||
testWidgets('Diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Diagnostics', (WidgetTester tester) async {
|
||||
Future<AppExitResponse> handleExitRequested() async {
|
||||
return AppExitResponse.cancel;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ void main() {
|
||||
'TestAppLifecycleListener#00000(binding: <AutomatedTestWidgetsFlutterBinding>, onStateChange, onExitRequested)'));
|
||||
});
|
||||
|
||||
testWidgets('listens to AppLifecycleState', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('listens to AppLifecycleState', (WidgetTester tester) async {
|
||||
final List<AppLifecycleState> states = <AppLifecycleState>[tester.binding.lifecycleState!];
|
||||
void stateChange(AppLifecycleState state) {
|
||||
states.add(state);
|
||||
@@ -95,7 +96,7 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
testWidgets('Triggers correct state transition callbacks', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Triggers correct state transition callbacks', (WidgetTester tester) async {
|
||||
final List<String> transitions = <String>[];
|
||||
listener = TestAppLifecycleListener(
|
||||
binding: WidgetsBinding.instance,
|
||||
@@ -148,7 +149,7 @@ void main() {
|
||||
await setAppLifeCycleState(AppLifecycleState.detached);
|
||||
});
|
||||
|
||||
testWidgets('Receives exit requests', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Receives exit requests', (WidgetTester tester) async {
|
||||
bool exitRequested = false;
|
||||
Future<AppExitResponse> handleExitRequested() async {
|
||||
exitRequested = true;
|
||||
|
||||
@@ -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';
|
||||
|
||||
Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>(
|
||||
settings: settings,
|
||||
@@ -13,7 +14,7 @@ Route<void> generateRoute(RouteSettings settings) => PageRouteBuilder<void>(
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('WidgetsApp.navigatorKey', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.navigatorKey', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
|
||||
await tester.pumpWidget(WidgetsApp(
|
||||
navigatorKey: key,
|
||||
|
||||
@@ -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';
|
||||
|
||||
class TestRoute<T> extends PageRoute<T> {
|
||||
TestRoute({ required this.child, super.settings });
|
||||
@@ -40,7 +41,7 @@ Future<void> pumpApp(WidgetTester tester) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('WidgetsApp control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp control test', (WidgetTester tester) async {
|
||||
await pumpApp(tester);
|
||||
expect(find.byType(WidgetsApp), findsOneWidget);
|
||||
expect(find.byType(Navigator), findsOneWidget);
|
||||
@@ -48,7 +49,7 @@ void main() {
|
||||
expect(find.byType(CheckedModeBanner), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('showPerformanceOverlayOverride true', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showPerformanceOverlayOverride true', (WidgetTester tester) async {
|
||||
expect(WidgetsApp.showPerformanceOverlayOverride, false);
|
||||
WidgetsApp.showPerformanceOverlayOverride = true;
|
||||
await pumpApp(tester);
|
||||
@@ -59,7 +60,7 @@ void main() {
|
||||
WidgetsApp.showPerformanceOverlayOverride = false;
|
||||
});
|
||||
|
||||
testWidgets('showPerformanceOverlayOverride false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showPerformanceOverlayOverride false', (WidgetTester tester) async {
|
||||
WidgetsApp.showPerformanceOverlayOverride = true;
|
||||
expect(WidgetsApp.showPerformanceOverlayOverride, true);
|
||||
WidgetsApp.showPerformanceOverlayOverride = false;
|
||||
@@ -70,7 +71,7 @@ void main() {
|
||||
expect(find.byType(CheckedModeBanner), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('debugAllowBannerOverride false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugAllowBannerOverride false', (WidgetTester tester) async {
|
||||
expect(WidgetsApp.showPerformanceOverlayOverride, false);
|
||||
expect(WidgetsApp.debugAllowBannerOverride, true);
|
||||
WidgetsApp.debugAllowBannerOverride = false;
|
||||
@@ -82,7 +83,7 @@ void main() {
|
||||
WidgetsApp.debugAllowBannerOverride = true; // restore to default value
|
||||
});
|
||||
|
||||
testWidgets('debugAllowBannerOverride true', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugAllowBannerOverride true', (WidgetTester tester) async {
|
||||
WidgetsApp.debugAllowBannerOverride = false;
|
||||
expect(WidgetsApp.showPerformanceOverlayOverride, false);
|
||||
expect(WidgetsApp.debugAllowBannerOverride, false);
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class TestIntent extends Intent {
|
||||
const TestIntent();
|
||||
@@ -23,7 +24,7 @@ class TestAction extends Action<Intent> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('WidgetsApp with builder only', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp with builder only', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
WidgetsApp(
|
||||
@@ -37,7 +38,7 @@ void main() {
|
||||
expect(find.byKey(key), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp default key bindings', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp default key bindings', (WidgetTester tester) async {
|
||||
bool? checked = false;
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
@@ -64,7 +65,7 @@ void main() {
|
||||
expect(checked, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp can override default key bindings', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp can override default key bindings', (WidgetTester tester) async {
|
||||
final TestAction action = TestAction();
|
||||
bool? checked = false;
|
||||
final GlobalKey key = GlobalKey();
|
||||
@@ -101,7 +102,7 @@ void main() {
|
||||
expect(action.calls, equals(1));
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp default activation key mappings work', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp default activation key mappings work', (WidgetTester tester) async {
|
||||
bool? checked = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -168,7 +169,7 @@ void main() {
|
||||
}
|
||||
}
|
||||
|
||||
testWidgets('push unknown route when onUnknownRoute is null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('push unknown route when onUnknownRoute is null', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
|
||||
expectFlutterError(
|
||||
key: key,
|
||||
@@ -196,7 +197,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('push unknown route when onUnknownRoute returns null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('push unknown route when onUnknownRoute returns null', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
|
||||
expectFlutterError(
|
||||
key: key,
|
||||
@@ -218,7 +219,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp can customize initial routes', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp can customize initial routes', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
await tester.pumpWidget(
|
||||
WidgetsApp(
|
||||
@@ -271,12 +272,13 @@ void main() {
|
||||
expect(find.text('regular page'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp.router works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router works', (WidgetTester tester) async {
|
||||
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(
|
||||
uri: Uri.parse('initial'),
|
||||
),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
@@ -288,6 +290,7 @@ void main() {
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
await tester.pumpWidget(WidgetsApp.router(
|
||||
routeInformationProvider: provider,
|
||||
routeInformationParser: SimpleRouteInformationParser(),
|
||||
@@ -301,9 +304,14 @@ void main() {
|
||||
await tester.binding.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('popped'), findsOneWidget);
|
||||
});
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(someone): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134205
|
||||
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
|
||||
));
|
||||
|
||||
testWidgets('WidgetsApp.router route information parser is optional', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router route information parser is optional', (WidgetTester tester) async {
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
@@ -315,6 +323,7 @@ void main() {
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
delegate.routeInformation = RouteInformation(uri: Uri.parse('initial'));
|
||||
await tester.pumpWidget(WidgetsApp.router(
|
||||
routerDelegate: delegate,
|
||||
@@ -327,9 +336,14 @@ void main() {
|
||||
await tester.binding.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('popped'), findsOneWidget);
|
||||
});
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(someone): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134205
|
||||
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
|
||||
));
|
||||
|
||||
testWidgets('WidgetsApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async {
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
@@ -341,12 +355,14 @@ void main() {
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
delegate.routeInformation = RouteInformation(uri: Uri.parse('initial'));
|
||||
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(
|
||||
uri: Uri.parse('initial'),
|
||||
),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
await expectLater(() async {
|
||||
await tester.pumpWidget(WidgetsApp.router(
|
||||
routeInformationProvider: provider,
|
||||
@@ -356,7 +372,7 @@ void main() {
|
||||
}, throwsAssertionError);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async {
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
@@ -368,6 +384,7 @@ void main() {
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
delegate.routeInformation = RouteInformation(uri: Uri.parse('initial'));
|
||||
final RouterConfig<RouteInformation> routerConfig = RouterConfig<RouteInformation>(routerDelegate: delegate);
|
||||
await expectLater(() async {
|
||||
@@ -379,25 +396,29 @@ void main() {
|
||||
}, throwsAssertionError);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp.router router config works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router router config works', (WidgetTester tester) async {
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
},
|
||||
onPopPage: (Route<void> route, void result, SimpleNavigatorRouterDelegate delegate) {
|
||||
delegate.routeInformation = RouteInformation(
|
||||
uri: Uri.parse('popped'),
|
||||
);
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(
|
||||
uri: Uri.parse('initial'),
|
||||
),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
final RouterConfig<RouteInformation> routerConfig = RouterConfig<RouteInformation>(
|
||||
routeInformationProvider: PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(
|
||||
uri: Uri.parse('initial'),
|
||||
),
|
||||
),
|
||||
routeInformationProvider: provider,
|
||||
routeInformationParser: SimpleRouteInformationParser(),
|
||||
routerDelegate: SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
},
|
||||
onPopPage: (Route<void> route, void result, SimpleNavigatorRouterDelegate delegate) {
|
||||
delegate.routeInformation = RouteInformation(
|
||||
uri: Uri.parse('popped'),
|
||||
);
|
||||
return route.didPop(result);
|
||||
},
|
||||
),
|
||||
routerDelegate: delegate,
|
||||
backButtonDispatcher: RootBackButtonDispatcher()
|
||||
);
|
||||
await tester.pumpWidget(WidgetsApp.router(
|
||||
@@ -411,24 +432,35 @@ void main() {
|
||||
await tester.binding.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('popped'), findsOneWidget);
|
||||
});
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(someone): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134205
|
||||
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
|
||||
));
|
||||
|
||||
testWidgets('WidgetsApp.router has correct default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp.router has correct default', (WidgetTester tester) async {
|
||||
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
|
||||
builder: (BuildContext context, RouteInformation information) {
|
||||
return Text(information.uri.toString());
|
||||
},
|
||||
onPopPage: (Route<Object?> route, Object? result, SimpleNavigatorRouterDelegate delegate) => true,
|
||||
);
|
||||
addTearDown(delegate.dispose);
|
||||
await tester.pumpWidget(WidgetsApp.router(
|
||||
routeInformationParser: SimpleRouteInformationParser(),
|
||||
routerDelegate: delegate,
|
||||
color: const Color(0xFF123456),
|
||||
));
|
||||
expect(find.text('/'), findsOneWidget);
|
||||
});
|
||||
},
|
||||
leakTrackingTestConfig: const LeakTrackingTestConfig(
|
||||
// TODO(someone): remove after fixing
|
||||
// https://github.com/flutter/flutter/issues/134205
|
||||
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
|
||||
));
|
||||
|
||||
testWidgets('WidgetsApp has correct default ScrollBehavior', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp has correct default ScrollBehavior', (WidgetTester tester) async {
|
||||
late BuildContext capturedContext;
|
||||
await tester.pumpWidget(
|
||||
WidgetsApp(
|
||||
@@ -569,7 +601,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("WidgetsApp reports an exception if the selected locale isn't supported", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("WidgetsApp reports an exception if the selected locale isn't supported", (WidgetTester tester) async {
|
||||
late final List<Locale>? localesArg;
|
||||
late final Iterable<Locale> supportedLocalesArg;
|
||||
await tester.pumpWidget(
|
||||
@@ -593,7 +625,7 @@ void main() {
|
||||
expect(tester.takeException(), "Warning: This application's locale, C_UTF-8, is not supported by all of its localization delegates.");
|
||||
});
|
||||
|
||||
testWidgets("WidgetsApp doesn't have dependency on MediaQuery", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("WidgetsApp doesn't have dependency on MediaQuery", (WidgetTester tester) async {
|
||||
int routeBuildCount = 0;
|
||||
|
||||
final Widget widget = WidgetsApp(
|
||||
@@ -619,8 +651,10 @@ void main() {
|
||||
expect(routeBuildCount, equals(1));
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp provides meta based shortcuts for iOS and macOS', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp provides meta based shortcuts for iOS and macOS', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
|
||||
final SelectAllSpy selectAllSpy = SelectAllSpy();
|
||||
final CopySpy copySpy = CopySpy();
|
||||
final PasteSpy pasteSpy = PasteSpy();
|
||||
@@ -710,7 +744,7 @@ void main() {
|
||||
await setAppLifeCycleState(AppLifecycleState.resumed);
|
||||
});
|
||||
|
||||
testWidgets('WidgetsApp calls setFrameworkHandlesBack only when app is ready', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('WidgetsApp calls setFrameworkHandlesBack only when app is ready', (WidgetTester tester) async {
|
||||
// Start in the `resumed` state, where setFrameworkHandlesBack should be
|
||||
// called like normal.
|
||||
await setAppLifeCycleState(AppLifecycleState.resumed);
|
||||
|
||||
@@ -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';
|
||||
|
||||
const Color kTitleColor = Color(0xFF333333);
|
||||
const String kTitleString = 'Hello World';
|
||||
@@ -30,13 +31,13 @@ Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle, C
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Specified title and color are used to build a Title', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Specified title and color are used to build a Title', (WidgetTester tester) async {
|
||||
await pumpApp(tester);
|
||||
expect(tester.widget<Title>(find.byType(Title)).title, kTitleString);
|
||||
expect(tester.widget<Title>(find.byType(Title)).color, kTitleColor);
|
||||
});
|
||||
|
||||
testWidgets('Specified color is made opaque for Title', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Specified color is made opaque for Title', (WidgetTester tester) async {
|
||||
// The Title widget can only handle fully opaque colors, the WidgetApp should
|
||||
// ensure it only uses a fully opaque version of its color for the title.
|
||||
const Color transparentBlue = Color(0xDD0000ff);
|
||||
@@ -45,7 +46,7 @@ void main() {
|
||||
expect(tester.widget<Title>(find.byType(Title)).color, opaqueBlue);
|
||||
});
|
||||
|
||||
testWidgets('onGenerateTitle handles changing locales', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('onGenerateTitle handles changing locales', (WidgetTester tester) async {
|
||||
String generateTitle(BuildContext context) {
|
||||
return Localizations.localeOf(context).toString();
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double aspectRatio) async {
|
||||
final Key childKey = UniqueKey();
|
||||
@@ -25,12 +26,12 @@ Future<Size> _getSize(WidgetTester tester, BoxConstraints constraints, double as
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Aspect ratio control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Aspect ratio control test', (WidgetTester tester) async {
|
||||
expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 2.0), equals(const Size(500.0, 250.0)));
|
||||
expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 0.5), equals(const Size(250.0, 500.0)));
|
||||
});
|
||||
|
||||
testWidgets('Aspect ratio infinite width', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Aspect ratio infinite width', (WidgetTester tester) async {
|
||||
final Key childKey = UniqueKey();
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:async';
|
||||
import 'package:flutter/foundation.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() {
|
||||
Widget snapshotText(BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||
@@ -66,21 +67,21 @@ void main() {
|
||||
});
|
||||
});
|
||||
group('Async smoke tests', () {
|
||||
testWidgets('FutureBuilder', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FutureBuilder', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
future: Future<String>.value('hello'),
|
||||
builder: snapshotText,
|
||||
));
|
||||
await eventFiring(tester);
|
||||
});
|
||||
testWidgets('StreamBuilder', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('StreamBuilder', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
stream: Stream<String>.fromIterable(<String>['hello', 'world']),
|
||||
builder: snapshotText,
|
||||
));
|
||||
await eventFiring(tester);
|
||||
});
|
||||
testWidgets('StreamFold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('StreamFold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(StringCollector(
|
||||
stream: Stream<String>.fromIterable(<String>['hello', 'world']),
|
||||
));
|
||||
@@ -88,7 +89,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
group('FutureBuilder', () {
|
||||
testWidgets('gives expected snapshot with SynchronousFuture', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gives expected snapshot with SynchronousFuture', (WidgetTester tester) async {
|
||||
final SynchronousFuture<String> future = SynchronousFuture<String>('flutter');
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
future: future,
|
||||
@@ -102,7 +103,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('gracefully handles transition from null future', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition from null future', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
key: key, builder: snapshotText, future: null,
|
||||
@@ -114,7 +115,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.waiting, null, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to null future', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to null future', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
@@ -129,7 +130,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.none, null, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to other future', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to other future', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final Completer<String> completerA = Completer<String>();
|
||||
final Completer<String> completerB = Completer<String>();
|
||||
@@ -146,7 +147,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, B, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('tracks life-cycle of Future to success', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tracks life-cycle of Future to success', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
future: completer.future, builder: snapshotText,
|
||||
@@ -156,7 +157,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, hello, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('tracks life-cycle of Future to error', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tracks life-cycle of Future to error', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
future: completer.future, builder: snapshotText,
|
||||
@@ -166,7 +167,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, null, bad, trace)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('runs the builder using given initial data', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('runs the builder using given initial data', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
key: key,
|
||||
@@ -176,7 +177,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.none, I, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('ignores initialData when reconfiguring', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ignores initialData when reconfiguring', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(FutureBuilder<String>(
|
||||
key: key,
|
||||
@@ -194,7 +195,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.waiting, I, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('debugRethrowError rethrows caught error', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugRethrowError rethrows caught error', (WidgetTester tester) async {
|
||||
FutureBuilder.debugRethrowError = true;
|
||||
final Completer<void> caughtError = Completer<void>();
|
||||
await runZonedGuarded(() async {
|
||||
@@ -214,7 +215,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
group('StreamBuilder', () {
|
||||
testWidgets('gracefully handles transition from null stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition from null stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
key: key, builder: snapshotText, stream: null,
|
||||
@@ -226,7 +227,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.waiting, null, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to null stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to null stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controller = StreamController<String>();
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
@@ -238,7 +239,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.none, null, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to other stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to other stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controllerA = StreamController<String>();
|
||||
final StreamController<String> controllerB = StreamController<String>();
|
||||
@@ -254,7 +255,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.active, B, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('tracks events and errors of stream until completion', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tracks events and errors of stream until completion', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controller = StreamController<String>();
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
@@ -274,7 +275,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, 4, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('runs the builder using given initial data', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('runs the builder using given initial data', (WidgetTester tester) async {
|
||||
final StreamController<String> controller = StreamController<String>();
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
stream: controller.stream,
|
||||
@@ -283,7 +284,7 @@ void main() {
|
||||
));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.waiting, I, null, null)'), findsOneWidget);
|
||||
});
|
||||
testWidgets('ignores initialData when reconfiguring', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ignores initialData when reconfiguring', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(StreamBuilder<String>(
|
||||
key: key,
|
||||
@@ -303,7 +304,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
group('FutureBuilder and StreamBuilder behave identically on Stream from Future', () {
|
||||
testWidgets('when completing with data', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when completing with data', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(future: completer.future, builder: snapshotText),
|
||||
@@ -314,7 +315,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, hello, null, null)'), findsNWidgets(2));
|
||||
});
|
||||
testWidgets('when completing with error and with empty stack trace', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when completing with error and with empty stack trace', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(future: completer.future, builder: snapshotText),
|
||||
@@ -325,7 +326,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, null, bad, )'), findsNWidgets(2));
|
||||
});
|
||||
testWidgets('when completing with error and with stack trace', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when completing with error and with stack trace', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(future: completer.future, builder: snapshotText),
|
||||
@@ -336,21 +337,21 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.done, null, bad, trace)'), findsNWidgets(2));
|
||||
});
|
||||
testWidgets('when Future is null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when Future is null', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(builder: snapshotText, future: null),
|
||||
StreamBuilder<String>(builder: snapshotText, stream: null,),
|
||||
]));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.none, null, null, null)'), findsNWidgets(2));
|
||||
});
|
||||
testWidgets('when initialData is used with null Future and Stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when initialData is used with null Future and Stream', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(builder: snapshotText, initialData: 'I', future: null),
|
||||
StreamBuilder<String>(builder: snapshotText, initialData: 'I', stream: null),
|
||||
]));
|
||||
expect(find.text('AsyncSnapshot<String>(ConnectionState.none, I, null, null)'), findsNWidgets(2));
|
||||
});
|
||||
testWidgets('when using initialData and completing with data', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when using initialData and completing with data', (WidgetTester tester) async {
|
||||
final Completer<String> completer = Completer<String>();
|
||||
await tester.pumpWidget(Column(children: <Widget>[
|
||||
FutureBuilder<String>(future: completer.future, builder: snapshotText, initialData: 'I'),
|
||||
@@ -363,7 +364,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
group('StreamBuilderBase', () {
|
||||
testWidgets('gracefully handles transition from null stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition from null stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(StringCollector(key: key));
|
||||
expect(find.text(''), findsOneWidget);
|
||||
@@ -371,7 +372,7 @@ void main() {
|
||||
await tester.pumpWidget(StringCollector(key: key, stream: controller.stream));
|
||||
expect(find.text('conn'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to null stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to null stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controller = StreamController<String>();
|
||||
await tester.pumpWidget(StringCollector(key: key, stream: controller.stream));
|
||||
@@ -379,7 +380,7 @@ void main() {
|
||||
await tester.pumpWidget(StringCollector(key: key));
|
||||
expect(find.text('conn, disc'), findsOneWidget);
|
||||
});
|
||||
testWidgets('gracefully handles transition to other stream', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('gracefully handles transition to other stream', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controllerA = StreamController<String>();
|
||||
final StreamController<String> controllerB = StreamController<String>();
|
||||
@@ -390,7 +391,7 @@ void main() {
|
||||
await eventFiring(tester);
|
||||
expect(find.text('conn, disc, conn, data:B'), findsOneWidget);
|
||||
});
|
||||
testWidgets('tracks events and errors until completion', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tracks events and errors until completion', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final StreamController<String> controller = StreamController<String>();
|
||||
await tester.pumpWidget(StringCollector(key: key, stream: controller.stream));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class User {
|
||||
const User({
|
||||
@@ -45,7 +46,7 @@ void main() {
|
||||
User(name: 'Charlie', email: 'charlie123@gmail.com'),
|
||||
];
|
||||
|
||||
testWidgets('can filter and select a list of string options', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -129,7 +130,7 @@ void main() {
|
||||
expect(lastOptions.elementAt(5), 'northern white rhinoceros');
|
||||
});
|
||||
|
||||
testWidgets('tapping on an option selects it', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('tapping on an option selects it', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -199,7 +200,7 @@ void main() {
|
||||
expect(textEditingController.text, equals(kOptions[2]));
|
||||
});
|
||||
|
||||
testWidgets('can filter and select a list of custom User options', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can filter and select a list of custom User options', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<User> lastOptions;
|
||||
@@ -277,7 +278,7 @@ void main() {
|
||||
expect(lastOptions.elementAt(0), kOptionsUsers[1]);
|
||||
});
|
||||
|
||||
testWidgets('can specify a custom display string for a list of custom User options', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can specify a custom display string for a list of custom User options', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<User> lastOptions;
|
||||
@@ -360,7 +361,7 @@ void main() {
|
||||
expect(lastOptions.elementAt(0), kOptionsUsers[1]);
|
||||
});
|
||||
|
||||
testWidgets('onFieldSubmitted selects the first option', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('onFieldSubmitted selects the first option', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -422,7 +423,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('optionsViewOpenDirection', () {
|
||||
testWidgets('unset (default behavior): open downward', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('unset (default behavior): open downward', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -445,7 +446,7 @@ void main() {
|
||||
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
|
||||
});
|
||||
|
||||
testWidgets('down: open downward', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('down: open downward', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -469,7 +470,7 @@ void main() {
|
||||
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
|
||||
});
|
||||
|
||||
testWidgets('up: open upward', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('up: open upward', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -494,10 +495,12 @@ void main() {
|
||||
});
|
||||
|
||||
group('fieldViewBuilder not passed', () {
|
||||
testWidgets('down', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('down', (WidgetTester tester) async {
|
||||
final GlobalKey autocompleteKey = GlobalKey();
|
||||
final TextEditingController controller = TextEditingController();
|
||||
addTearDown(controller.dispose);
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -525,10 +528,12 @@ void main() {
|
||||
offsetMoreOrLessEquals(tester.getTopLeft(find.text('a'))));
|
||||
});
|
||||
|
||||
testWidgets('up', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('up', (WidgetTester tester) async {
|
||||
final GlobalKey autocompleteKey = GlobalKey();
|
||||
final TextEditingController controller = TextEditingController();
|
||||
addTearDown(controller.dispose);
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -559,7 +564,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('options follow field when it moves', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('options follow field when it moves', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late StateSetter setState;
|
||||
@@ -633,7 +638,7 @@ void main() {
|
||||
expect(optionsOffsetOpen.dy, fieldOffset.dy + fieldSize.height);
|
||||
});
|
||||
|
||||
testWidgets('can prevent options from showing by returning an empty iterable', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can prevent options from showing by returning an empty iterable', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -696,13 +701,15 @@ void main() {
|
||||
expect(lastOptions.elementAt(1), 'elephant');
|
||||
});
|
||||
|
||||
testWidgets('can create a field outside of fieldViewBuilder', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can create a field outside of fieldViewBuilder', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
final GlobalKey autocompleteKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
final TextEditingController textEditingController = TextEditingController();
|
||||
addTearDown(textEditingController.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -762,7 +769,7 @@ void main() {
|
||||
expect(textEditingController.text, lastOptions.elementAt(0));
|
||||
});
|
||||
|
||||
testWidgets('initialValue sets initial text field value', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('initialValue sets initial text field value', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -822,9 +829,11 @@ void main() {
|
||||
expect(textEditingController.text, selection);
|
||||
});
|
||||
|
||||
testWidgets('initialValue cannot be defined if TextEditingController is defined', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('initialValue cannot be defined if TextEditingController is defined', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
final TextEditingController textEditingController = TextEditingController();
|
||||
addTearDown(textEditingController.dispose);
|
||||
|
||||
expect(
|
||||
() {
|
||||
@@ -854,7 +863,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('support asynchronous options builder', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('support asynchronous options builder', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late FocusNode focusNode;
|
||||
@@ -915,7 +924,7 @@ void main() {
|
||||
expect(lastOptions, <String>['dingo', 'flamingo']);
|
||||
});
|
||||
|
||||
testWidgets('can navigate options with the keyboard', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can navigate options with the keyboard', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -1001,7 +1010,7 @@ void main() {
|
||||
expect(textEditingController.text, 'goose');
|
||||
});
|
||||
|
||||
testWidgets('can hide and show options with the keyboard', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can hide and show options with the keyboard', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -1091,7 +1100,7 @@ void main() {
|
||||
expect(find.byKey(optionsKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('re-invokes DismissIntent if options not shown', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('re-invokes DismissIntent if options not shown', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late FocusNode focusNode;
|
||||
@@ -1150,7 +1159,7 @@ void main() {
|
||||
expect(wrappingActionInvoked, true);
|
||||
});
|
||||
|
||||
testWidgets('optionsViewBuilders can use AutocompleteHighlightedOption to highlight selected option', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('optionsViewBuilders can use AutocompleteHighlightedOption to highlight selected option', (WidgetTester tester) async {
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
late Iterable<String> lastOptions;
|
||||
@@ -1231,7 +1240,7 @@ void main() {
|
||||
expect(lastHighlighted, 5);
|
||||
});
|
||||
|
||||
testWidgets('floating menu goes away on select', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('floating menu goes away on select', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/99749.
|
||||
final GlobalKey fieldKey = GlobalKey();
|
||||
final GlobalKey optionsKey = GlobalKey();
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
final Matcher _matchesCommit = isMethodCall('TextInput.finishAutofillContext', arguments: true);
|
||||
final Matcher _matchesCancel = isMethodCall('TextInput.finishAutofillContext', arguments: false);
|
||||
|
||||
void main() {
|
||||
testWidgets('AutofillGroup has the right clients', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutofillGroup has the right clients', (WidgetTester tester) async {
|
||||
const Key outerKey = Key('outer');
|
||||
const Key innerKey = Key('inner');
|
||||
|
||||
@@ -44,7 +45,7 @@ void main() {
|
||||
expect(innerState.autofillClients.toList(), <State<TextField>>[clientState2]);
|
||||
});
|
||||
|
||||
testWidgets('new clients can be added & removed to a scope', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('new clients can be added & removed to a scope', (WidgetTester tester) async {
|
||||
const Key scopeKey = Key('scope');
|
||||
|
||||
const TextField client1 = TextField(autofillHints: <String>['1']);
|
||||
@@ -92,7 +93,7 @@ void main() {
|
||||
expect(scopeState.autofillClients, <State<TextField>>[clientState1]);
|
||||
});
|
||||
|
||||
testWidgets('AutofillGroup has the right clients after reparenting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutofillGroup has the right clients after reparenting', (WidgetTester tester) async {
|
||||
const Key outerKey = Key('outer');
|
||||
const Key innerKey = Key('inner');
|
||||
final GlobalKey keyClient3 = GlobalKey();
|
||||
@@ -151,7 +152,7 @@ void main() {
|
||||
expect(innerState.autofillClients, <State<TextField>>[clientState2]);
|
||||
});
|
||||
|
||||
testWidgets('disposing AutofillGroups', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('disposing AutofillGroups', (WidgetTester tester) async {
|
||||
late StateSetter setState;
|
||||
const Key group1 = Key('group1');
|
||||
const Key group2 = Key('group2');
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
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';
|
||||
|
||||
class Leaf extends StatefulWidget {
|
||||
const Leaf({ required Key key, required this.child }) : super(key: key);
|
||||
@@ -21,7 +22,7 @@ class _LeafState extends State<Leaf> {
|
||||
|
||||
@override
|
||||
void deactivate() {
|
||||
_handle?.release();
|
||||
_handle?.dispose();
|
||||
_handle = null;
|
||||
super.deactivate();
|
||||
}
|
||||
@@ -34,7 +35,7 @@ class _LeafState extends State<Leaf> {
|
||||
KeepAliveNotification(_handle!).dispatch(context);
|
||||
}
|
||||
} else {
|
||||
_handle?.release();
|
||||
_handle?.dispose();
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
@@ -67,7 +68,7 @@ List<Widget> generateList(Widget child, { required bool impliedMode }) {
|
||||
}
|
||||
|
||||
void tests({ required bool impliedMode }) {
|
||||
testWidgets('AutomaticKeepAlive with ListView with itemExtent', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with ListView with itemExtent', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -115,7 +116,7 @@ void tests({ required bool impliedMode }) {
|
||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive with ListView without itemExtent', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with ListView without itemExtent', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -165,7 +166,7 @@ void tests({ required bool impliedMode }) {
|
||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive with GridView', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with GridView', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -222,7 +223,7 @@ void main() {
|
||||
group('Explicit automatic keep-alive', () { tests(impliedMode: false); });
|
||||
group('Implied automatic keep-alive', () { tests(impliedMode: true); });
|
||||
|
||||
testWidgets('AutomaticKeepAlive double', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive double', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -306,7 +307,7 @@ void main() {
|
||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive double 2', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive double 2', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -474,7 +475,7 @@ void main() {
|
||||
expect(find.byKey(const GlobalObjectKey<_LeafState>(0), skipOffstage: false), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive with keepAlive set to true before initState', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with keepAlive set to true before initState', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: ListView.builder(
|
||||
@@ -509,7 +510,7 @@ void main() {
|
||||
expect(find.text('FooBar 2'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive with keepAlive set to true before initState and widget goes out of scope', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with keepAlive set to true before initState and widget goes out of scope', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: ListView.builder(
|
||||
@@ -548,19 +549,22 @@ void main() {
|
||||
expect(find.text('FooBar 73'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('AutomaticKeepAlive with SliverKeepAliveWidget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AutomaticKeepAlive with SliverKeepAliveWidget', (WidgetTester tester) async {
|
||||
// We're just doing a basic test here to make sure that the functionality of
|
||||
// RenderSliverWithKeepAliveMixin doesn't get regressed or deleted. As testing
|
||||
// the full functionality would be cumbersome.
|
||||
final RenderSliverMultiBoxAdaptorAlt alternate = RenderSliverMultiBoxAdaptorAlt();
|
||||
addTearDown(alternate.dispose);
|
||||
final RenderBox child = RenderBoxKeepAlive();
|
||||
addTearDown(child.dispose);
|
||||
alternate.insert(child);
|
||||
|
||||
expect(alternate.children.length, 1);
|
||||
});
|
||||
|
||||
testWidgets('Keep alive Listenable has its listener removed once called', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Keep alive Listenable has its listener removed once called', (WidgetTester tester) async {
|
||||
final LeakCheckerHandle handle = LeakCheckerHandle();
|
||||
addTearDown(handle.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: ListView.builder(
|
||||
|
||||
@@ -11,9 +11,10 @@ import 'dart:ui';
|
||||
|
||||
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("Material2 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("Material2 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
@@ -51,7 +52,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("Material3 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("Material3 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
@@ -89,7 +90,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material2 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(useMaterial3: false),
|
||||
@@ -148,7 +149,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material3 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material3 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class TestCanvas implements Canvas {
|
||||
final List<Invocation> invocations = <Invocation>[];
|
||||
@@ -245,7 +246,7 @@ void main() {
|
||||
expect(rotateCommand.positionalArguments[0], equals(math.pi / 4.0));
|
||||
});
|
||||
|
||||
testWidgets('Banner widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Banner widget', (WidgetTester tester) async {
|
||||
debugDisableShadows = false;
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
@@ -265,7 +266,7 @@ void main() {
|
||||
debugDisableShadows = true;
|
||||
});
|
||||
|
||||
testWidgets('Banner widget in MaterialApp', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Banner widget in MaterialApp', (WidgetTester tester) async {
|
||||
debugDisableShadows = false;
|
||||
await tester.pumpWidget(const MaterialApp(home: Placeholder()));
|
||||
expect(find.byType(CheckedModeBanner), paints
|
||||
|
||||
@@ -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('Baseline - control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Baseline - control test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: DefaultTextStyle(
|
||||
@@ -20,7 +21,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.text('X')).size, const Size(100.0, 100.0));
|
||||
});
|
||||
|
||||
testWidgets('Baseline - position test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Baseline - position test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Center(
|
||||
child: Baseline(
|
||||
@@ -43,7 +44,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Chip caches baseline', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Chip caches baseline', (WidgetTester tester) async {
|
||||
int calls = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -68,7 +69,7 @@ void main() {
|
||||
expect(calls, 2);
|
||||
});
|
||||
|
||||
testWidgets('ListTile caches baseline', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ListTile caches baseline', (WidgetTester tester) async {
|
||||
int calls = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -93,7 +94,7 @@ void main() {
|
||||
expect(calls, 2);
|
||||
});
|
||||
|
||||
testWidgets("LayoutBuilder returns child's baseline", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("LayoutBuilder returns child's baseline", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
|
||||
@@ -15,12 +15,13 @@ import 'package:flutter/gestures.dart';
|
||||
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() {
|
||||
group('RawImage', () {
|
||||
testWidgets('properties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('properties', (WidgetTester tester) async {
|
||||
final ui.Image image1 = (await tester.runAsync<ui.Image>(() => createTestImage()))!;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -110,7 +111,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('PhysicalShape', () {
|
||||
testWidgets('properties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('properties', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const PhysicalShape(
|
||||
clipper: ShapeBorderClipper(shape: CircleBorder()),
|
||||
@@ -126,7 +127,7 @@ void main() {
|
||||
expect(renderObject.elevation, 2.0);
|
||||
});
|
||||
|
||||
testWidgets('hit test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hit test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
PhysicalShape(
|
||||
clipper: const ShapeBorderClipper(shape: CircleBorder()),
|
||||
@@ -156,7 +157,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('FractionalTranslation', () {
|
||||
testWidgets('hit test - entirely inside the bounding box', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hit test - entirely inside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool pointerDown = false;
|
||||
|
||||
@@ -185,7 +186,7 @@ void main() {
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('hit test - partially inside the bounding box', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hit test - partially inside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool pointerDown = false;
|
||||
|
||||
@@ -214,7 +215,7 @@ void main() {
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('hit test - completely outside the bounding box', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('hit test - completely outside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool pointerDown = false;
|
||||
|
||||
@@ -243,7 +244,7 @@ void main() {
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('semantics bounds are updated', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('semantics bounds are updated', (WidgetTester tester) async {
|
||||
final GlobalKey fractionalTranslationKey = GlobalKey();
|
||||
final GlobalKey textKey = GlobalKey();
|
||||
Offset offset = const Offset(0.4, 0.4);
|
||||
@@ -307,7 +308,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Semantics', () {
|
||||
testWidgets('Semantics can set attributed Text', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Semantics can set attributed Text', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -358,7 +359,7 @@ void main() {
|
||||
expect(attributedHint.attributes[0].range, const TextRange(start:1, end: 2));
|
||||
});
|
||||
|
||||
testWidgets('Semantics can merge attributed strings', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Semantics can merge attributed strings', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -413,7 +414,7 @@ void main() {
|
||||
expect(attributedHint.attributes[1].range, const TextRange(start:6, end: 7));
|
||||
});
|
||||
|
||||
testWidgets('Semantics can merge attributed strings with non attributed string', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Semantics can merge attributed strings with non attributed string', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -453,7 +454,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Row', () {
|
||||
testWidgets('multiple baseline aligned children', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('multiple baseline aligned children', (WidgetTester tester) async {
|
||||
final UniqueKey key1 = UniqueKey();
|
||||
final UniqueKey key2 = UniqueKey();
|
||||
// The point size of the font must be a multiple of 4 until
|
||||
@@ -507,7 +508,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.byKey(key2)).dy, aboveBaseline1 - aboveBaseline2);
|
||||
});
|
||||
|
||||
testWidgets('baseline aligned children account for a larger, no-baseline child size', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('baseline aligned children account for a larger, no-baseline child size', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/58898
|
||||
final UniqueKey key1 = UniqueKey();
|
||||
final UniqueKey key2 = UniqueKey();
|
||||
@@ -575,7 +576,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('UnconstrainedBox can set and update clipBehavior', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const UnconstrainedBox());
|
||||
final RenderConstraintsTransformBox renderObject = tester.allRenderObjects.whereType<RenderConstraintsTransformBox>().first;
|
||||
expect(renderObject.clipBehavior, equals(Clip.none));
|
||||
@@ -584,7 +585,7 @@ void main() {
|
||||
expect(renderObject.clipBehavior, equals(Clip.antiAlias));
|
||||
});
|
||||
|
||||
testWidgets('UnconstrainedBox warns only when clipBehavior is Clip.none', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('UnconstrainedBox warns only when clipBehavior is Clip.none', (WidgetTester tester) async {
|
||||
for (final Clip? clip in <Clip?>[null, ...Clip.values]) {
|
||||
// Clear any render objects that were there before so that we can see more
|
||||
// than one error. Otherwise, it just throws the first one and skips the
|
||||
@@ -660,7 +661,7 @@ void main() {
|
||||
mockCanvas = mockContext.canvas;
|
||||
});
|
||||
|
||||
testWidgets('ColoredBox - no size, no child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ColoredBox - no size, no child', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Flex(
|
||||
direction: Axis.horizontal,
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -681,7 +682,7 @@ void main() {
|
||||
expect(mockContext.offsets, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('ColoredBox - no size, child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ColoredBox - no size, child', (WidgetTester tester) async {
|
||||
const ValueKey<int> key = ValueKey<int>(0);
|
||||
const Widget child = SizedBox.expand(key: key);
|
||||
await tester.pumpWidget(const Flex(
|
||||
@@ -705,7 +706,7 @@ void main() {
|
||||
expect(mockContext.offsets.single, Offset.zero);
|
||||
});
|
||||
|
||||
testWidgets('ColoredBox - size, no child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ColoredBox - size, no child', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ColoredBox(color: colorToPaint));
|
||||
expect(find.byType(ColoredBox), findsOneWidget);
|
||||
final RenderObject renderColoredBox = tester.renderObject(find.byType(ColoredBox));
|
||||
@@ -718,7 +719,7 @@ void main() {
|
||||
expect(mockContext.offsets, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('ColoredBox - size, child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ColoredBox - size, child', (WidgetTester tester) async {
|
||||
const ValueKey<int> key = ValueKey<int>(0);
|
||||
const Widget child = SizedBox.expand(key: key);
|
||||
await tester.pumpWidget(const ColoredBox(color: colorToPaint, child: child));
|
||||
@@ -734,7 +735,7 @@ void main() {
|
||||
expect(mockContext.offsets.single, Offset.zero);
|
||||
});
|
||||
|
||||
testWidgets('ColoredBox - debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ColoredBox - debugFillProperties', (WidgetTester tester) async {
|
||||
const ColoredBox box = ColoredBox(color: colorToPaint);
|
||||
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
|
||||
box.debugFillProperties(properties);
|
||||
@@ -742,7 +743,7 @@ void main() {
|
||||
expect(properties.properties.first.value, colorToPaint);
|
||||
});
|
||||
});
|
||||
testWidgets('Inconsequential golden test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Inconsequential golden test', (WidgetTester tester) async {
|
||||
// The test validates the Flutter Gold integration. Any changes to the
|
||||
// golden file can be approved at any time.
|
||||
await tester.pumpWidget(RepaintBoundary(
|
||||
@@ -758,7 +759,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('IgnorePointer ignores pointers', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('IgnorePointer ignores pointers', (WidgetTester tester) async {
|
||||
final List<String> logs = <String>[];
|
||||
Widget target({required bool ignoring}) => Align(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -836,7 +837,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('IgnorePointer semantics', () {
|
||||
testWidgets('does not change semantics when not ignoring', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('does not change semantics when not ignoring', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -863,7 +864,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('can toggle the ignoring.', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('can toggle the ignoring.', (WidgetTester tester) async {
|
||||
final UniqueKey key1 = UniqueKey();
|
||||
final UniqueKey key2 = UniqueKey();
|
||||
final UniqueKey key3 = UniqueKey();
|
||||
@@ -982,7 +983,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('drops semantics when its ignoringSemantics is true', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drops semantics when its ignoringSemantics is true', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
@@ -1001,7 +1002,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('ignores user interactions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ignores user interactions', (WidgetTester tester) async {
|
||||
final UniqueKey key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
@@ -1028,7 +1029,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('AbsorbPointer absorbs pointers', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AbsorbPointer absorbs pointers', (WidgetTester tester) async {
|
||||
final List<String> logs = <String>[];
|
||||
Widget target({required bool absorbing}) => Align(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -1105,7 +1106,7 @@ void main() {
|
||||
logs.clear();
|
||||
});
|
||||
|
||||
testWidgets('Wrap implements debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Wrap implements debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
const Wrap(
|
||||
spacing: 8.0, // gap between adjacent Text widget
|
||||
@@ -1136,7 +1137,7 @@ void main() {
|
||||
]));
|
||||
});
|
||||
|
||||
testWidgets('Row and IgnoreBaseline (control -- with baseline)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Row and IgnoreBaseline (control -- with baseline)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
@@ -1163,7 +1164,7 @@ void main() {
|
||||
expect(bPos.dy, 96.0 - 24.0);
|
||||
});
|
||||
|
||||
testWidgets('Row and IgnoreBaseline (with ignored baseline)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Row and IgnoreBaseline (with ignored baseline)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||
|
||||
@@ -8,12 +8,13 @@ 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';
|
||||
|
||||
const String _actualContent = 'Actual Content';
|
||||
const String _loading = 'Loading...';
|
||||
|
||||
void main() {
|
||||
testWidgets('deferFirstFrame/allowFirstFrame stops sending frames to engine', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('deferFirstFrame/allowFirstFrame stops sending frames to engine', (WidgetTester tester) async {
|
||||
expect(RendererBinding.instance.sendFramesToEngine, isTrue);
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
@@ -50,7 +51,7 @@ void main() {
|
||||
expect(RendererBinding.instance.sendFramesToEngine, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Two widgets can defer frames', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Two widgets can defer frames', (WidgetTester tester) async {
|
||||
expect(RendererBinding.instance.sendFramesToEngine, isTrue);
|
||||
|
||||
final Completer<void> completer1 = Completer<void>();
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
class MemoryPressureObserver with WidgetsBindingObserver {
|
||||
bool sawMemoryPressure = false;
|
||||
@@ -143,7 +144,7 @@ void main() {
|
||||
.handlePlatformMessage('flutter/lifecycle', message, (_) { });
|
||||
}
|
||||
|
||||
testWidgets('Rentrant observer callbacks do not result in exceptions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Rentrant observer callbacks do not result in exceptions', (WidgetTester tester) async {
|
||||
final RentrantObserver observer = RentrantObserver();
|
||||
WidgetsBinding.instance.handleAccessibilityFeaturesChanged();
|
||||
WidgetsBinding.instance.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
||||
@@ -160,7 +161,7 @@ void main() {
|
||||
expect(observer.removeSelf(), 0);
|
||||
});
|
||||
|
||||
testWidgets('didHaveMemoryPressure callback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didHaveMemoryPressure callback', (WidgetTester tester) async {
|
||||
final MemoryPressureObserver observer = MemoryPressureObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
final ByteData message = const JSONMessageCodec().encodeMessage(<String, dynamic>{'type': 'memoryPressure'})!;
|
||||
@@ -169,7 +170,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('handleLifecycleStateChanged callback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('handleLifecycleStateChanged callback', (WidgetTester tester) async {
|
||||
final AppLifecycleStateObserver observer = AppLifecycleStateObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -228,7 +229,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRoute callback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRoute callback', (WidgetTester tester) async {
|
||||
final PushRouteObserver observer = PushRouteObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -240,7 +241,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRouteInformation calls didPushRoute by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRouteInformation calls didPushRoute by default', (WidgetTester tester) async {
|
||||
final PushRouteObserver observer = PushRouteObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -258,7 +259,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRouteInformation calls didPushRoute correctly when handling url', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRouteInformation calls didPushRoute correctly when handling url', (WidgetTester tester) async {
|
||||
final PushRouteObserver observer = PushRouteObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -290,7 +291,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRouteInformation callback', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRouteInformation callback', (WidgetTester tester) async {
|
||||
final PushRouteInformationObserver observer = PushRouteInformationObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -307,7 +308,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRouteInformation callback can handle url', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRouteInformation callback can handle url', (WidgetTester tester) async {
|
||||
final PushRouteInformationObserver observer = PushRouteInformationObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -325,7 +326,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('didPushRouteInformation callback with null state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('didPushRouteInformation callback with null state', (WidgetTester tester) async {
|
||||
final PushRouteInformationObserver observer = PushRouteInformationObserver();
|
||||
WidgetsBinding.instance.addObserver(observer);
|
||||
|
||||
@@ -343,7 +344,7 @@ void main() {
|
||||
WidgetsBinding.instance.removeObserver(observer);
|
||||
});
|
||||
|
||||
testWidgets('Application lifecycle affects frame scheduling', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Application lifecycle affects frame scheduling', (WidgetTester tester) async {
|
||||
expect(tester.binding.hasScheduledFrame, isFalse);
|
||||
|
||||
await setAppLifeCycleState(AppLifecycleState.paused);
|
||||
@@ -397,7 +398,7 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('scheduleFrameCallback error control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('scheduleFrameCallback error control test', (WidgetTester tester) async {
|
||||
late FlutterError error;
|
||||
try {
|
||||
tester.binding.scheduleFrameCallback((Duration _) { }, rescheduling: true);
|
||||
@@ -429,7 +430,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('defaultStackFilter elides framework Element mounting stacks', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('defaultStackFilter elides framework Element mounting stacks', (WidgetTester tester) async {
|
||||
final FlutterExceptionHandler? oldHandler = FlutterError.onError;
|
||||
late FlutterErrorDetails errorDetails;
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'dart:ui' as ui show Image;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import '../image_data.dart';
|
||||
|
||||
@@ -36,7 +37,7 @@ Future<void> main() async {
|
||||
AutomatedTestWidgetsFlutterBinding();
|
||||
TestImageProvider.image = await decodeImageFromList(Uint8List.fromList(kTransparentImage));
|
||||
|
||||
testWidgets('DecoratedBox handles loading images', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedBox handles loading images', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final Completer<void> completer = Completer<void>();
|
||||
await tester.pumpWidget(
|
||||
@@ -59,7 +60,7 @@ Future<void> main() async {
|
||||
expect(tester.binding.hasScheduledFrame, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Moving a DecoratedBox', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Moving a DecoratedBox', (WidgetTester tester) async {
|
||||
final Completer<void> completer = Completer<void>();
|
||||
final Widget subtree = KeyedSubtree(
|
||||
key: GlobalKey(),
|
||||
@@ -88,7 +89,7 @@ Future<void> main() async {
|
||||
expect(tester.binding.hasScheduledFrame, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Circles can have uniform borders', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Circles can have uniform borders', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
padding: const EdgeInsets.all(50.0),
|
||||
@@ -101,7 +102,7 @@ Future<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Bordered Container insets its child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Bordered Container insets its child', (WidgetTester tester) async {
|
||||
const Key key = Key('outerContainer');
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
@@ -118,7 +119,7 @@ Future<void> main() async {
|
||||
expect(tester.getSize(find.byKey(key)), equals(const Size(45.0, 45.0)));
|
||||
});
|
||||
|
||||
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('BoxDecoration paints its border correctly', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/7672
|
||||
|
||||
const Key key = Key('Container with BoxDecoration');
|
||||
@@ -169,7 +170,7 @@ Future<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('BoxDecoration paints its border correctly', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/12165
|
||||
await tester.pumpWidget(
|
||||
Column(
|
||||
@@ -254,7 +255,7 @@ Future<void> main() async {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Can hit test on BoxDecoration', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can hit test on BoxDecoration', (WidgetTester tester) async {
|
||||
|
||||
late List<int> itemsTapped;
|
||||
|
||||
@@ -291,7 +292,7 @@ Future<void> main() async {
|
||||
|
||||
});
|
||||
|
||||
testWidgets('Can hit test on BoxDecoration circle', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can hit test on BoxDecoration circle', (WidgetTester tester) async {
|
||||
|
||||
late List<int> itemsTapped;
|
||||
|
||||
@@ -331,7 +332,7 @@ Future<void> main() async {
|
||||
|
||||
});
|
||||
|
||||
testWidgets('Can hit test on BoxDecoration border', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can hit test on BoxDecoration border', (WidgetTester tester) async {
|
||||
late List<int> itemsTapped;
|
||||
const Key key = Key('Container with BoxDecoration');
|
||||
Widget buildFrame(Border border) {
|
||||
@@ -369,7 +370,7 @@ Future<void> main() async {
|
||||
expect(itemsTapped, <int>[1,1]);
|
||||
});
|
||||
|
||||
testWidgets('BoxDecoration not tap outside rounded angles - Top Left', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('BoxDecoration not tap outside rounded angles - Top Left', (WidgetTester tester) async {
|
||||
const double height = 50.0;
|
||||
const double width = 50.0;
|
||||
const double radius = 12.3;
|
||||
@@ -429,7 +430,7 @@ Future<void> main() async {
|
||||
|
||||
});
|
||||
|
||||
testWidgets('BoxDecoration tap inside rounded angles - Top Left', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('BoxDecoration tap inside rounded angles - Top Left', (WidgetTester tester) async {
|
||||
const double height = 50.0;
|
||||
const double width = 50.0;
|
||||
const double radius = 12.3;
|
||||
@@ -477,7 +478,7 @@ Future<void> main() async {
|
||||
expect(itemsTapped, <int>[1,1,1,1]);
|
||||
});
|
||||
|
||||
testWidgets('BoxDecoration rounded angles other corner works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('BoxDecoration rounded angles other corner works', (WidgetTester tester) async {
|
||||
const double height = 50.0;
|
||||
const double width = 50.0;
|
||||
const double radius = 20;
|
||||
@@ -545,7 +546,7 @@ Future<void> main() async {
|
||||
expect(itemsTapped, <int>[1,1,1,1,1], reason: 'top left tapped');
|
||||
});
|
||||
|
||||
testWidgets("BoxDecoration doesn't crash with BorderRadiusDirectional", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("BoxDecoration doesn't crash with BorderRadiusDirectional", (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/88039
|
||||
|
||||
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('StatefulWidget BuildContext.mounted', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('StatefulWidget BuildContext.mounted', (WidgetTester tester) async {
|
||||
late BuildContext capturedContext;
|
||||
await tester.pumpWidget(TestStatefulWidget(
|
||||
onBuild: (BuildContext context) {
|
||||
@@ -18,7 +19,7 @@ void main() {
|
||||
expect(capturedContext.mounted, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('StatelessWidget BuildContext.mounted', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('StatelessWidget BuildContext.mounted', (WidgetTester tester) async {
|
||||
late BuildContext capturedContext;
|
||||
await tester.pumpWidget(TestStatelessWidget(
|
||||
onBuild: (BuildContext context) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
import 'test_widgets.dart';
|
||||
|
||||
@@ -133,7 +134,7 @@ class Wrapper extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Legal times for setState', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Legal times for setState', (WidgetTester tester) async {
|
||||
final GlobalKey flipKey = GlobalKey();
|
||||
expect(ProbeWidgetState.buildCount, equals(0));
|
||||
await tester.pumpWidget(const ProbeWidget(key: Key('a')));
|
||||
@@ -171,7 +172,7 @@ void main() {
|
||||
expect(tester.takeException(), isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('Dirty element list sort order', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dirty element list sort order', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey(debugLabel: 'key1');
|
||||
final GlobalKey key2 = GlobalKey(debugLabel: 'key2');
|
||||
|
||||
|
||||
@@ -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('Can be placed in an infinite box', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can be placed in an infinite box', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
||||
@@ -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';
|
||||
|
||||
// Assuming that the test container is 800x600. The height of the
|
||||
// viewport's contents is 650.0, the top and bottom text children
|
||||
@@ -32,7 +33,7 @@ Widget buildFrame(ScrollPhysics physics, { ScrollController? scrollController })
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('ClampingScrollPhysics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClampingScrollPhysics', (WidgetTester tester) async {
|
||||
|
||||
// Scroll the target text widget by offset and then return its origin
|
||||
// in global coordinates.
|
||||
@@ -59,7 +60,7 @@ void main() {
|
||||
expect(origin.dy, equals(500.0));
|
||||
});
|
||||
|
||||
testWidgets('ClampingScrollPhysics affects ScrollPosition', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClampingScrollPhysics affects ScrollPosition', (WidgetTester tester) async {
|
||||
|
||||
// BouncingScrollPhysics
|
||||
|
||||
@@ -91,9 +92,10 @@ void main() {
|
||||
expect(scrollable.position.pixels, equals(50.0));
|
||||
});
|
||||
|
||||
testWidgets('ClampingScrollPhysics handles out of bounds ScrollPosition', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClampingScrollPhysics handles out of bounds ScrollPosition', (WidgetTester tester) async {
|
||||
Future<void> testOutOfBounds(ScrollPhysics physics, double initialOffset, double expectedOffset) async {
|
||||
final ScrollController scrollController = ScrollController(initialScrollOffset: initialOffset);
|
||||
addTearDown(scrollController.dispose);
|
||||
await tester.pumpWidget(buildFrame(physics, scrollController: scrollController));
|
||||
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ 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';
|
||||
|
||||
import 'test_border.dart' show TestBorder;
|
||||
|
||||
@@ -58,7 +59,7 @@ class NotifyClipper<T> extends CustomClipper<T> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('ClipRect with a FittedBox child sized to zero works with semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRect with a FittedBox child sized to zero works with semantics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: ClipRect(
|
||||
@@ -77,7 +78,7 @@ void main() {
|
||||
expect(find.byType(FittedBox), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('ClipRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ClipRect());
|
||||
|
||||
final RenderClipRect renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first;
|
||||
@@ -99,7 +100,7 @@ void main() {
|
||||
expect(clipRRect.borderRadius, equals(BorderRadius.zero));
|
||||
});
|
||||
|
||||
testWidgets('ClipRRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRRect updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ClipRRect());
|
||||
|
||||
final RenderClipRRect renderClip = tester.allRenderObjects.whereType<RenderClipRRect>().first;
|
||||
@@ -115,7 +116,7 @@ void main() {
|
||||
expect(renderClip.clipBehavior, equals(Clip.none));
|
||||
});
|
||||
|
||||
testWidgets('ClipOval updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipOval updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ClipOval());
|
||||
|
||||
final RenderClipOval renderClip = tester.allRenderObjects.whereType<RenderClipOval>().first;
|
||||
@@ -131,7 +132,7 @@ void main() {
|
||||
expect(renderClip.clipBehavior, equals(Clip.none));
|
||||
});
|
||||
|
||||
testWidgets('ClipPath updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipPath updates clipBehavior in updateRenderObject', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ClipPath());
|
||||
|
||||
final RenderClipPath renderClip = tester.allRenderObjects.whereType<RenderClipPath>().first;
|
||||
@@ -147,7 +148,7 @@ void main() {
|
||||
expect(renderClip.clipBehavior, equals(Clip.none));
|
||||
});
|
||||
|
||||
testWidgets('ClipPath', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipPath', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ClipPath(
|
||||
clipper: PathClipper(),
|
||||
@@ -168,7 +169,7 @@ void main() {
|
||||
log.clear();
|
||||
});
|
||||
|
||||
testWidgets('ClipOval', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipOval', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ClipOval(
|
||||
child: GestureDetector(
|
||||
@@ -188,7 +189,7 @@ void main() {
|
||||
log.clear();
|
||||
});
|
||||
|
||||
testWidgets('Transparent ClipOval hit test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Transparent ClipOval hit test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Opacity(
|
||||
opacity: 0.0,
|
||||
@@ -211,7 +212,7 @@ void main() {
|
||||
log.clear();
|
||||
});
|
||||
|
||||
testWidgets('ClipRect', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRect', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -334,7 +335,7 @@ void main() {
|
||||
log.clear();
|
||||
});
|
||||
|
||||
testWidgets('debugPaintSizeEnabled', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugPaintSizeEnabled', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const ClipRect(
|
||||
child: Placeholder(),
|
||||
@@ -356,7 +357,7 @@ void main() {
|
||||
debugPaintSizeEnabled = false;
|
||||
});
|
||||
|
||||
testWidgets('ClipRect painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRect painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -399,7 +400,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
RepaintBoundary(
|
||||
child: Stack(
|
||||
@@ -438,7 +439,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipRRect painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRRect painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -487,7 +488,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipOval painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipOval painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -530,7 +531,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipPath painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipPath painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -615,7 +616,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('PhysicalModel painting with Clip.antiAlias', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalModel painting with Clip.antiAlias', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalModel(Clip.antiAlias));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -623,7 +624,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('PhysicalModel painting with Clip.hardEdge', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalModel painting with Clip.hardEdge', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalModel(Clip.hardEdge));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -633,7 +634,7 @@ void main() {
|
||||
|
||||
// There will be bleeding edges on the rect edges, but there shouldn't be any bleeding edges on the
|
||||
// round corners.
|
||||
testWidgets('PhysicalModel painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalModel painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalModel(Clip.antiAliasWithSaveLayer));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -641,7 +642,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Default PhysicalModel painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Default PhysicalModel painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -724,7 +725,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('PhysicalShape painting with Clip.antiAlias', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalShape painting with Clip.antiAlias', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalShape(Clip.antiAlias));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -732,7 +733,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('PhysicalShape painting with Clip.hardEdge', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalShape painting with Clip.hardEdge', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalShape(Clip.hardEdge));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -740,7 +741,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('PhysicalShape painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalShape painting with Clip.antiAliasWithSaveLayer', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer));
|
||||
await expectLater(
|
||||
find.byType(RepaintBoundary).first,
|
||||
@@ -748,7 +749,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('PhysicalShape painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('PhysicalShape painting', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
@@ -794,7 +795,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipPath.shape', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipPath.shape', (WidgetTester tester) async {
|
||||
final List<String> logs = <String>[];
|
||||
final ShapeBorder shape = TestBorder((String message) { logs.add(message); });
|
||||
Widget buildClipPath() {
|
||||
@@ -851,8 +852,9 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
testWidgets('CustomClipper reclips when notified', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomClipper reclips when notified', (WidgetTester tester) async {
|
||||
final ValueNotifier<Rect> clip = ValueNotifier<Rect>(const Rect.fromLTWH(50.0, 50.0, 100.0, 100.0));
|
||||
addTearDown(clip.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ClipRect(
|
||||
@@ -884,7 +886,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('ClipRRect supports BorderRadiusDirectional', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRRect supports BorderRadiusDirectional', (WidgetTester tester) async {
|
||||
const Radius startRadius = Radius.circular(15.0);
|
||||
const Radius endRadius = Radius.circular(30.0);
|
||||
|
||||
@@ -911,7 +913,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('ClipRRect is direction-aware', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ClipRRect is direction-aware', (WidgetTester tester) async {
|
||||
const Radius startRadius = Radius.circular(15.0);
|
||||
const Radius endRadius = Radius.circular(30.0);
|
||||
TextDirection textDirection = TextDirection.ltr;
|
||||
|
||||
@@ -11,9 +11,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('Color filter - red', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Color filter - red', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const RepaintBoundary(
|
||||
child: ColorFiltered(
|
||||
@@ -28,7 +29,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Color filter - sepia', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Color filter - sepia', (WidgetTester tester) async {
|
||||
const ColorFilter sepia = ColorFilter.matrix(<double>[
|
||||
0.39, 0.769, 0.189, 0, 0, //
|
||||
0.349, 0.686, 0.168, 0, 0, //
|
||||
@@ -65,7 +66,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Color filter - reuses its layer', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Color filter - reuses its layer', (WidgetTester tester) async {
|
||||
Future<void> pumpWithColor(Color color) async {
|
||||
await tester.pumpWidget(
|
||||
RepaintBoundary(
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
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() {
|
||||
// DOWN (default)
|
||||
|
||||
testWidgets('Column with one flexible child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -55,7 +56,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(500.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with default main axis parameters', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -101,7 +102,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(200.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -139,7 +140,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(300.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -185,7 +186,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(500.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -231,7 +232,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(500.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -285,7 +286,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(475.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -331,7 +332,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(445.0));
|
||||
});
|
||||
|
||||
testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
|
||||
const Key flexKey = Key('flexKey');
|
||||
|
||||
// Default is MainAxisSize.max so the Column should be as high as the test: 600.
|
||||
@@ -364,7 +365,7 @@ void main() {
|
||||
expect(renderBox.size.height, equals(250.0));
|
||||
});
|
||||
|
||||
testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
|
||||
await tester.pumpWidget(const Center(
|
||||
@@ -390,7 +391,7 @@ void main() {
|
||||
|
||||
// UP
|
||||
|
||||
testWidgets('Column with one flexible child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with one flexible child', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -437,7 +438,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(0.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with default main axis parameters', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with default main axis parameters', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -484,7 +485,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(300.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.center', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -523,7 +524,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(200.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.end', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.end', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -570,7 +571,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(0.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceBetween', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -617,7 +618,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(0.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceAround', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -672,7 +673,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(500.0 - 475.0));
|
||||
});
|
||||
|
||||
testWidgets('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column with MainAxisAlignment.spaceEvenly', (WidgetTester tester) async {
|
||||
const Key columnKey = Key('column');
|
||||
const Key child0Key = Key('child0');
|
||||
const Key child1Key = Key('child1');
|
||||
@@ -719,7 +720,7 @@ void main() {
|
||||
expect(boxParentData.offset.dy, equals(600.0 - 445.0 - 20.0));
|
||||
});
|
||||
|
||||
testWidgets('Column and MainAxisSize.min', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column and MainAxisSize.min', (WidgetTester tester) async {
|
||||
const Key flexKey = Key('flexKey');
|
||||
|
||||
// Default is MainAxisSize.max so the Column should be as high as the test: 600.
|
||||
@@ -754,7 +755,7 @@ void main() {
|
||||
expect(renderBox.size.height, equals(250.0));
|
||||
});
|
||||
|
||||
testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
|
||||
await tester.pumpWidget(const Center(
|
||||
|
||||
@@ -7,11 +7,12 @@ import 'dart:ui' as ui;
|
||||
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() {
|
||||
final LayerLink link = LayerLink();
|
||||
|
||||
testWidgets('Change link during layout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Change link during layout', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
Widget build({ LayerLink? linkToUse }) {
|
||||
return Directionality(
|
||||
@@ -56,7 +57,7 @@ void main() {
|
||||
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
|
||||
});
|
||||
|
||||
testWidgets('LeaderLayer should not cause error', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('LeaderLayer should not cause error', (WidgetTester tester) async {
|
||||
final LayerLink link = LayerLink();
|
||||
|
||||
Widget buildWidget({
|
||||
@@ -116,19 +117,19 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('topLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
|
||||
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
|
||||
expect(box.localToGlobal(Offset.zero), const Offset(123.0, 456.0));
|
||||
});
|
||||
|
||||
testWidgets('center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
|
||||
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
|
||||
expect(box.localToGlobal(Offset.zero), const Offset(118.0, 451.0));
|
||||
});
|
||||
|
||||
testWidgets('bottomRight - topRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
|
||||
final RenderBox box = key.currentContext!.findRenderObject()! as RenderBox;
|
||||
expect(box.localToGlobal(Offset.zero), const Offset(113.0, 466.0));
|
||||
@@ -172,7 +173,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
}
|
||||
testWidgets('topLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -181,7 +182,7 @@ void main() {
|
||||
expect(position1, offsetMoreOrLessEquals(position2));
|
||||
});
|
||||
|
||||
testWidgets('center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -190,7 +191,7 @@ void main() {
|
||||
expect(position1, offsetMoreOrLessEquals(position2));
|
||||
});
|
||||
|
||||
testWidgets('bottomRight - topRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -249,7 +250,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
}
|
||||
testWidgets('topLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('topLeft', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.topLeft, followerAlignment: Alignment.topLeft));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -258,7 +259,7 @@ void main() {
|
||||
expect(position1, offsetMoreOrLessEquals(position2));
|
||||
});
|
||||
|
||||
testWidgets('center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('center', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.center, followerAlignment: Alignment.center));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -267,7 +268,7 @@ void main() {
|
||||
expect(position1, offsetMoreOrLessEquals(position2));
|
||||
});
|
||||
|
||||
testWidgets('bottomRight - topRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('bottomRight - topRight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(build(targetAlignment: Alignment.bottomRight, followerAlignment: Alignment.topRight));
|
||||
final RenderBox box1 = key1.currentContext!.findRenderObject()! as RenderBox;
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
@@ -321,7 +322,7 @@ void main() {
|
||||
|
||||
for (final Alignment targetAlignment in alignments) {
|
||||
for (final Alignment followerAlignment in alignments) {
|
||||
testWidgets('$targetAlignment - $followerAlignment', (WidgetTester tester) async{
|
||||
testWidgetsWithLeakTracking('$targetAlignment - $followerAlignment', (WidgetTester tester) async{
|
||||
await tester.pumpWidget(build(targetAlignment: targetAlignment, followerAlignment: followerAlignment));
|
||||
final RenderBox box2 = key2.currentContext!.findRenderObject()! as RenderBox;
|
||||
expect(box2.size, const Size(2.0, 2.0));
|
||||
@@ -333,7 +334,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Leader after Follower asserts', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Leader after Follower asserts', (WidgetTester tester) async {
|
||||
final LayerLink link = LayerLink();
|
||||
await tester.pumpWidget(
|
||||
CompositedTransformFollower(
|
||||
@@ -351,7 +352,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'`FollowerLayer` (`CompositedTransformFollower`) has null pointer error when using with some kinds of `Layer`s',
|
||||
(WidgetTester tester) async {
|
||||
final LayerLink link = LayerLink();
|
||||
|
||||
@@ -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('Placeholder intrinsics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Placeholder intrinsics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Placeholder());
|
||||
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMinIntrinsicWidth(double.infinity), 0.0);
|
||||
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicWidth(double.infinity), 0.0);
|
||||
@@ -14,7 +15,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(Placeholder)).getMaxIntrinsicHeight(double.infinity), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - minHeight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minHeight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -29,7 +30,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - minWidth', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minWidth', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -44,7 +45,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - maxHeight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - maxHeight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -59,7 +60,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - maxWidth', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - maxWidth', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -74,7 +75,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - tight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - tight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints.tightFor(width: 10.0, height: 30.0),
|
||||
@@ -88,7 +89,7 @@ void main() {
|
||||
});
|
||||
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - minHeight - with infinite width', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minHeight - with infinite width', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -104,7 +105,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 20.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - minWidth - with infinite height', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - minWidth - with infinite height', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
@@ -120,7 +121,7 @@ void main() {
|
||||
expect(tester.renderObject<RenderBox>(find.byType(ConstrainedBox)).getMaxIntrinsicHeight(double.infinity), 0.0);
|
||||
});
|
||||
|
||||
testWidgets('ConstrainedBox intrinsics - infinite', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ConstrainedBox intrinsics - infinite', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints.tightFor(width: double.infinity, height: double.infinity),
|
||||
|
||||
@@ -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';
|
||||
|
||||
void main() {
|
||||
group('Container control tests:', () {
|
||||
@@ -37,7 +38,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('paints as expected', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('paints as expected', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -54,7 +55,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('diagnostics', () {
|
||||
testWidgets('has reasonable default diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has reasonable default diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -66,7 +67,7 @@ void main() {
|
||||
expect(box, hasAGoodToStringDeep);
|
||||
});
|
||||
|
||||
testWidgets('has expected info diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has expected info diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -138,7 +139,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('has expected debug diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has expected debug diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -243,7 +244,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('has expected fine diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has expected fine diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -376,7 +377,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('has expected hidden diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('has expected hidden diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -533,7 +534,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('painting error has expected diagnostics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('painting error has expected diagnostics', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: container,
|
||||
@@ -564,7 +565,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Can be placed in an infinite box', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can be placed in an infinite box', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -573,7 +574,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Container transformAlignment', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Container transformAlignment', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -620,7 +621,7 @@ void main() {
|
||||
expect(tester.getBottomRight(finder), equals(const Offset(200, 200)));
|
||||
});
|
||||
|
||||
testWidgets('giving clipBehaviour Clip.None, will not add a ClipPath to the tree', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('giving clipBehaviour Clip.None, will not add a ClipPath to the tree', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
@@ -635,7 +636,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('giving clipBehaviour not a Clip.None, will add a ClipPath to the tree', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('giving clipBehaviour not a Clip.None, will add a ClipPath to the tree', (WidgetTester tester) async {
|
||||
final Container container = Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(
|
||||
@@ -652,7 +653,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('getClipPath() works for lots of kinds of decorations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('getClipPath() works for lots of kinds of decorations', (WidgetTester tester) async {
|
||||
Future<void> test(Decoration decoration) async {
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
@@ -682,7 +683,7 @@ void main() {
|
||||
await test(const FlutterLogoDecoration());
|
||||
});
|
||||
|
||||
testWidgets('Container is hittable only when having decorations', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Container is hittable only when having decorations', (WidgetTester tester) async {
|
||||
bool tapped = false;
|
||||
await tester.pumpWidget(GestureDetector(
|
||||
onTap: () { tapped = true; },
|
||||
@@ -736,7 +737,7 @@ void main() {
|
||||
expect(tapped, false);
|
||||
});
|
||||
|
||||
testWidgets('Container discards alignment when the child parameter is null and constraints is not Tight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Container discards alignment when the child parameter is null and constraints is not Tight', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
@@ -751,7 +752,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('using clipBehaviour and shadow, should not clip the shadow', (WidgetTester tester) async {
|
||||
final Container container = Container(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import 'clipboard_utils.dart';
|
||||
import 'editable_text_utils.dart';
|
||||
@@ -20,7 +21,7 @@ void main() {
|
||||
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
|
||||
});
|
||||
|
||||
testWidgets('Hides and shows only a single menu', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Hides and shows only a single menu', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
final GlobalKey key2 = GlobalKey();
|
||||
late final BuildContext context;
|
||||
@@ -90,7 +91,7 @@ void main() {
|
||||
expect(find.byKey(key2), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('A menu can be hidden and then reshown', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('A menu can be hidden and then reshown', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
late final BuildContext context;
|
||||
|
||||
@@ -141,7 +142,7 @@ void main() {
|
||||
expect(find.byKey(key1), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('markNeedsBuild causes the builder to update', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('markNeedsBuild causes the builder to update', (WidgetTester tester) async {
|
||||
int buildCount = 0;
|
||||
late final BuildContext context;
|
||||
|
||||
@@ -178,7 +179,7 @@ void main() {
|
||||
controller.remove();
|
||||
});
|
||||
|
||||
testWidgets('Calling show when a built-in widget is already showing its context menu hides the built-in menu', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Calling show when a built-in widget is already showing its context menu hides the built-in menu', (WidgetTester tester) async {
|
||||
final GlobalKey builtInKey = GlobalKey();
|
||||
final GlobalKey directKey = GlobalKey();
|
||||
late final BuildContext context;
|
||||
|
||||
@@ -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('Comparing coordinates', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Comparing coordinates', (WidgetTester tester) async {
|
||||
final Key keyA = GlobalKey();
|
||||
final Key keyB = GlobalKey();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.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';
|
||||
|
||||
class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate {
|
||||
late BoxConstraints getSizeConstraints;
|
||||
@@ -163,7 +164,7 @@ class LayoutWithMissingId extends ParentDataWidget<MultiChildLayoutParentData> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Control test for CustomMultiChildLayout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Control test for CustomMultiChildLayout', (WidgetTester tester) async {
|
||||
final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
|
||||
await tester.pumpWidget(buildFrame(delegate));
|
||||
|
||||
@@ -181,7 +182,7 @@ void main() {
|
||||
expect(delegate.performLayoutIsChild, false);
|
||||
});
|
||||
|
||||
testWidgets('Test MultiChildDelegate shouldRelayout method', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Test MultiChildDelegate shouldRelayout method', (WidgetTester tester) async {
|
||||
TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
|
||||
await tester.pumpWidget(buildFrame(delegate));
|
||||
|
||||
@@ -204,7 +205,7 @@ void main() {
|
||||
expect(delegate.performLayoutSize, isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('Nested CustomMultiChildLayouts', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Nested CustomMultiChildLayouts', (WidgetTester tester) async {
|
||||
final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate();
|
||||
await tester.pumpWidget(Center(
|
||||
child: CustomMultiChildLayout(
|
||||
@@ -227,7 +228,7 @@ void main() {
|
||||
|
||||
});
|
||||
|
||||
testWidgets('Loose constraints', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Loose constraints', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
await tester.pumpWidget(Center(
|
||||
child: CustomMultiChildLayout(
|
||||
@@ -251,8 +252,9 @@ void main() {
|
||||
expect(box.size.height, equals(250.0));
|
||||
});
|
||||
|
||||
testWidgets('Can use listener for relayout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can use listener for relayout', (WidgetTester tester) async {
|
||||
final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0));
|
||||
addTearDown(size.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
@@ -302,7 +304,7 @@ void main() {
|
||||
expect((errors.first.exception as FlutterError).toStringDeep(), equalsIgnoringHashCodes(message));
|
||||
}
|
||||
|
||||
testWidgets('layoutChild on non existent child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('layoutChild on non existent child', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
tester: tester,
|
||||
delegate: ZeroAndOneIdLayoutDelegate(),
|
||||
@@ -314,7 +316,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('layoutChild more than once', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('layoutChild more than once', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
tester: tester,
|
||||
delegate: DuplicateLayoutDelegate(),
|
||||
@@ -326,7 +328,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('layoutChild on invalid size constraint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('layoutChild on invalid size constraint', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
tester: tester,
|
||||
delegate: InvalidConstraintsChildLayoutDelegate(),
|
||||
@@ -345,7 +347,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('positionChild on non existent child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positionChild on non existent child', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
tester: tester,
|
||||
delegate: NonExistentPositionDelegate(),
|
||||
@@ -357,7 +359,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets("_callPerformLayout on child that doesn't have id", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("_callPerformLayout on child that doesn't have id", (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
widget: Center(
|
||||
child: CustomMultiChildLayout(
|
||||
@@ -383,7 +385,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('performLayout did not layout a child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('performLayout did not layout a child', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
widget: Center(
|
||||
child: CustomMultiChildLayout(
|
||||
@@ -405,7 +407,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('performLayout did not layout multiple child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('performLayout did not layout multiple child', (WidgetTester tester) async {
|
||||
await expectFlutterErrorMessage(
|
||||
widget: Center(
|
||||
child: CustomMultiChildLayout(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
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';
|
||||
|
||||
class TestCustomPainter extends CustomPainter {
|
||||
TestCustomPainter({ required this.log, this.name });
|
||||
@@ -40,7 +41,7 @@ class MockPaintingContext extends Fake implements PaintingContext {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Control test for custom painting', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Control test for custom painting', (WidgetTester tester) async {
|
||||
final List<String?> log = <String?>[];
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
painter: TestCustomPainter(
|
||||
@@ -62,7 +63,7 @@ void main() {
|
||||
expect(log, equals(<String>['background', 'child', 'foreground']));
|
||||
});
|
||||
|
||||
testWidgets('Throws FlutterError on custom painter incorrect restore/save calls', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Throws FlutterError on custom painter incorrect restore/save calls', (WidgetTester tester) async {
|
||||
final GlobalKey target = GlobalKey();
|
||||
final List<String?> log = <String?>[];
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -118,7 +119,7 @@ void main() {
|
||||
expect(error.toStringDeep(), contains('2 more times'));
|
||||
});
|
||||
|
||||
testWidgets('CustomPaint sizing', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomPaint sizing', (WidgetTester tester) async {
|
||||
final GlobalKey target = GlobalKey();
|
||||
|
||||
await tester.pumpWidget(Center(
|
||||
@@ -153,7 +154,7 @@ void main() {
|
||||
|
||||
});
|
||||
|
||||
testWidgets('Raster cache hints', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Raster cache hints', (WidgetTester tester) async {
|
||||
final GlobalKey target = GlobalKey();
|
||||
|
||||
final List<String?> log = <String?>[];
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
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 'semantics_tester.dart';
|
||||
|
||||
@@ -22,7 +23,7 @@ void main() {
|
||||
}
|
||||
|
||||
void _defineTests() {
|
||||
testWidgets('builds no semantics by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('builds no semantics by default', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -36,7 +37,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('provides foreground semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('provides foreground semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -72,7 +73,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('provides background semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('provides background semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -108,7 +109,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('combines background, child and foreground semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('combines background, child and foreground semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -167,7 +168,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('applies $SemanticsProperties', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('applies $SemanticsProperties', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -270,7 +271,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Can toggle semantics on, off, on without crash', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can toggle semantics on, off, on without crash', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
painter: _PainterWithSemantics(
|
||||
semantics: const CustomPainterSemantics(
|
||||
@@ -312,7 +313,7 @@ void _defineTests() {
|
||||
semantics.dispose();
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('Supports all actions', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Supports all actions', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final List<SemanticsAction> performedActions = <SemanticsAction>[];
|
||||
|
||||
@@ -410,7 +411,7 @@ void _defineTests() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Supports all flags', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Supports all flags', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
// checked state and toggled state are mutually exclusive.
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
@@ -525,7 +526,7 @@ void _defineTests() {
|
||||
});
|
||||
|
||||
group('diffing', () {
|
||||
testWidgets('complains about duplicate keys', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('complains about duplicate keys', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
await tester.pumpWidget(CustomPaint(
|
||||
painter: _SemanticsDiffTest(<String>[
|
||||
@@ -622,7 +623,7 @@ void _defineTests() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('rebuilds semantics upon resize', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('rebuilds semantics upon resize', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
final _PainterWithSemantics painter = _PainterWithSemantics(
|
||||
@@ -667,7 +668,7 @@ void _defineTests() {
|
||||
semanticsTester.dispose();
|
||||
});
|
||||
|
||||
testWidgets('does not rebuild when shouldRebuildSemantics is false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('does not rebuild when shouldRebuildSemantics is false', (WidgetTester tester) async {
|
||||
final SemanticsTester semanticsTester = SemanticsTester(tester);
|
||||
|
||||
const CustomPainterSemantics testSemantics = CustomPainterSemantics(
|
||||
@@ -712,7 +713,7 @@ void _defineTests() {
|
||||
}
|
||||
|
||||
void _testDiff(String description, Future<void> Function(_DiffTester tester) testFunction) {
|
||||
testWidgets(description, (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking(description, (WidgetTester tester) async {
|
||||
await testFunction(_DiffTester(tester));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
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() {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/96024
|
||||
testWidgets('CustomScrollView.center update test 1', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomScrollView.center update test 1', (WidgetTester tester) async {
|
||||
final Key centerKey = UniqueKey();
|
||||
late StateSetter setState;
|
||||
bool hasKey = false;
|
||||
@@ -49,7 +50,7 @@ void main() {
|
||||
// Pass without throw.
|
||||
});
|
||||
|
||||
testWidgets('CustomScrollView.center update test 2', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomScrollView.center update test 2', (WidgetTester tester) async {
|
||||
const List<Widget> slivers1 = <Widget>[
|
||||
SliverToBoxAdapter(key: Key('a'), child: SizedBox(height: 100.0)),
|
||||
SliverToBoxAdapter(key: Key('b'), child: SizedBox(height: 100.0)),
|
||||
@@ -81,7 +82,7 @@ void main() {
|
||||
// Pass without throw.
|
||||
});
|
||||
|
||||
testWidgets('CustomScrollView.center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomScrollView.center', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: CustomScrollView(
|
||||
@@ -103,7 +104,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('CustomScrollView.center', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomScrollView.center', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: CustomScrollView(
|
||||
@@ -135,7 +136,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('CustomScrollView.anchor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CustomScrollView.anchor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: CustomScrollView(
|
||||
|
||||
@@ -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';
|
||||
|
||||
class TestSingleChildLayoutDelegate extends SingleChildLayoutDelegate {
|
||||
late BoxConstraints constraintsFromGetSize;
|
||||
@@ -93,7 +94,7 @@ Widget buildFrame(SingleChildLayoutDelegate delegate) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Control test for CustomSingleChildLayout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Control test for CustomSingleChildLayout', (WidgetTester tester) async {
|
||||
final TestSingleChildLayoutDelegate delegate = TestSingleChildLayoutDelegate();
|
||||
await tester.pumpWidget(buildFrame(delegate));
|
||||
|
||||
@@ -114,7 +115,7 @@ void main() {
|
||||
expect(delegate.childSizeFromGetPositionForChild.height, 400.0);
|
||||
});
|
||||
|
||||
testWidgets('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async {
|
||||
TestSingleChildLayoutDelegate delegate =
|
||||
TestSingleChildLayoutDelegate();
|
||||
await tester.pumpWidget(buildFrame(delegate));
|
||||
@@ -138,7 +139,7 @@ void main() {
|
||||
expect(delegate.constraintsFromGetConstraintsForChild, isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('Delegate can change size', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Delegate can change size', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildFrame(FixedSizeLayoutDelegate(const Size(100.0, 200.0))));
|
||||
|
||||
RenderBox box = tester.renderObject(find.byType(CustomSingleChildLayout));
|
||||
@@ -150,8 +151,9 @@ void main() {
|
||||
expect(box.size, equals(const Size(150.0, 240.0)));
|
||||
});
|
||||
|
||||
testWidgets('Can use listener for relayout', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can use listener for relayout', (WidgetTester tester) async {
|
||||
final ValueNotifier<Size> size = ValueNotifier<Size>(const Size(100.0, 200.0));
|
||||
addTearDown(size.dispose);
|
||||
|
||||
await tester.pumpWidget(buildFrame(NotifierLayoutDelegate(size)));
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:ui';
|
||||
import 'package:flutter/foundation.dart';
|
||||
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() {
|
||||
test('debugChildrenHaveDuplicateKeys control test', () {
|
||||
@@ -64,7 +65,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('debugCheckHasTable control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugCheckHasTable control test', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (BuildContext context) {
|
||||
@@ -95,7 +96,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('debugCheckHasMediaQuery control test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugCheckHasMediaQuery control test', (WidgetTester tester) async {
|
||||
// Cannot use tester.pumpWidget here because it wraps the widget in a View,
|
||||
// which introduces a MediaQuery ancestor.
|
||||
await pumpWidgetWithoutViewWrapper(
|
||||
@@ -231,7 +232,7 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('debugCheckHasWidgetsLocalizations throws', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugCheckHasWidgetsLocalizations throws', (WidgetTester tester) async {
|
||||
final GlobalKey noLocalizationsAvailable = GlobalKey();
|
||||
final GlobalKey localizationsAvailable = GlobalKey();
|
||||
|
||||
@@ -280,7 +281,7 @@ void main() {
|
||||
debugHighlightDeprecatedWidgets = false;
|
||||
});
|
||||
|
||||
testWidgets('debugCreator of layers should not be null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('debugCreator of layers should not be null', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Directionality(
|
||||
|
||||
@@ -9,9 +9,10 @@ library;
|
||||
|
||||
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('DecoratedSliver creates, paints, and disposes BoxPainter', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver creates, paints, and disposes BoxPainter', (WidgetTester tester) async {
|
||||
final TestDecoration decoration = TestDecoration();
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Scaffold(
|
||||
@@ -39,7 +40,7 @@ void main() {
|
||||
expect(decoration.painters.last.disposed, true);
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver can update box painter', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver can update box painter', (WidgetTester tester) async {
|
||||
final TestDecoration decorationA = TestDecoration();
|
||||
final TestDecoration decorationB = TestDecoration();
|
||||
|
||||
@@ -79,7 +80,7 @@ void main() {
|
||||
expect(decorationB.painters.last.paintCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver can update DecorationPosition', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver can update DecorationPosition', (WidgetTester tester) async {
|
||||
final TestDecoration decoration = TestDecoration();
|
||||
|
||||
DecorationPosition activePosition = DecorationPosition.foreground;
|
||||
@@ -117,7 +118,7 @@ void main() {
|
||||
expect(decoration.painters.last.paintCount, 2);
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver golden test', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver golden test', (WidgetTester tester) async {
|
||||
const BoxDecoration decoration = BoxDecoration(
|
||||
color: Colors.blue,
|
||||
);
|
||||
@@ -198,10 +199,11 @@ void main() {
|
||||
await expectLater(find.byKey(foregroundKey), matchesGoldenFile('decorated_sliver.moon.foreground.png'));
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver paints its border correctly vertically', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly vertically', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -234,10 +236,11 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver paints its border correctly vertically reverse', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly vertically reverse', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -273,10 +276,11 @@ void main() {
|
||||
|
||||
|
||||
|
||||
testWidgets('DecoratedSliver paints its border correctly horizontally', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly horizontally', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -310,10 +314,11 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver paints its border correctly horizontally reverse', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver paints its border correctly horizontally reverse', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -349,10 +354,11 @@ void main() {
|
||||
});
|
||||
|
||||
|
||||
testWidgets('DecoratedSliver works with SliverMainAxisGroup', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver works with SliverMainAxisGroup', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -387,10 +393,11 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver works with SliverCrossAxisGroup', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver works with SliverCrossAxisGroup', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
@@ -425,10 +432,11 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('DecoratedSliver draws only up to the bottom cache when sliver has infinite scroll extent', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DecoratedSliver draws only up to the bottom cache when sliver has infinite scroll extent', (WidgetTester tester) async {
|
||||
const Key key = Key('DecoratedSliver with border');
|
||||
const Color black = Color(0xFF000000);
|
||||
final ScrollController controller = ScrollController();
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: Align(
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
const double _crispText = 100.0; // this font size is selected to avoid needing any antialiasing.
|
||||
const String _expText = 'Éxp'; // renders in the test font as:
|
||||
@@ -19,7 +20,7 @@ const String _expText = 'Éxp'; // renders in the test font as:
|
||||
// ÉÉÉÉxxxxpppp
|
||||
|
||||
void main() {
|
||||
testWidgets('Default background', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Default background', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(_expText, textDirection: TextDirection.ltr, style: TextStyle(color: Color(0xFF345678), fontSize: _crispText))),
|
||||
@@ -40,7 +41,7 @@ void main() {
|
||||
);
|
||||
}, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently.
|
||||
|
||||
testWidgets('Default text color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Default text color', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const ColoredBox(
|
||||
color: Color(0xFFABCDEF),
|
||||
child: Align(
|
||||
@@ -65,8 +66,22 @@ void main() {
|
||||
);
|
||||
}, skip: !canCaptureImage); // [intended] Test relies on captureImage, which is not supported on web currently.
|
||||
|
||||
testWidgets('Default text selection color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Default text selection color', (WidgetTester tester) async {
|
||||
final GlobalKey key = GlobalKey();
|
||||
final FocusNode focusNode = FocusNode();
|
||||
addTearDown(focusNode.dispose);
|
||||
final OverlayEntry overlayEntry = OverlayEntry(
|
||||
builder: (BuildContext context) => SelectableRegion(
|
||||
focusNode: focusNode,
|
||||
selectionControls: emptyTextSelectionControls,
|
||||
child: Align(
|
||||
key: key,
|
||||
alignment: Alignment.topLeft,
|
||||
child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText, color: Color(0xFF000000))),
|
||||
),
|
||||
),
|
||||
);
|
||||
addTearDown(() => overlayEntry..remove()..dispose());
|
||||
await tester.pumpWidget(
|
||||
ColoredBox(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
@@ -75,19 +90,7 @@ void main() {
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Overlay(
|
||||
initialEntries: <OverlayEntry>[
|
||||
OverlayEntry(
|
||||
builder: (BuildContext context) => SelectableRegion(
|
||||
focusNode: FocusNode(),
|
||||
selectionControls: emptyTextSelectionControls,
|
||||
child: Align(
|
||||
key: key,
|
||||
alignment: Alignment.topLeft,
|
||||
child: const Text('Éxp', textDirection: TextDirection.ltr, style: TextStyle(fontSize: _crispText, color: Color(0xFF000000))),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
initialEntries: <OverlayEntry>[overlayEntry],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -132,6 +135,7 @@ Color _getPixel(ByteData bytes, int x, int y, int width) {
|
||||
Future<void> _expectColors(WidgetTester tester, Finder finder, Set<Color> allowedColors, [ Map<Offset, Color>? spotChecks ]) async {
|
||||
final TestWidgetsFlutterBinding binding = tester.binding;
|
||||
final ui.Image image = (await binding.runAsync<ui.Image>(() => captureImage(finder.evaluate().single)))!;
|
||||
addTearDown(image.dispose);
|
||||
final ByteData bytes = (await binding.runAsync<ByteData?>(() => image.toByteData(format: ui.ImageByteFormat.rawStraightRgba)))!;
|
||||
final Set<int> actualColorValues = <int>{};
|
||||
for (int offset = 0; offset < bytes.lengthInBytes; offset += 4) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
import 'keyboard_utils.dart';
|
||||
|
||||
@@ -14,6 +15,9 @@ void main() {
|
||||
required FocusNode editableFocusNode,
|
||||
required FocusNode spyFocusNode,
|
||||
}) {
|
||||
final TextEditingController controller = TextEditingController(text: 'dummy text');
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
return MaterialApp(
|
||||
home: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -24,7 +28,7 @@ void main() {
|
||||
child: ActionSpy(
|
||||
focusNode: spyFocusNode,
|
||||
child: EditableText(
|
||||
controller: TextEditingController(text: 'dummy text'),
|
||||
controller: controller,
|
||||
showSelectionHandles: true,
|
||||
autofocus: true,
|
||||
focusNode: editableFocusNode,
|
||||
@@ -50,7 +54,7 @@ void main() {
|
||||
final FocusNode editable = FocusNode();
|
||||
final FocusNode spy = FocusNode();
|
||||
|
||||
testWidgets('backspace with and without word modifier', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('backspace with and without word modifier', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown(tester.binding.testTextInput.register);
|
||||
|
||||
@@ -74,7 +78,7 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: iOS);
|
||||
|
||||
testWidgets('delete with and without word modifier', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('delete with and without word modifier', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown(tester.binding.testTextInput.register);
|
||||
|
||||
@@ -98,7 +102,7 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: iOS);
|
||||
|
||||
testWidgets('Exception: deleting to line boundary is handled by the framework', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Exception: deleting to line boundary is handled by the framework', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown(tester.binding.testTextInput.register);
|
||||
|
||||
@@ -128,13 +132,15 @@ void main() {
|
||||
group('macOS does not accept shortcuts if focus under EditableText', () {
|
||||
final TargetPlatformVariant macOSOnly = TargetPlatformVariant.only(TargetPlatform.macOS);
|
||||
|
||||
testWidgets('word modifier + arrowLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrowLeft', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -151,13 +157,15 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('word modifier + arrowRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrowRight', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -174,13 +182,15 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrowLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrowLeft', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -197,13 +207,15 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrowRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrowRight', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -220,13 +232,15 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('word modifier + arrow key movement', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrow key movement', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -255,13 +269,15 @@ void main() {
|
||||
expect(state.lastIntent, isNull);
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrow key movement', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrow key movement', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -293,13 +309,15 @@ void main() {
|
||||
group('macOS does accept shortcuts if focus above EditableText', () {
|
||||
final TargetPlatformVariant macOSOnly = TargetPlatformVariant.only(TargetPlatform.macOS);
|
||||
|
||||
testWidgets('word modifier + arrowLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrowLeft', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -316,13 +334,15 @@ void main() {
|
||||
expect(state.lastIntent, isA<ExtendSelectionToNextWordBoundaryIntent>());
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('word modifier + arrowRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrowRight', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -339,13 +359,15 @@ void main() {
|
||||
expect(state.lastIntent, isA<ExtendSelectionToNextWordBoundaryIntent>());
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrowLeft', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrowLeft', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -362,13 +384,15 @@ void main() {
|
||||
expect(state.lastIntent, isA<ExtendSelectionToLineBreakIntent>());
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrowRight', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrowRight', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -385,13 +409,15 @@ void main() {
|
||||
expect(state.lastIntent, isA<ExtendSelectionToLineBreakIntent>());
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('word modifier + arrow key movement', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('word modifier + arrow key movement', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
@@ -422,13 +448,15 @@ void main() {
|
||||
expect(state.lastIntent, isA<ExtendSelectionToNextWordBoundaryIntent>());
|
||||
}, variant: macOSOnly);
|
||||
|
||||
testWidgets('line modifier + arrow key movement', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('line modifier + arrow key movement', (WidgetTester tester) async {
|
||||
tester.binding.testTextInput.unregister();
|
||||
addTearDown((){
|
||||
tester.binding.testTextInput.register();
|
||||
});
|
||||
final FocusNode editable = FocusNode();
|
||||
addTearDown(editable.dispose);
|
||||
final FocusNode spy = FocusNode();
|
||||
addTearDown(spy.dispose);
|
||||
await tester.pumpWidget(
|
||||
buildSpyAboveEditableText(
|
||||
editableFocusNode: editable,
|
||||
|
||||
@@ -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('Text widget parameter takes precedence over DefaultTextHeightBehavior', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Text widget parameter takes precedence over DefaultTextHeightBehavior', (WidgetTester tester) async {
|
||||
const TextHeightBehavior behavior1 = TextHeightBehavior(
|
||||
applyHeightToLastDescent: false,
|
||||
applyHeightToFirstAscent: false,
|
||||
@@ -31,7 +32,7 @@ void main() {
|
||||
expect(text.textHeightBehavior, behavior1);
|
||||
});
|
||||
|
||||
testWidgets('DefaultTextStyle.textHeightBehavior takes precedence over DefaultTextHeightBehavior ', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DefaultTextStyle.textHeightBehavior takes precedence over DefaultTextHeightBehavior ', (WidgetTester tester) async {
|
||||
const TextHeightBehavior behavior1 = TextHeightBehavior(
|
||||
applyHeightToLastDescent: false,
|
||||
applyHeightToFirstAscent: false,
|
||||
@@ -77,7 +78,7 @@ void main() {
|
||||
expect(text.textHeightBehavior, behavior1);
|
||||
});
|
||||
|
||||
testWidgets('DefaultTextHeightBehavior changes propagate to Text', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DefaultTextHeightBehavior changes propagate to Text', (WidgetTester tester) async {
|
||||
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
|
||||
const TextHeightBehavior behavior1 = TextHeightBehavior(
|
||||
applyHeightToLastDescent: false,
|
||||
@@ -107,7 +108,7 @@ void main() {
|
||||
expect(text.textHeightBehavior, behavior2);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'DefaultTextHeightBehavior.of(context) returns null if no '
|
||||
'DefaultTextHeightBehavior widget in tree',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
@@ -6,9 +6,10 @@ import 'dart:ui' as ui show TextHeightBehavior;
|
||||
|
||||
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('DefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
|
||||
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
|
||||
const TextStyle s1 = TextStyle(
|
||||
fontSize: 10.0,
|
||||
@@ -43,7 +44,7 @@ void main() {
|
||||
expect(text.maxLines, 3);
|
||||
});
|
||||
|
||||
testWidgets('AnimatedDefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('AnimatedDefaultTextStyle changes propagate to Text', (WidgetTester tester) async {
|
||||
const Text textWidget = Text('Hello', textDirection: TextDirection.ltr);
|
||||
const TextStyle s1 = TextStyle(
|
||||
fontSize: 10.0,
|
||||
|
||||
@@ -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('Can call setState from didUpdateWidget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Can call setState from didUpdateWidget', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: WidgetUnderTest(text: 'hello'),
|
||||
|
||||
@@ -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('Directionality', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Directionality', (WidgetTester tester) async {
|
||||
final List<TextDirection> log = <TextDirection>[];
|
||||
final Widget inner = Builder(
|
||||
builder: (BuildContext context) {
|
||||
@@ -51,7 +52,7 @@ void main() {
|
||||
expect(log, <TextDirection>[TextDirection.ltr, TextDirection.rtl, TextDirection.ltr]);
|
||||
});
|
||||
|
||||
testWidgets('Directionality default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Directionality default', (WidgetTester tester) async {
|
||||
bool good = false;
|
||||
await tester.pumpWidget(Builder(
|
||||
builder: (BuildContext context) {
|
||||
@@ -63,7 +64,7 @@ void main() {
|
||||
expect(good, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Directionality.maybeOf', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Directionality.maybeOf', (WidgetTester tester) async {
|
||||
final GlobalKey hasDirectionality = GlobalKey();
|
||||
final GlobalKey noDirectionality = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
@@ -81,7 +82,7 @@ void main() {
|
||||
expect(Directionality.maybeOf(hasDirectionality.currentContext!), TextDirection.rtl);
|
||||
});
|
||||
|
||||
testWidgets('Directionality.of', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Directionality.of', (WidgetTester tester) async {
|
||||
final GlobalKey hasDirectionality = GlobalKey();
|
||||
final GlobalKey noDirectionality = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:async';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
const DismissDirection defaultDismissDirection = DismissDirection.horizontal;
|
||||
const double crossAxisEndOffset = 0.5;
|
||||
@@ -252,7 +253,7 @@ void main() {
|
||||
dismissedItems = <int>[];
|
||||
});
|
||||
|
||||
testWidgets('Horizontal drag triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Horizontal drag triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(),
|
||||
);
|
||||
@@ -269,7 +270,7 @@ void main() {
|
||||
expect(reportedDismissDirection, DismissDirection.endToStart);
|
||||
});
|
||||
|
||||
testWidgets('Horizontal fling triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Horizontal fling triggers dismiss scrollDirection=vertical', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(),
|
||||
);
|
||||
@@ -286,7 +287,7 @@ void main() {
|
||||
expect(reportedDismissDirection, DismissDirection.endToStart);
|
||||
});
|
||||
|
||||
testWidgets('Horizontal fling does not trigger at zero offset, but does otherwise', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Horizontal fling does not trigger at zero offset, but does otherwise', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
startToEndThreshold: 0.95,
|
||||
@@ -313,7 +314,7 @@ void main() {
|
||||
expect(reportedDismissDirection, DismissDirection.endToStart);
|
||||
});
|
||||
|
||||
testWidgets('Vertical drag triggers dismiss scrollDirection=horizontal', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Vertical drag triggers dismiss scrollDirection=horizontal', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -333,7 +334,7 @@ void main() {
|
||||
expect(reportedDismissDirection, DismissDirection.down);
|
||||
});
|
||||
|
||||
testWidgets('drag-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
dismissDirection: DismissDirection.endToStart,
|
||||
@@ -352,7 +353,7 @@ void main() {
|
||||
await dismissItem(tester, 1, gestureDirection: AxisDirection.left);
|
||||
});
|
||||
|
||||
testWidgets('drag-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
dismissDirection: DismissDirection.startToEnd,
|
||||
@@ -369,7 +370,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('drag-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
textDirection: TextDirection.rtl,
|
||||
@@ -388,7 +389,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('drag-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
textDirection: TextDirection.rtl,
|
||||
@@ -408,7 +409,7 @@ void main() {
|
||||
await dismissItem(tester, 1, gestureDirection: AxisDirection.left);
|
||||
});
|
||||
|
||||
testWidgets('fling-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-left with DismissDirection.endToStart triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
dismissDirection: DismissDirection.endToStart,
|
||||
@@ -427,7 +428,7 @@ void main() {
|
||||
await dismissItem(tester, 1, gestureDirection: AxisDirection.left);
|
||||
});
|
||||
|
||||
testWidgets('fling-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-right with DismissDirection.startToEnd triggers dismiss (LTR)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
dismissDirection: DismissDirection.startToEnd,
|
||||
@@ -445,7 +446,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('fling-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-right with DismissDirection.endToStart triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
textDirection: TextDirection.rtl,
|
||||
@@ -463,7 +464,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('fling-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-left with DismissDirection.startToEnd triggers dismiss (RTL)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
textDirection: TextDirection.rtl,
|
||||
@@ -483,7 +484,7 @@ void main() {
|
||||
await dismissItem(tester, 1, mechanism: flingElement, gestureDirection: AxisDirection.left);
|
||||
});
|
||||
|
||||
testWidgets('drag-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -501,7 +502,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('drag-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -519,7 +520,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('fling-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-up with DismissDirection.up triggers dismiss', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -537,7 +538,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('fling-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-down with DismissDirection.down triggers dismiss', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -555,7 +556,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('drag-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
startToEndThreshold: 1.0,
|
||||
@@ -572,7 +573,7 @@ void main() {
|
||||
expect(dismissedItems, equals(<int>[0]));
|
||||
});
|
||||
|
||||
testWidgets('fling-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('fling-left has no effect on dismissible with a high dismiss threshold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
startToEndThreshold: 1.0,
|
||||
@@ -595,7 +596,7 @@ void main() {
|
||||
// now since we migrated to the new repo. The bug was fixed by
|
||||
// https://github.com/flutter/engine/pull/1134 at the time, and later made
|
||||
// irrelevant by fn3, but just in case...
|
||||
testWidgets('Verify that drag-move events do not assert', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Verify that drag-move events do not assert', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
@@ -622,7 +623,7 @@ void main() {
|
||||
// died in the migration to the new repo). Don't copy this test; it doesn't
|
||||
// actually remove the dismissed widget, which is a violation of the
|
||||
// Dismissible contract. This is not an example of good practice.
|
||||
testWidgets('dismissing bottom then top (smoketest)', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('dismissing bottom then top (smoketest)', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -654,7 +655,7 @@ void main() {
|
||||
expect(find.text('2'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Dismissible starts from the full size when collapsing', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dismissible starts from the full size when collapsing', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
background: const Text('background'),
|
||||
@@ -672,7 +673,7 @@ void main() {
|
||||
expect(backgroundBox.size.height, equals(100.0));
|
||||
});
|
||||
|
||||
testWidgets('Checking fling item before movementDuration completes', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Checking fling item before movementDuration completes', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest());
|
||||
expect(dismissedItems, isEmpty);
|
||||
|
||||
@@ -683,7 +684,7 @@ void main() {
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Checking fling item after movementDuration', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Checking fling item after movementDuration', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest());
|
||||
expect(dismissedItems, isEmpty);
|
||||
|
||||
@@ -694,7 +695,7 @@ void main() {
|
||||
expect(find.text('0'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Horizontal fling less than threshold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Horizontal fling less than threshold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest(scrollDirection: Axis.horizontal));
|
||||
expect(dismissedItems, isEmpty);
|
||||
|
||||
@@ -707,7 +708,7 @@ void main() {
|
||||
expect(dismissedItems, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('Vertical fling less than threshold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Vertical fling less than threshold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest());
|
||||
expect(dismissedItems, isEmpty);
|
||||
|
||||
@@ -720,7 +721,7 @@ void main() {
|
||||
expect(dismissedItems, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('confirmDismiss returns values: true, false, null', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('confirmDismiss returns values: true, false, null', (WidgetTester tester) async {
|
||||
late DismissDirection confirmDismissDirection;
|
||||
|
||||
Widget buildFrame(bool? confirmDismissValue) {
|
||||
@@ -777,7 +778,7 @@ void main() {
|
||||
expect(confirmDismissDirection, DismissDirection.endToStart);
|
||||
});
|
||||
|
||||
testWidgets('Pending confirmDismiss does not cause errors', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Pending confirmDismiss does not cause errors', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/54990
|
||||
|
||||
late Completer<bool?> completer;
|
||||
@@ -839,7 +840,7 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('Dismissible cannot be dragged with pending confirmDismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dismissible cannot be dragged with pending confirmDismiss', (WidgetTester tester) async {
|
||||
final Completer<bool?> completer = Completer<bool?>();
|
||||
await tester.pumpWidget(
|
||||
buildTest(
|
||||
@@ -863,7 +864,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('0')), position);
|
||||
});
|
||||
|
||||
testWidgets('Drag to end and release - items does not get stuck if confirmDismiss returns false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Drag to end and release - items does not get stuck if confirmDismiss returns false', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/87556
|
||||
|
||||
final Completer<bool?> completer = Completer<bool?>();
|
||||
@@ -882,7 +883,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('0')), position);
|
||||
});
|
||||
|
||||
testWidgets('Dismissible with null resizeDuration calls onDismissed immediately', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dismissible with null resizeDuration calls onDismissed immediately', (WidgetTester tester) async {
|
||||
bool resized = false;
|
||||
bool dismissed = false;
|
||||
|
||||
@@ -914,7 +915,7 @@ void main() {
|
||||
expect(resized, false);
|
||||
});
|
||||
|
||||
testWidgets('setState that does not remove the Dismissible from tree should throw Error', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('setState that does not remove the Dismissible from tree should throw Error', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: StatefulBuilder(
|
||||
@@ -971,7 +972,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Dismissible.behavior should behave correctly during hit testing', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dismissible.behavior should behave correctly during hit testing', (WidgetTester tester) async {
|
||||
bool didReceivePointerDown = false;
|
||||
|
||||
Widget buildStack({required Widget child}) {
|
||||
@@ -1040,7 +1041,7 @@ void main() {
|
||||
expect(didReceivePointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('DismissDirection.none does not trigger dismiss', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DismissDirection.none does not trigger dismiss', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest(
|
||||
dismissDirection: DismissDirection.none,
|
||||
scrollPhysics: const NeverScrollableScrollPhysics(),
|
||||
@@ -1054,7 +1055,7 @@ void main() {
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('DismissDirection.none does not prevent scrolling', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DismissDirection.none does not prevent scrolling', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -1077,7 +1078,7 @@ void main() {
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
testWidgets('onUpdate', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('onUpdate', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildTest(
|
||||
scrollDirection: Axis.horizontal,
|
||||
));
|
||||
@@ -1131,7 +1132,7 @@ void main() {
|
||||
expect(reportedDismissUpdateProgress, 0.0);
|
||||
});
|
||||
|
||||
testWidgets('Change direction does not lose child state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Change direction does not lose child state', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/108961
|
||||
Widget buildFrame(DismissDirection direction) {
|
||||
return Directionality(
|
||||
|
||||
@@ -6,10 +6,11 @@ import 'dart:ui';
|
||||
|
||||
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() {
|
||||
group('DisplayFeatureSubScreen', () {
|
||||
testWidgets('without Directionality or anchor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('without Directionality or anchor', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -37,7 +38,7 @@ void main() {
|
||||
expect(message, contains('Directionality'));
|
||||
});
|
||||
|
||||
testWidgets('with anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with anchorPoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -68,7 +69,7 @@ void main() {
|
||||
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0)));
|
||||
});
|
||||
|
||||
testWidgets('with infinity anchorpoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with infinity anchorpoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -99,7 +100,7 @@ void main() {
|
||||
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,0)));
|
||||
});
|
||||
|
||||
testWidgets('with horizontal hinge and anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with horizontal hinge and anchorPoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -129,7 +130,7 @@ void main() {
|
||||
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(0,310)));
|
||||
});
|
||||
|
||||
testWidgets('with multiple display features and anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with multiple display features and anchorPoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -164,7 +165,7 @@ void main() {
|
||||
expect(renderBox.localToGlobal(Offset.zero), equals(const Offset(410,310)));
|
||||
});
|
||||
|
||||
testWidgets('with non-splitting display features and anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with non-splitting display features and anchorPoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
@@ -209,7 +210,7 @@ void main() {
|
||||
expect(renderBox.localToGlobal(Offset.zero), equals(Offset.zero));
|
||||
});
|
||||
|
||||
testWidgets('with size 0 display feature in half-opened posture and anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('with size 0 display feature in half-opened posture and anchorPoint', (WidgetTester tester) async {
|
||||
const Key childKey = Key('childKey');
|
||||
final MediaQueryData mediaQuery = MediaQueryData.fromView(tester.view).copyWith(
|
||||
displayFeatures: <DisplayFeature>[
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
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('DisposableBuildContext asserts on disposed state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('DisposableBuildContext asserts on disposed state', (WidgetTester tester) async {
|
||||
final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>();
|
||||
await tester.pumpWidget(TestWidget(key));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user