Unverified Commit 6221d5c7 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

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.
parent a5accb77
......@@ -6,6 +6,8 @@
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
......
......@@ -119,7 +119,7 @@ void main() {
'or WidgetsApp widget at the top of your application widget tree.\n',
),
);
expect(error.toStringDeep(), equalsIgnoringHashCodes(
expect(error.toStringDeep(), startsWith(
'FlutterError\n'
' No Scaffold widget found.\n'
' Builder widgets require a Scaffold widget ancestor.\n'
......@@ -128,114 +128,8 @@ void main() {
' The ancestors of this widget were:\n'
' Semantics\n'
' Builder\n'
' RepaintBoundary-[GlobalKey#00000]\n'
' IgnorePointer\n'
' 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'
));
expect(error.toStringDeep(), endsWith(
' [root]\n'
' Typically, the Scaffold widget is introduced by the MaterialApp\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',
),
);
expect(error.toStringDeep(), equalsIgnoringHashCodes(
expect(error.toStringDeep(), startsWith(
'FlutterError\n'
' No ScaffoldMessenger widget found.\n'
' SnackBarAction widgets require a ScaffoldMessenger widget\n'
......@@ -314,69 +208,8 @@ void main() {
' TextButtonTheme\n'
' Padding\n'
' Row\n'
' Wrap\n'
' Padding\n'
' 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'
));
expect(error.toStringDeep(), endsWith(
' [root]\n'
' Typically, the ScaffoldMessenger widget is introduced by the\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',
),
);
expect(error.toStringDeep(), equalsIgnoringHashCodes(
expect(error.toStringDeep(), startsWith(
'FlutterError\n'
' No ScaffoldMessenger widget found.\n'
' Builder widgets require a ScaffoldMessenger widget ancestor.\n'
......@@ -2509,32 +2509,8 @@ void main() {
' ancestor was:\n'
' Builder\n'
' The ancestors of this widget were:\n'
' KeyedSubtree-[GlobalKey#00000]\n'
' _BodyBuilder\n'
' 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'
));
expect(error.toStringDeep(), endsWith(
' [root]\n'
' Typically, the ScaffoldMessenger widget is introduced by the\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';
void main() {
TestRenderingFlutterBinding.ensureInitialized();
......
......@@ -1689,7 +1689,7 @@ void main() {
testWidgets('RenderObjectElement.unmount disposes of its renderObject', (WidgetTester tester) async {
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;
expect(renderObject.debugDisposed, false);
......
......@@ -1182,22 +1182,20 @@ Future<void> main() async {
await tester.pump(const Duration(milliseconds: 100));
expect(tester.getTopLeft(find.byKey(heroABKey)).dy, 100.0);
bool isVisible(Element node) {
bool visible = true;
node.visitAncestorElements((Element ancestor) {
final RenderObject r = ancestor.renderObject!;
if (r is RenderAnimatedOpacity && r.opacity.value == 0) {
visible = false;
bool isVisible(RenderObject node) {
RenderObject? currentNode = node;
while (currentNode != null) {
if (currentNode is RenderAnimatedOpacity && currentNode.opacity.value == 0) {
return false;
}
return true;
});
return visible;
currentNode = currentNode.parent as RenderObject?;
}
return true;
}
// Of all heroes only one should be visible now.
final Iterable<Element> elements = find.text('Hero').evaluate();
expect(elements.where(isVisible).length, 1);
final Iterable<RenderObject> renderObjects = find.text('Hero').evaluate().map((Element e) => e.renderObject!);
expect(renderObjects.where(isVisible).length, 1);
// Hero BC's flight finishes normally.
await tester.pump(const Duration(milliseconds: 300));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment