import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/application/app.dart'; import 'package:pipelines_app/ui/adaptive/platform.dart'; import 'package:pipelines_app/ui/theme/app_theme.dart'; void main() { test('no platform prefers the Cupertino host', () { expect(prefersCupertino(), isFalse); }); for (final platform in TargetPlatform.values) { testWidgets('the app uses the Material host on $platform', (tester) async { debugDefaultTargetPlatformOverride = platform; addTearDown(() => debugDefaultTargetPlatformOverride = null); await tester.pumpWidget(const MyApp()); expect(find.byType(MaterialApp), findsOneWidget); expect(find.byType(CupertinoApp), findsNothing); // Native hosts keep the target platform so Flutter's automatic // behaviours (scroll physics, text selection, back-swipe) still apply. final expected = kIsWeb ? TargetPlatform.android : platform; expect(appLightTheme().platform, expected); expect(appDarkTheme().platform, expected); await tester.pumpWidget(const SizedBox.shrink()); debugDefaultTargetPlatformOverride = null; }); } testWidgets('an explicit cupertino choice still builds the Cupertino host', ( tester, ) async { await tester.pumpWidget(const MyApp(cupertino: true)); expect(find.byType(CupertinoApp), findsOneWidget); await tester.pumpWidget(const SizedBox.shrink()); }); }