import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/empty_detail_pane.dart'; /// One placeholder for an empty detail pane: the destination's icon above a /// short muted line, centred, on both hosts. void main() { for (final cupertino in [false, true]) { final host = cupertino ? 'Cupertino' : 'Material'; for (final destination in [ AppDestination.runs, AppDestination.chat, AppDestination.pipelines, ]) { testWidgets('$host ${destination.name}: icon over a muted line', ( tester, ) async { final content = EmptyDetailPane( destination: destination, message: 'Select one to open it here.', ); await tester.pumpWidget( cupertino ? CupertinoApp(home: CupertinoPageScaffold(child: content)) : MaterialApp(home: Scaffold(body: content)), ); final details = destinationDetails(destination); final icon = find.byIcon( cupertino ? details.cupertinoIcon : details.icon, ); expect(icon, findsOneWidget); final text = find.text('Select one to open it here.'); expect( tester.getTopLeft(text).dy, greaterThan(tester.getRect(icon).bottom), ); // Centred in the pane. final size = tester.view.physicalSize / tester.view.devicePixelRatio; expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1)); // Muted: the same secondary colour on the icon and the line. final context = tester.element(text); final muted = cupertino ? CupertinoColors.secondaryLabel.resolveFrom(context) : Theme.of(context).colorScheme.onSurfaceVariant; expect(tester.widget(icon).color, muted); expect(tester.widget(text).style?.color, muted); }); } } }