import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart'; import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart'; import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; void main() { testWidgets('code-like values still use native host typography', ( tester, ) async { await tester.pumpWidget( MaterialApp( home: Scaffold( body: Builder( builder: (context) { expect( pipelineValueStyle(context, monospace: true), Theme.of(context).textTheme.bodyMedium, ); return const SizedBox.shrink(); }, ), ), ), ); }); for (final cupertino in [false, true]) { for (final width in [320.0, 390.0, 720.0, 1200.0]) { testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', ( tester, ) async { tester.view.physicalSize = Size(width, 640); tester.view.devicePixelRatio = 1; addTearDown(tester.view.reset); PipelineDetailTab? selected; final body = Align( alignment: Alignment.bottomCenter, child: PipelineDetailTabs( selected: PipelineDetailTab.summary, onSelected: (value) => selected = value, ), ); Widget scaled(BuildContext context, Widget? child) => MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(2)), child: child!, ); await tester.pumpWidget( cupertino ? CupertinoApp( builder: scaled, home: CupertinoPageScaffold(child: body), ) : MaterialApp( builder: scaled, home: Scaffold(body: body), ), ); await tester.pumpAndSettle(); // The host's own tab bar inside the shared glass pill. expect( find.byType(cupertino ? CupertinoTabBar : NavigationBar), findsOneWidget, ); final pill = tester.getRect(find.byType(GlassPill)); if (width < 600) { expect(pill.left, 16); expect(pill.right, width - 16); } else { // Sized to its three tabs at the right edge. expect(pill.right, width - 16); expect(pill.width, lessThan(width * 0.6)); } for (final tab in PipelineDetailTab.values) { final rect = tester.getRect( find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')), ); expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name); expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name); } await tester.tap(find.byKey(const Key('pipeline-detail-tab-source'))); await tester.pumpAndSettle(); expect(selected, PipelineDetailTab.source); expect(tester.takeException(), isNull); }); } } }