@@ -25,6 +25,7 @@ void main() {
2525
2626 final env = FlutterTestEnvironment (
2727 const FlutterRunConfiguration (withDebugger: true ),
28+ testAppDirectory: 'test/test_infra/fixtures/inspector_app' ,
2829 );
2930
3031 InspectorService ? inspectorService;
@@ -261,141 +262,66 @@ void main() {
261262 });
262263 });
263264
264- group (
265- 'widget trees' ,
266- () {
267- test ('isSummaryTree = true' , () async {
268- await env.setupEnvironment ();
269- final group = inspectorService! .createObjectGroup ('test-group' );
270- final root = (await group.getRoot (
271- FlutterTreeType .widget,
272- isSummaryTree: true ,
273- ))! ;
274- // Tree only contains widgets from local app.
275- expect (
276- treeToDebugString (root),
277- equals (
278- equalsGoldenIgnoringHashCodes (
279- 'inspector_service_tree_summary.txt' ,
280- ),
281- ),
282- );
283- final nodeInSummaryTree = findNodeMatching (root, 'MaterialApp' )! ;
284- expect (nodeInSummaryTree, isNotNull);
285-
286- expect (
287- treeToDebugString (nodeInSummaryTree),
288- equals (
289- equalsGoldenIgnoringHashCodes (
290- 'inspector_service_node_summary.txt' ,
291- ),
292- ),
293- );
294-
295- await group.dispose ();
296- });
297-
298- test ('isSummaryTree = false' , () async {
299- await env.setupEnvironment ();
300- final group = inspectorService! .createObjectGroup ('test-group' );
301- final root = (await group.getRoot (FlutterTreeType .widget))! ;
302- // Tree contains all widgets.
303- expect (
304- treeToDebugString (root),
305- equals (
306- equalsGoldenIgnoringHashCodes (
307- 'inspector_service_tree_no_summary.txt' ,
308- ),
309- ),
310- );
311- final nodeInTree = findNodeMatching (root, 'MaterialApp' )! ;
312- expect (nodeInTree, isNotNull);
313- expect (
314- treeToDebugString (nodeInTree),
315- equals (
316- equalsGoldenIgnoringHashCodes (
317- 'inspector_service_node_no_summary.txt' ,
318- ),
319- ),
320- );
321-
322- await group.dispose ();
323- });
324-
325- test ('details tree' , () async {
326- await env.setupEnvironment ();
327-
328- // First get a node in the summary tree:
329- final group = inspectorService! .createObjectGroup ('test-group' );
330- final root = (await group.getRoot (
331- FlutterTreeType .widget,
332- isSummaryTree: true ,
333- ))! ;
334- RemoteDiagnosticsNode nodeInSummaryTree = findNodeMatching (
335- root,
336- 'MaterialApp' ,
337- )! ;
338- expect (nodeInSummaryTree, isNotNull);
339-
340- // Then get the details tree for the node in the summary tree:
341- RemoteDiagnosticsNode nodeInDetailsTree = (await group
342- .getDetailsSubtree (nodeInSummaryTree))! ;
343-
344- // When flutter rolls, this string may sometimes change due to
345- // implementation details.
346- expect (
347- treeToDebugStringTruncated (nodeInDetailsTree, 30 ),
265+ group ('widget trees' , () {
266+ test ('isSummaryTree = true' , () async {
267+ await env.setupEnvironment ();
268+ final group = inspectorService! .createObjectGroup ('test-group' );
269+ final root = (await group.getRoot (
270+ FlutterTreeType .widget,
271+ isSummaryTree: true ,
272+ ))! ;
273+ // Tree only contains widgets from local app.
274+ expect (
275+ treeToDebugString (root),
276+ equals (
348277 equalsGoldenIgnoringHashCodes (
349- 'inspector_service_details_tree .txt' ,
278+ 'inspector_service_tree_summary .txt' ,
350279 ),
351- );
352-
353- nodeInSummaryTree = findNodeMatching (root, 'Text' )! ;
354- expect (nodeInSummaryTree, isNotNull);
355- expect (
356- treeToDebugString (nodeInSummaryTree),
357- equalsIgnoringHashCodes ('Text\n ' ),
358- );
359-
360- nodeInDetailsTree = (await group.getDetailsSubtree (
361- nodeInSummaryTree,
362- ))! ;
280+ ),
281+ );
282+ final nodeInSummaryTree = findNodeMatching (root, 'CustomApp' )! ;
283+ expect (nodeInSummaryTree, isNotNull);
363284
364- expect (
365- treeToDebugString (nodeInDetailsTree),
285+ expect (
286+ treeToDebugString (nodeInSummaryTree),
287+ equals (
366288 equalsGoldenIgnoringHashCodes (
367- 'inspector_service_text_details_tree .txt' ,
289+ 'inspector_service_node_summary .txt' ,
368290 ),
369- );
370-
371- expect (
372- nodeInDetailsTree.valueRef,
373- equals (nodeInSummaryTree.valueRef),
374- );
291+ ),
292+ );
375293
376- await group.setSelectionInspector (nodeInDetailsTree.valueRef, true );
377- final selection = (await group.getSelection (
378- null ,
379- FlutterTreeType .widget,
380- ))! ;
381- expect (selection, isNotNull);
382- expect (selection.valueRef, equals (nodeInDetailsTree.valueRef));
383- expect (
384- treeToDebugString (selection),
385- equalsIgnoringHashCodes (
386- 'Text\n '
387- ' └─RichText\n ' ,
388- ),
389- );
294+ await group.dispose ();
295+ });
390296
391- await group.dispose ();
392- });
393- },
394- // TODO(https://github.com/flutter/devtools/issues/9395): Tests should be
395- // re-enabled once they are no longer dependant on widget ordering in the
396- // framework.
397- skip: true ,
398- );
297+ test ('isSummaryTree = false' , () async {
298+ await env.setupEnvironment ();
299+ final group = inspectorService! .createObjectGroup ('test-group' );
300+ final root = (await group.getRoot (FlutterTreeType .widget))! ;
301+ final summaryTreeRoot = (await group.getRoot (
302+ FlutterTreeType .widget,
303+ isSummaryTree: true ,
304+ ))! ;
305+
306+ final widgetsInTree = treeToDebugString (root).split ('\n ' );
307+
308+ // Unlike in the summary tree, CustomApp is not directly beneath root.
309+ expect (widgetsInTree[0 ].contains ('[root]' ), isTrue);
310+ expect (widgetsInTree[1 ].contains ('CustomApp' ), isFalse);
311+
312+ // Tree contains implementation widgets not in the summary tree.
313+ final widgetsInSummaryTree = treeToDebugString (
314+ summaryTreeRoot,
315+ ).split ('\n ' );
316+ expect (widgetsInTree.length > widgetsInSummaryTree.length, isTrue);
317+
318+ // Tree contains the CustomApp.
319+ final nodeInTree = findNodeMatching (root, 'CustomApp' )! ;
320+ expect (nodeInTree, isNotNull);
321+
322+ await group.dispose ();
323+ });
324+ });
399325
400326 test ('enables hover eval mode by default' , () async {
401327 await env.setupEnvironment ();
0 commit comments