diff --git a/packages/flutter/test/widgets/sliver_tree_test.dart b/packages/flutter/test/widgets/sliver_tree_test.dart index a10277c7961f..a7a7a2581ecd 100644 --- a/packages/flutter/test/widgets/sliver_tree_test.dart +++ b/packages/flutter/test/widgets/sliver_tree_test.dart @@ -28,6 +28,29 @@ List> simpleNodeSet = >[ void main() { group('TreeSliverNode', () { + setUp(() { + // Reset node conditions for each test. + simpleNodeSet = >[ + TreeSliverNode('Root 0'), + TreeSliverNode( + 'Root 1', + expanded: true, + children: >[ + TreeSliverNode('Child 1:0'), + TreeSliverNode('Child 1:1'), + ], + ), + TreeSliverNode( + 'Root 2', + children: >[ + TreeSliverNode('Child 2:0'), + TreeSliverNode('Child 2:1'), + ], + ), + TreeSliverNode('Root 3'), + ]; + }); + test('getters, toString', () { final List> children = >[ TreeSliverNode('child'), @@ -123,6 +146,7 @@ void main() { TreeSliverNode('Root 3'), ]; }); + testWidgets('Can set controller on TreeSliver', (WidgetTester tester) async { final TreeSliverController controller = TreeSliverController(); TreeSliverController? returnedController; @@ -427,6 +451,26 @@ void main() { }); testWidgets('.toggleNodeWith, onNodeToggle', (WidgetTester tester) async { + simpleNodeSet = >[ + TreeSliverNode('Root 0'), + TreeSliverNode( + 'Root 1', + expanded: true, + children: >[ + TreeSliverNode('Child 1:0'), + TreeSliverNode('Child 1:1'), + ], + ), + TreeSliverNode( + 'Root 2', + children: >[ + TreeSliverNode('Child 2:0'), + TreeSliverNode('Child 2:1'), + ], + ), + TreeSliverNode('Root 3'), + ]; + final TreeSliverController controller = TreeSliverController(); // The default node builder wraps the leading icon with toggleNodeWith. bool toggled = false; @@ -516,6 +560,26 @@ void main() { }); testWidgets('AnimationStyle is piped through to node builder', (WidgetTester tester) async { + simpleNodeSet = >[ + TreeSliverNode('Root 0'), + TreeSliverNode( + 'Root 1', + expanded: true, + children: >[ + TreeSliverNode('Child 1:0'), + TreeSliverNode('Child 1:1'), + ], + ), + TreeSliverNode( + 'Root 2', + children: >[ + TreeSliverNode('Child 2:0'), + TreeSliverNode('Child 2:1'), + ], + ), + TreeSliverNode('Root 3'), + ]; + AnimationStyle? style; await tester.pumpWidget(MaterialApp( home: CustomScrollView(