Refactor tests (#128371)
To make them a little more resilient to changes in the tree shape as the tree will be changing a little bit for multi view.
This commit is contained in:
parent
a5accb779b
commit
6221d5c709
@ -6,6 +6,8 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.cs.allow-jit</key>
|
<key>com.apple.security.cs.allow-jit</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.network.client</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.security.network.server</key>
|
<key>com.apple.security.network.server</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -119,7 +119,7 @@ void main() {
|
|||||||
'or WidgetsApp widget at the top of your application widget tree.\n',
|
'or WidgetsApp widget at the top of your application widget tree.\n',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
expect(error.toStringDeep(), startsWith(
|
||||||
'FlutterError\n'
|
'FlutterError\n'
|
||||||
' No Scaffold widget found.\n'
|
' No Scaffold widget found.\n'
|
||||||
' Builder widgets require a Scaffold widget ancestor.\n'
|
' Builder widgets require a Scaffold widget ancestor.\n'
|
||||||
@ -128,114 +128,8 @@ void main() {
|
|||||||
' The ancestors of this widget were:\n'
|
' The ancestors of this widget were:\n'
|
||||||
' Semantics\n'
|
' Semantics\n'
|
||||||
' Builder\n'
|
' Builder\n'
|
||||||
' RepaintBoundary-[GlobalKey#00000]\n'
|
));
|
||||||
' IgnorePointer\n'
|
expect(error.toStringDeep(), endsWith(
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' FadeTransition\n'
|
|
||||||
' FractionalTranslation\n'
|
|
||||||
' SlideTransition\n'
|
|
||||||
' _FadeUpwardsPageTransition\n'
|
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' RepaintBoundary\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' FocusScope\n'
|
|
||||||
' PrimaryScrollController\n'
|
|
||||||
' _ActionsScope\n'
|
|
||||||
' Actions\n'
|
|
||||||
' Builder\n'
|
|
||||||
' PageStorage\n'
|
|
||||||
' Offstage\n'
|
|
||||||
' _ModalScopeStatus\n'
|
|
||||||
' UnmanagedRestorationScope\n'
|
|
||||||
' RestorationScope\n'
|
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#00000]\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' _RenderTheaterMarker\n'
|
|
||||||
' _EffectiveTickerMode\n'
|
|
||||||
' TickerMode\n'
|
|
||||||
' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000]\n'
|
|
||||||
' _Theater\n'
|
|
||||||
' Overlay-[LabeledGlobalKey<OverlayState>#00000]\n'
|
|
||||||
' UnmanagedRestorationScope\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' FocusTraversalGroup\n'
|
|
||||||
' AbsorbPointer\n'
|
|
||||||
' Listener\n'
|
|
||||||
' HeroControllerScope\n'
|
|
||||||
' Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#00000]\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' FocusScope\n'
|
|
||||||
' DefaultSelectionStyle\n'
|
|
||||||
' IconTheme\n'
|
|
||||||
' IconTheme\n'
|
|
||||||
' _InheritedCupertinoTheme\n'
|
|
||||||
' CupertinoTheme\n'
|
|
||||||
' _InheritedTheme\n'
|
|
||||||
' Theme\n'
|
|
||||||
' AnimatedTheme\n'
|
|
||||||
' DefaultSelectionStyle\n'
|
|
||||||
' _ScaffoldMessengerScope\n'
|
|
||||||
' ScaffoldMessenger\n'
|
|
||||||
' Builder\n'
|
|
||||||
' DefaultTextStyle\n'
|
|
||||||
' CustomPaint\n'
|
|
||||||
' Banner\n'
|
|
||||||
' CheckedModeBanner\n'
|
|
||||||
' Title\n'
|
|
||||||
' Directionality\n'
|
|
||||||
' _LocalizationsScope-[GlobalKey#00000]\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' Localizations\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' Shortcuts\n'
|
|
||||||
' _ShortcutRegistrarScope\n'
|
|
||||||
' ShortcutRegistrar\n'
|
|
||||||
' TapRegionSurface\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' FocusTraversalGroup\n'
|
|
||||||
' _ActionsScope\n'
|
|
||||||
' Actions\n'
|
|
||||||
'${kIsWeb
|
|
||||||
? ' Semantics\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' Shortcuts\n'
|
|
||||||
: ''}'
|
|
||||||
' Semantics\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' Shortcuts\n'
|
|
||||||
' DefaultTextEditingShortcuts\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' Shortcuts\n'
|
|
||||||
' _SharedAppModel\n'
|
|
||||||
' SharedAppData\n'
|
|
||||||
' UnmanagedRestorationScope\n'
|
|
||||||
' RestorationScope\n'
|
|
||||||
' UnmanagedRestorationScope\n'
|
|
||||||
' RootRestorationScope\n'
|
|
||||||
' WidgetsApp-[GlobalObjectKey _MaterialAppState#00000]\n'
|
|
||||||
' Semantics\n'
|
|
||||||
' _FocusInheritedScope\n'
|
|
||||||
' Focus\n'
|
|
||||||
' HeroControllerScope\n'
|
|
||||||
' ScrollConfiguration\n'
|
|
||||||
' MaterialApp\n'
|
|
||||||
' MediaQuery\n'
|
|
||||||
' _MediaQueryFromView\n'
|
|
||||||
' _ViewScope\n'
|
|
||||||
' View-[GlobalObjectKey TestFlutterView#00000]\n'
|
|
||||||
' [root]\n'
|
' [root]\n'
|
||||||
' Typically, the Scaffold widget is introduced by the MaterialApp\n'
|
' Typically, the Scaffold widget is introduced by the MaterialApp\n'
|
||||||
' or WidgetsApp widget at the top of your application widget tree.\n'
|
' or WidgetsApp widget at the top of your application widget tree.\n'
|
||||||
@ -302,7 +196,7 @@ void main() {
|
|||||||
'MaterialApp at the top of your application widget tree.\n',
|
'MaterialApp at the top of your application widget tree.\n',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
expect(error.toStringDeep(), startsWith(
|
||||||
'FlutterError\n'
|
'FlutterError\n'
|
||||||
' No ScaffoldMessenger widget found.\n'
|
' No ScaffoldMessenger widget found.\n'
|
||||||
' SnackBarAction widgets require a ScaffoldMessenger widget\n'
|
' SnackBarAction widgets require a ScaffoldMessenger widget\n'
|
||||||
@ -314,69 +208,8 @@ void main() {
|
|||||||
' TextButtonTheme\n'
|
' TextButtonTheme\n'
|
||||||
' Padding\n'
|
' Padding\n'
|
||||||
' Row\n'
|
' Row\n'
|
||||||
' Wrap\n'
|
));
|
||||||
' Padding\n'
|
expect(error.toStringDeep(), endsWith(
|
||||||
' MediaQuery\n'
|
|
||||||
' Padding\n'
|
|
||||||
' SafeArea\n'
|
|
||||||
' FadeTransition\n'
|
|
||||||
' DefaultSelectionStyle\n'
|
|
||||||
' IconTheme\n'
|
|
||||||
' IconTheme\n'
|
|
||||||
' _InheritedCupertinoTheme\n'
|
|
||||||
' CupertinoTheme\n'
|
|
||||||
' _InheritedTheme\n'
|
|
||||||
' Theme\n'
|
|
||||||
' DefaultTextStyle\n'
|
|
||||||
' AnimatedDefaultTextStyle\n'
|
|
||||||
' _InkFeatures-[GlobalKey#00000 ink renderer]\n'
|
|
||||||
' NotificationListener<LayoutChangedNotification>\n'
|
|
||||||
' PhysicalModel\n'
|
|
||||||
' AnimatedPhysicalModel\n'
|
|
||||||
' Material\n'
|
|
||||||
' KeyedSubtree-[GlobalKey#00000]\n'
|
|
||||||
' FractionalTranslation\n'
|
|
||||||
' SlideTransition\n'
|
|
||||||
' Listener\n'
|
|
||||||
' _GestureSemantics\n'
|
|
||||||
' RawGestureDetector\n'
|
|
||||||
' GestureDetector\n'
|
|
||||||
" Dismissible-[<'dismissible'>]\n"
|
|
||||||
' Semantics\n'
|
|
||||||
' Align\n'
|
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' ClipRect\n'
|
|
||||||
' KeyedSubtree-[GlobalKey#00000]\n'
|
|
||||||
' _EffectiveTickerMode\n'
|
|
||||||
' TickerMode\n'
|
|
||||||
' Offstage\n'
|
|
||||||
' SizedBox\n'
|
|
||||||
' Hero\n'
|
|
||||||
' SnackBar-[#00000]\n'
|
|
||||||
' MediaQuery\n'
|
|
||||||
' LayoutId-[<_ScaffoldSlot.snackBar>]\n'
|
|
||||||
' CustomMultiChildLayout\n'
|
|
||||||
' _ActionsScope\n'
|
|
||||||
' Actions\n'
|
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' DefaultTextStyle\n'
|
|
||||||
' AnimatedDefaultTextStyle\n'
|
|
||||||
' _InkFeatures-[GlobalKey#00000 ink renderer]\n'
|
|
||||||
' NotificationListener<LayoutChangedNotification>\n'
|
|
||||||
' PhysicalModel\n'
|
|
||||||
' AnimatedPhysicalModel\n'
|
|
||||||
' Material\n'
|
|
||||||
' _ScrollNotificationObserverScope\n'
|
|
||||||
' NotificationListener<ScrollNotification>\n'
|
|
||||||
' NotificationListener<ScrollMetricsNotification>\n'
|
|
||||||
' ScrollNotificationObserver\n'
|
|
||||||
' _ScaffoldScope\n'
|
|
||||||
' Scaffold-[LabeledGlobalKey<ScaffoldState>#00000]\n'
|
|
||||||
' Directionality\n'
|
|
||||||
' MediaQuery\n'
|
|
||||||
' _MediaQueryFromView\n'
|
|
||||||
' _ViewScope\n'
|
|
||||||
' View-[GlobalObjectKey TestFlutterView#00000]\n'
|
|
||||||
' [root]\n'
|
' [root]\n'
|
||||||
' Typically, the ScaffoldMessenger widget is introduced by the\n'
|
' Typically, the ScaffoldMessenger widget is introduced by the\n'
|
||||||
' MaterialApp at the top of your application widget tree.\n'
|
' MaterialApp at the top of your application widget tree.\n'
|
||||||
|
@ -2501,7 +2501,7 @@ void main() {
|
|||||||
'MaterialApp at the top of your application widget tree.\n',
|
'MaterialApp at the top of your application widget tree.\n',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
expect(error.toStringDeep(), startsWith(
|
||||||
'FlutterError\n'
|
'FlutterError\n'
|
||||||
' No ScaffoldMessenger widget found.\n'
|
' No ScaffoldMessenger widget found.\n'
|
||||||
' Builder widgets require a ScaffoldMessenger widget ancestor.\n'
|
' Builder widgets require a ScaffoldMessenger widget ancestor.\n'
|
||||||
@ -2509,32 +2509,8 @@ void main() {
|
|||||||
' ancestor was:\n'
|
' ancestor was:\n'
|
||||||
' Builder\n'
|
' Builder\n'
|
||||||
' The ancestors of this widget were:\n'
|
' The ancestors of this widget were:\n'
|
||||||
' KeyedSubtree-[GlobalKey#00000]\n'
|
));
|
||||||
' _BodyBuilder\n'
|
expect(error.toStringDeep(), endsWith(
|
||||||
' MediaQuery\n'
|
|
||||||
' LayoutId-[<_ScaffoldSlot.body>]\n'
|
|
||||||
' CustomMultiChildLayout\n'
|
|
||||||
' _ActionsScope\n'
|
|
||||||
' Actions\n'
|
|
||||||
' AnimatedBuilder\n'
|
|
||||||
' DefaultTextStyle\n'
|
|
||||||
' AnimatedDefaultTextStyle\n'
|
|
||||||
' _InkFeatures-[GlobalKey#00000 ink renderer]\n'
|
|
||||||
' NotificationListener<LayoutChangedNotification>\n'
|
|
||||||
' PhysicalModel\n'
|
|
||||||
' AnimatedPhysicalModel\n'
|
|
||||||
' Material\n'
|
|
||||||
' _ScrollNotificationObserverScope\n'
|
|
||||||
' NotificationListener<ScrollNotification>\n'
|
|
||||||
' NotificationListener<ScrollMetricsNotification>\n'
|
|
||||||
' ScrollNotificationObserver\n'
|
|
||||||
' _ScaffoldScope\n'
|
|
||||||
' Scaffold\n'
|
|
||||||
' Directionality\n'
|
|
||||||
' MediaQuery\n'
|
|
||||||
' _MediaQueryFromView\n'
|
|
||||||
' _ViewScope\n'
|
|
||||||
' View-[GlobalObjectKey TestFlutterView#e6136]\n'
|
|
||||||
' [root]\n'
|
' [root]\n'
|
||||||
' Typically, the ScaffoldMessenger widget is introduced by the\n'
|
' Typically, the ScaffoldMessenger widget is introduced by the\n'
|
||||||
' MaterialApp at the top of your application widget tree.\n',
|
' MaterialApp at the top of your application widget tree.\n',
|
||||||
|
@ -7,7 +7,6 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
|
|
||||||
import 'rendering_tester.dart';
|
import 'rendering_tester.dart';
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
TestRenderingFlutterBinding.ensureInitialized();
|
TestRenderingFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
@ -1689,7 +1689,7 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('RenderObjectElement.unmount disposes of its renderObject', (WidgetTester tester) async {
|
testWidgets('RenderObjectElement.unmount disposes of its renderObject', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(const Placeholder());
|
await tester.pumpWidget(const Placeholder());
|
||||||
final RenderObjectElement element = tester.allElements.whereType<RenderObjectElement>().first;
|
final RenderObjectElement element = tester.allElements.whereType<RenderObjectElement>().last;
|
||||||
final RenderObject renderObject = element.renderObject;
|
final RenderObject renderObject = element.renderObject;
|
||||||
expect(renderObject.debugDisposed, false);
|
expect(renderObject.debugDisposed, false);
|
||||||
|
|
||||||
|
@ -1182,22 +1182,20 @@ Future<void> main() async {
|
|||||||
await tester.pump(const Duration(milliseconds: 100));
|
await tester.pump(const Duration(milliseconds: 100));
|
||||||
expect(tester.getTopLeft(find.byKey(heroABKey)).dy, 100.0);
|
expect(tester.getTopLeft(find.byKey(heroABKey)).dy, 100.0);
|
||||||
|
|
||||||
bool isVisible(Element node) {
|
bool isVisible(RenderObject node) {
|
||||||
bool visible = true;
|
RenderObject? currentNode = node;
|
||||||
node.visitAncestorElements((Element ancestor) {
|
while (currentNode != null) {
|
||||||
final RenderObject r = ancestor.renderObject!;
|
if (currentNode is RenderAnimatedOpacity && currentNode.opacity.value == 0) {
|
||||||
if (r is RenderAnimatedOpacity && r.opacity.value == 0) {
|
|
||||||
visible = false;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
currentNode = currentNode.parent as RenderObject?;
|
||||||
});
|
}
|
||||||
return visible;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Of all heroes only one should be visible now.
|
// Of all heroes only one should be visible now.
|
||||||
final Iterable<Element> elements = find.text('Hero').evaluate();
|
final Iterable<RenderObject> renderObjects = find.text('Hero').evaluate().map((Element e) => e.renderObject!);
|
||||||
expect(elements.where(isVisible).length, 1);
|
expect(renderObjects.where(isVisible).length, 1);
|
||||||
|
|
||||||
// Hero BC's flight finishes normally.
|
// Hero BC's flight finishes normally.
|
||||||
await tester.pump(const Duration(milliseconds: 300));
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user