import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/ui/navigation/labelled_icon_button.dart'; /// Touch shows an action's caption under its icon (no hover tooltip there); /// desktop keeps the icon with its tooltip. Both are named once for /// assistive technology. void main() { Future pump(WidgetTester tester) => tester.pumpWidget( MaterialApp( home: Scaffold( body: Center( child: LabelledIconButton( icon: Icons.sort, label: 'Sort runs: Newest first', caption: 'Sort', onPressed: () {}, ), ), ), ), ); testWidgets( 'touch draws the caption and names the full action', (tester) async { final semantics = tester.ensureSemantics(); await pump(tester); expect(find.text('Sort'), findsOneWidget); expect(find.byType(Tooltip), findsNothing); expect(find.bySemanticsLabel('Sort runs: Newest first'), findsOneWidget); expect(tester.getSize(find.byType(LabelledIconButton)).height, 48); semantics.dispose(); }, variant: TargetPlatformVariant.only(TargetPlatform.android), ); testWidgets( 'desktop keeps the icon with its tooltip', (tester) async { await pump(tester); expect(find.text('Sort'), findsNothing); expect(find.byTooltip('Sort runs: Newest first'), findsOneWidget); expect(find.byType(IconButton), findsOneWidget); }, variant: TargetPlatformVariant.only(TargetPlatform.linux), ); }