import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/navigation_rail.dart'; /// The rail's surface runs from the window's top edge. The system's top inset /// is kept clear for the rail's content, but it is painted with the rail's /// surface, so no unpainted strip (white in the app's canvas) shows above it. void main() { for (final brightness in Brightness.values) { testWidgets('the rail top under a system inset is the rail surface ' '(${brightness.name})', (tester) async { tester.view.physicalSize = const Size(1000, 800); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final theme = ThemeData( colorSchemeSeed: Colors.purple, brightness: brightness, ); await tester.pumpWidget( MaterialApp( theme: theme, home: Scaffold( body: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ ShellNavigationRail( selected: AppDestination.pipelines, icon: (destination) => Icon(destinationDetails(destination).icon), onSelected: (_) {}, padding: const EdgeInsets.only(top: 8), ), ], ), ), ), ); await tester.pumpAndSettle(); final surface = theme.colorScheme.surface; final cover = find.byKey(const ValueKey('shell.navigation-rail.surface')); final rail = find.byKey(const ValueKey('shell.navigation-rail')); // The cover and the rail's own background are the same surface colour. expect(tester.widget(cover).color, surface); expect(tester.widget(rail).backgroundColor, surface); // The rail's content starts below the inset, and the cover starts at the // window's top edge, so the inset strip is covered. final coverRect = tester.getRect(cover); final railRect = tester.getRect(rail); expect(coverRect.top, 0); expect(railRect.top, 8); expect( coverRect.contains(Offset(railRect.center.dx, 2)), isTrue, reason: 'the strip above the rail content is painted', ); }); } }