diff --git a/packages/devtools_app/test/shared/diagnostics/inspector_service_test.dart b/packages/devtools_app/test/shared/diagnostics/inspector_service_test.dart index f34311e3ca5..63657deee0c 100644 --- a/packages/devtools_app/test/shared/diagnostics/inspector_service_test.dart +++ b/packages/devtools_app/test/shared/diagnostics/inspector_service_test.dart @@ -25,6 +25,7 @@ void main() { final env = FlutterTestEnvironment( const FlutterRunConfiguration(withDebugger: true), + testAppDirectory: 'test/test_infra/fixtures/inspector_app', ); InspectorService? inspectorService; @@ -261,141 +262,66 @@ void main() { }); }); - group( - 'widget trees', - () { - test('isSummaryTree = true', () async { - await env.setupEnvironment(); - final group = inspectorService!.createObjectGroup('test-group'); - final root = (await group.getRoot( - FlutterTreeType.widget, - isSummaryTree: true, - ))!; - // Tree only contains widgets from local app. - expect( - treeToDebugString(root), - equals( - equalsGoldenIgnoringHashCodes( - 'inspector_service_tree_summary.txt', - ), - ), - ); - final nodeInSummaryTree = findNodeMatching(root, 'MaterialApp')!; - expect(nodeInSummaryTree, isNotNull); - - expect( - treeToDebugString(nodeInSummaryTree), - equals( - equalsGoldenIgnoringHashCodes( - 'inspector_service_node_summary.txt', - ), - ), - ); - - await group.dispose(); - }); - - test('isSummaryTree = false', () async { - await env.setupEnvironment(); - final group = inspectorService!.createObjectGroup('test-group'); - final root = (await group.getRoot(FlutterTreeType.widget))!; - // Tree contains all widgets. - expect( - treeToDebugString(root), - equals( - equalsGoldenIgnoringHashCodes( - 'inspector_service_tree_no_summary.txt', - ), - ), - ); - final nodeInTree = findNodeMatching(root, 'MaterialApp')!; - expect(nodeInTree, isNotNull); - expect( - treeToDebugString(nodeInTree), - equals( - equalsGoldenIgnoringHashCodes( - 'inspector_service_node_no_summary.txt', - ), - ), - ); - - await group.dispose(); - }); - - test('details tree', () async { - await env.setupEnvironment(); - - // First get a node in the summary tree: - final group = inspectorService!.createObjectGroup('test-group'); - final root = (await group.getRoot( - FlutterTreeType.widget, - isSummaryTree: true, - ))!; - RemoteDiagnosticsNode nodeInSummaryTree = findNodeMatching( - root, - 'MaterialApp', - )!; - expect(nodeInSummaryTree, isNotNull); - - // Then get the details tree for the node in the summary tree: - RemoteDiagnosticsNode nodeInDetailsTree = (await group - .getDetailsSubtree(nodeInSummaryTree))!; - - // When flutter rolls, this string may sometimes change due to - // implementation details. - expect( - treeToDebugStringTruncated(nodeInDetailsTree, 30), + group('widget trees', () { + test('isSummaryTree = true', () async { + await env.setupEnvironment(); + final group = inspectorService!.createObjectGroup('test-group'); + final root = (await group.getRoot( + FlutterTreeType.widget, + isSummaryTree: true, + ))!; + // Tree only contains widgets from local app. + expect( + treeToDebugString(root), + equals( equalsGoldenIgnoringHashCodes( - 'inspector_service_details_tree.txt', + 'inspector_service_tree_summary.txt', ), - ); - - nodeInSummaryTree = findNodeMatching(root, 'Text')!; - expect(nodeInSummaryTree, isNotNull); - expect( - treeToDebugString(nodeInSummaryTree), - equalsIgnoringHashCodes('Text\n'), - ); - - nodeInDetailsTree = (await group.getDetailsSubtree( - nodeInSummaryTree, - ))!; + ), + ); + final nodeInSummaryTree = findNodeMatching(root, 'CustomApp')!; + expect(nodeInSummaryTree, isNotNull); - expect( - treeToDebugString(nodeInDetailsTree), + expect( + treeToDebugString(nodeInSummaryTree), + equals( equalsGoldenIgnoringHashCodes( - 'inspector_service_text_details_tree.txt', + 'inspector_service_node_summary.txt', ), - ); - - expect( - nodeInDetailsTree.valueRef, - equals(nodeInSummaryTree.valueRef), - ); + ), + ); - await group.setSelectionInspector(nodeInDetailsTree.valueRef, true); - final selection = (await group.getSelection( - null, - FlutterTreeType.widget, - ))!; - expect(selection, isNotNull); - expect(selection.valueRef, equals(nodeInDetailsTree.valueRef)); - expect( - treeToDebugString(selection), - equalsIgnoringHashCodes( - 'Text\n' - ' └─RichText\n', - ), - ); + await group.dispose(); + }); - await group.dispose(); - }); - }, - // TODO(https://github.com/flutter/devtools/issues/9395): Tests should be - // re-enabled once they are no longer dependant on widget ordering in the - // framework. - skip: true, - ); + test('isSummaryTree = false', () async { + await env.setupEnvironment(); + final group = inspectorService!.createObjectGroup('test-group'); + final root = (await group.getRoot(FlutterTreeType.widget))!; + final summaryTreeRoot = (await group.getRoot( + FlutterTreeType.widget, + isSummaryTree: true, + ))!; + + final widgetsInTree = treeToDebugString(root).split('\n'); + + // Unlike in the summary tree, CustomApp is not directly beneath root. + expect(widgetsInTree[0].contains('[root]'), isTrue); + expect(widgetsInTree[1].contains('CustomApp'), isFalse); + + // Tree contains implementation widgets not in the summary tree. + final widgetsInSummaryTree = treeToDebugString( + summaryTreeRoot, + ).split('\n'); + expect(widgetsInTree.length > widgetsInSummaryTree.length, isTrue); + + // Tree contains the CustomApp. + final nodeInTree = findNodeMatching(root, 'CustomApp')!; + expect(nodeInTree, isNotNull); + + await group.dispose(); + }); + }); test('enables hover eval mode by default', () async { await env.setupEnvironment(); diff --git a/packages/devtools_app/test/test_infra/goldens/inspector_service_node_no_summary.txt b/packages/devtools_app/test/test_infra/goldens/inspector_service_node_no_summary.txt deleted file mode 100644 index d9df846f496..00000000000 --- a/packages/devtools_app/test/test_infra/goldens/inspector_service_node_no_summary.txt +++ /dev/null @@ -1,247 +0,0 @@ -MaterialApp - └─ScrollConfiguration - └─HeroControllerScope - └─Focus - └─_FocusInheritedScope - └─Semantics - └─WidgetsApp-[GlobalObjectKey _MaterialAppState#00000] - └─RootRestorationScope - └─UnmanagedRestorationScope - └─RestorationScope - └─UnmanagedRestorationScope - └─SharedAppData - └─_SharedAppModel - └─NotificationListener - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─DefaultTextEditingShortcuts - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─Actions - └─_ActionsScope - └─FocusTraversalGroup - └─Focus - └─_FocusInheritedScope - └─TapRegionSurface - └─ShortcutRegistrar - └─_ShortcutRegistrarScope - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─ListenableBuilder - └─Localizations - └─Semantics - └─_LocalizationsScope-[GlobalKey#00000] - └─Directionality - └─Title - └─CheckedModeBanner - └─Banner - └─CustomPaint - └─ValueListenableBuilder - └─DefaultTextStyle - └─Builder - └─AnimatedTheme - └─Theme - └─_InheritedTheme - └─CupertinoTheme - └─InheritedCupertinoTheme - └─IconTheme - └─IconTheme - └─DefaultSelectionStyle - └─ScaffoldMessenger - └─_ScaffoldMessengerScope - └─DefaultSelectionStyle - └─FocusScope - └─Semantics - └─_FocusInheritedScope - └─Navigator-[GlobalObjectKey _WidgetsAppState#00000] - └─HeroControllerScope - └─NotificationListener - └─Listener - └─AbsorbPointer - └─FocusTraversalGroup - └─Focus - └─_FocusInheritedScope - └─Focus - └─_FocusInheritedScope - └─UnmanagedRestorationScope - └─Overlay-[LabeledGlobalKey#00000] - └─_Theater - ├─_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000] - │ └─TickerMode - │ └─_EffectiveTickerMode - │ └─_RenderTheaterMarker - │ └─IgnorePointer - │ └─ModalBarrier - │ └─BlockSemantics - │ └─ExcludeSemantics - │ └─_ModalBarrierGestureDetector - │ └─RawGestureDetector - │ └─_GestureSemantics - │ └─Listener - │ └─Semantics - │ └─MouseRegion - │ └─ConstrainedBox - └─_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000] - └─TickerMode - └─_EffectiveTickerMode - └─_RenderTheaterMarker - └─Semantics - └─_ModalScope-[LabeledGlobalKey<_ModalScopeState>#00000] - └─AnimatedBuilder - └─RestorationScope - └─UnmanagedRestorationScope - └─_ModalScopeStatus - └─Offstage - └─PageStorage - └─Builder - └─Actions - └─_ActionsScope - └─PrimaryScrollController - └─_FocusScopeWithExternalFocusNode - └─Semantics - └─_FocusInheritedScope - └─RepaintBoundary - └─ListenableBuilder - └─_PageTransitionsThemeTransitions - └─_ZoomPageTransition - └─DualTransitionBuilder - └─_ZoomEnterTransition - └─SnapshotWidget - └─_ZoomExitTransition - └─SnapshotWidget - └─DualTransitionBuilder - └─_ZoomEnterTransition - └─SnapshotWidget - └─_ZoomExitTransition - └─SnapshotWidget - └─ListenableBuilder - └─IgnorePointer - └─RepaintBoundary-[GlobalKey#00000] - └─Builder - └─Semantics - └─Scaffold - └─_ScaffoldScope - └─ScrollNotificationObserver - └─NotificationListener - └─NotificationListener - └─_ScrollNotificationObserverScope - └─Material - └─AnimatedPhysicalModel - └─PhysicalModel - └─NotificationListener - └─_InkFeatures-[GlobalKey#00000 ink renderer] - └─AnimatedDefaultTextStyle - └─DefaultTextStyle - └─AnimatedBuilder - └─Actions - └─_ActionsScope - └─CustomMultiChildLayout - ├─LayoutId-[<_ScaffoldSlot.body>] - │ └─MediaQuery - │ └─_BodyBuilder - │ └─KeyedSubtree-[GlobalKey#00000] - │ └─Center - │ └─Text - │ └─RichText - ├─LayoutId-[<_ScaffoldSlot.appBar>] - │ └─MediaQuery - │ └─ConstrainedBox - │ └─FlexibleSpaceBarSettings - │ └─AppBar - │ └─Semantics - │ └─AnnotatedRegion - │ └─Material - │ └─AnimatedPhysicalModel - │ └─PhysicalModel - │ └─NotificationListener - │ └─_InkFeatures-[GlobalKey#00000 ink renderer] - │ └─AnimatedDefaultTextStyle - │ └─DefaultTextStyle - │ └─Semantics - │ └─Align - │ └─SafeArea - │ └─Padding - │ └─MediaQuery - │ └─ClipRect - │ └─CustomSingleChildLayout - │ └─Builder - │ └─IconTheme - │ └─DefaultTextStyle - │ └─NavigationToolbar - │ └─CustomMultiChildLayout - │ └─LayoutId-[<_ToolbarSlot.middle>] - │ └─Builder - │ └─MediaQuery - │ └─DefaultTextStyle - │ └─Semantics - │ └─_AppBarTitleBox - │ └─Text - │ └─RichText - └─LayoutId-[<_ScaffoldSlot.floatingActionButton>] - └─MediaQuery - └─_FloatingActionButtonTransition - └─Stack - └─ScaleTransition - └─Transform - └─RotationTransition - └─Transform - └─FloatingActionButton - └─MergeSemantics - └─Hero - └─SizedBox - └─Offstage - └─TickerMode - └─_EffectiveTickerMode - └─KeyedSubtree-[GlobalKey#00000] - └─Tooltip - └─OverlayPortal - └─_OverlayPortal - └─_ExclusiveMouseRegion - └─Listener - └─Semantics - └─RawMaterialButton - └─Semantics - └─_InputPadding - └─ConstrainedBox - └─Material - └─_MaterialInterior - └─PhysicalShape - └─_ShapeBorderPaint - └─CustomPaint - └─NotificationListener - └─_InkFeatures-[GlobalKey#00000 ink renderer] - └─AnimatedDefaultTextStyle - └─DefaultTextStyle - └─InkWell - └─_InkResponseStateWidget - └─_ParentInkResponseProvider - └─Actions - └─_ActionsScope - └─Focus - └─_FocusInheritedScope - └─Semantics - └─MouseRegion - └─Builder - └─DefaultSelectionStyle - └─Semantics - └─GestureDetector - └─RawGestureDetector - └─Listener - └─Builder - └─IconTheme - └─Padding - └─Center - └─Builder - └─IconTheme - └─Icon - └─Semantics - └─ExcludeSemantics - └─SizedBox - └─Center - └─RichText diff --git a/packages/devtools_app/test/test_infra/goldens/inspector_service_node_summary.txt b/packages/devtools_app/test/test_infra/goldens/inspector_service_node_summary.txt index b842776e6c8..59ed4f8aa6c 100644 --- a/packages/devtools_app/test/test_infra/goldens/inspector_service_node_summary.txt +++ b/packages/devtools_app/test/test_infra/goldens/inspector_service_node_summary.txt @@ -1,8 +1,15 @@ -MaterialApp - └─Scaffold - ├─Center - │ └─Text - ├─AppBar - │ └─Text - └─FloatingActionButton - └─Icon +CustomApp + └─Directionality + └─DefaultTextStyle + └─HomeScreen + └─CustomContainer + └─Padding + └─Container + └─CustomCenter + └─CustomButton + └─GestureDetector + └─CustomContainer + └─Padding + └─Container + └─CustomText + └─Text diff --git a/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_no_summary.txt b/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_no_summary.txt deleted file mode 100644 index 2d59ded01ee..00000000000 --- a/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_no_summary.txt +++ /dev/null @@ -1,261 +0,0 @@ -[root] - └─View - └─RawView - └─_RawViewInternal-[_DeprecatedRawViewKey FlutterView#00000] - └─_ViewScope - └─_PipelineOwnerScope - └─_MediaQueryFromView - └─MediaQuery - └─FocusTraversalGroup - └─Focus - └─_FocusInheritedScope - └─_FocusScopeWithExternalFocusNode - └─_FocusInheritedScope - └─MyApp - └─MaterialApp - └─ScrollConfiguration - └─HeroControllerScope - └─Focus - └─_FocusInheritedScope - └─Semantics - └─WidgetsApp-[GlobalObjectKey _MaterialAppState#00000] - └─RootRestorationScope - └─UnmanagedRestorationScope - └─RestorationScope - └─UnmanagedRestorationScope - └─SharedAppData - └─_SharedAppModel - └─NotificationListener - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─DefaultTextEditingShortcuts - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─Actions - └─_ActionsScope - └─FocusTraversalGroup - └─Focus - └─_FocusInheritedScope - └─TapRegionSurface - └─ShortcutRegistrar - └─_ShortcutRegistrarScope - └─Shortcuts - └─Focus - └─_FocusInheritedScope - └─Semantics - └─ListenableBuilder - └─Localizations - └─Semantics - └─_LocalizationsScope-[GlobalKey#00000] - └─Directionality - └─Title - └─CheckedModeBanner - └─Banner - └─CustomPaint - └─ValueListenableBuilder - └─DefaultTextStyle - └─Builder - └─AnimatedTheme - └─Theme - └─_InheritedTheme - └─CupertinoTheme - └─InheritedCupertinoTheme - └─IconTheme - └─IconTheme - └─DefaultSelectionStyle - └─ScaffoldMessenger - └─_ScaffoldMessengerScope - └─DefaultSelectionStyle - └─FocusScope - └─Semantics - └─_FocusInheritedScope - └─Navigator-[GlobalObjectKey _WidgetsAppState#00000] - └─HeroControllerScope - └─NotificationListener - └─Listener - └─AbsorbPointer - └─FocusTraversalGroup - └─Focus - └─_FocusInheritedScope - └─Focus - └─_FocusInheritedScope - └─UnmanagedRestorationScope - └─Overlay-[LabeledGlobalKey#00000] - └─_Theater - ├─_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000] - │ └─TickerMode - │ └─_EffectiveTickerMode - │ └─_RenderTheaterMarker - │ └─IgnorePointer - │ └─ModalBarrier - │ └─BlockSemantics - │ └─ExcludeSemantics - │ └─_ModalBarrierGestureDetector - │ └─RawGestureDetector - │ └─_GestureSemantics - │ └─Listener - │ └─Semantics - │ └─MouseRegion - │ └─ConstrainedBox - └─_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000] - └─TickerMode - └─_EffectiveTickerMode - └─_RenderTheaterMarker - └─Semantics - └─_ModalScope-[LabeledGlobalKey<_ModalScopeState>#00000] - └─AnimatedBuilder - └─RestorationScope - └─UnmanagedRestorationScope - └─_ModalScopeStatus - └─Offstage - └─PageStorage - └─Builder - └─Actions - └─_ActionsScope - └─PrimaryScrollController - └─_FocusScopeWithExternalFocusNode - └─Semantics - └─_FocusInheritedScope - └─RepaintBoundary - └─ListenableBuilder - └─_PageTransitionsThemeTransitions - └─_ZoomPageTransition - └─DualTransitionBuilder - └─_ZoomEnterTransition - └─SnapshotWidget - └─_ZoomExitTransition - └─SnapshotWidget - └─DualTransitionBuilder - └─_ZoomEnterTransition - └─SnapshotWidget - └─_ZoomExitTransition - └─SnapshotWidget - └─ListenableBuilder - └─IgnorePointer - └─RepaintBoundary-[GlobalKey#00000] - └─Builder - └─Semantics - └─Scaffold - └─_ScaffoldScope - └─ScrollNotificationObserver - └─NotificationListener - └─NotificationListener - └─_ScrollNotificationObserverScope - └─Material - └─AnimatedPhysicalModel - └─PhysicalModel - └─NotificationListener - └─_InkFeatures-[GlobalKey#00000 ink renderer] - └─AnimatedDefaultTextStyle - └─DefaultTextStyle - └─AnimatedBuilder - └─Actions - └─_ActionsScope - └─CustomMultiChildLayout - ├─LayoutId-[<_ScaffoldSlot.body>] - │ └─MediaQuery - │ └─_BodyBuilder - │ └─KeyedSubtree-[GlobalKey#00000] - │ └─Center - │ └─Text - │ └─RichText - ├─LayoutId-[<_ScaffoldSlot.appBar>] - │ └─MediaQuery - │ └─ConstrainedBox - │ └─FlexibleSpaceBarSettings - │ └─AppBar - │ └─Semantics - │ └─AnnotatedRegion - │ └─Material - │ └─AnimatedPhysicalModel - │ └─PhysicalModel - │ └─NotificationListener - │ └─_InkFeatures-[GlobalKey#00000 ink renderer] - │ └─AnimatedDefaultTextStyle - │ └─DefaultTextStyle - │ └─Semantics - │ └─Align - │ └─SafeArea - │ └─Padding - │ └─MediaQuery - │ └─ClipRect - │ └─CustomSingleChildLayout - │ └─Builder - │ └─IconTheme - │ └─DefaultTextStyle - │ └─NavigationToolbar - │ └─CustomMultiChildLayout - │ └─LayoutId-[<_ToolbarSlot.middle>] - │ └─Builder - │ └─MediaQuery - │ └─DefaultTextStyle - │ └─Semantics - │ └─_AppBarTitleBox - │ └─Text - │ └─RichText - └─LayoutId-[<_ScaffoldSlot.floatingActionButton>] - └─MediaQuery - └─_FloatingActionButtonTransition - └─Stack - └─ScaleTransition - └─Transform - └─RotationTransition - └─Transform - └─FloatingActionButton - └─MergeSemantics - └─Hero - └─SizedBox - └─Offstage - └─TickerMode - └─_EffectiveTickerMode - └─KeyedSubtree-[GlobalKey#00000] - └─Tooltip - └─OverlayPortal - └─_OverlayPortal - └─_ExclusiveMouseRegion - └─Listener - └─Semantics - └─RawMaterialButton - └─Semantics - └─_InputPadding - └─ConstrainedBox - └─Material - └─_MaterialInterior - └─PhysicalShape - └─_ShapeBorderPaint - └─CustomPaint - └─NotificationListener - └─_InkFeatures-[GlobalKey#00000 ink renderer] - └─AnimatedDefaultTextStyle - └─DefaultTextStyle - └─InkWell - └─_InkResponseStateWidget - └─_ParentInkResponseProvider - └─Actions - └─_ActionsScope - └─Focus - └─_FocusInheritedScope - └─Semantics - └─MouseRegion - └─Builder - └─DefaultSelectionStyle - └─Semantics - └─GestureDetector - └─RawGestureDetector - └─Listener - └─Builder - └─IconTheme - └─Padding - └─Center - └─Builder - └─IconTheme - └─Icon - └─Semantics - └─ExcludeSemantics - └─SizedBox - └─Center - └─RichText diff --git a/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_summary.txt b/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_summary.txt index 05b579be5fb..3661c01fad0 100644 --- a/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_summary.txt +++ b/packages/devtools_app/test/test_infra/goldens/inspector_service_tree_summary.txt @@ -1,10 +1,16 @@ [root] - └─MyApp - └─MaterialApp - └─Scaffold - ├─Center - │ └─Text - ├─AppBar - │ └─Text - └─FloatingActionButton - └─Icon + └─CustomApp + └─Directionality + └─DefaultTextStyle + └─HomeScreen + └─CustomContainer + └─Padding + └─Container + └─CustomCenter + └─CustomButton + └─GestureDetector + └─CustomContainer + └─Padding + └─Container + └─CustomText + └─Text