import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart' as transport; import 'package:pipelines_app/features/settings/settings_group.dart'; import 'package:pipelines_app/features/settings/settings_screen.dart'; import 'package:pipelines_app/features/settings/settings_store.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; import 'fake_channel.dart'; /// Settings as the shell's tab: the page runs behind the shell's bar. void main() { Future pump(WidgetTester tester) async { await tester.binding.setSurfaceSize(const Size(560, 1000)); addTearDown(() => tester.binding.setSurfaceSize(null)); final factory = FakeChannelFactory(); final client = transport.PipelinesClient(channelFactory: factory.call); addTearDown(client.dispose); final shell = AdaptiveShell( destination: AppDestination.settings, destinationBodies: { AppDestination.settings: (_) => SettingsScreen( client: client, store: MemorySettingsStore(), embedded: true, ), }, ); await tester.pumpWidget(MaterialApp(home: shell)); await tester.pump(); await tester.pump(); } Color scrimOf(WidgetTester tester) => tester .widget( find .descendant( of: find.byType(SegmentedBar), matching: find.byType(ColoredBox), ) .first, ) .color; testWidgets('the bar keeps the shell page background', (tester) async { await pump(tester); final context = tester.element(find.byType(SettingsGroup).first); expect( scrimOf(tester).toARGB32(), Theme.of(context).scaffoldBackgroundColor.toARGB32(), ); expect( tester .getTopLeft(find.byKey(const ValueKey('settings.scroll'))) .dy, greaterThan(tester.getRect(find.byType(SegmentedBar)).bottom), ); }); }