import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:halkyon_ui/halkyon_ui.dart'; import 'package:material_ui/material_ui.dart'; import '../support/test_app.dart'; /// A transparent PNG of one pixel, standing in for an app's kingfisher. final _emblem = MemoryImage( Uint8List.fromList(const [ 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, // 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, ]), ); void main() { testWidgets("shows the kingfisher in the app's colours as it is, and " "\"Halkyon\" over the app's word, read out as the app's name", ( tester, ) async { await tester.pumpWidget( testApp( LaunchScreen(emblem: _emblem, product: 'Todo', name: 'Halkyon Todo'), ), ); // The bird on the screen itself (ADR 0031, D11), not a rounded tile. expect(find.byType(Image), findsOneWidget); expect( find.ancestor(of: find.byType(Image), matching: find.byType(ClipRRect)), findsNothing, ); expect( tester.getSize(find.byType(Image)), const Size.square(LaunchScreen.emblemSize), ); final brand = tester.getRect(find.text('Halkyon')); final product = tester.getRect(find.text('Todo')); expect(product.top, greaterThanOrEqualTo(brand.bottom - 1)); expect(product.center.dx, moreOrLessEquals(brand.center.dx)); expect(find.bySemanticsLabel('Halkyon Todo'), findsOneWidget); }); testWidgets('the wordmark is cobalt over copper, and silent to screen ' 'readers', (tester) async { await tester.pumpWidget( testApp(const Scaffold(body: BrandWordmark(product: 'Train'))), ); final scheme = appTheme(Brightness.light).colorScheme; expect( tester.widget(find.text('Halkyon')).style?.color, scheme.primary, ); expect( tester.widget(find.text('Train')).style?.color, scheme.tertiary, ); expect(find.bySemanticsLabel('Train'), findsNothing); }); }