import 'package:cutdex_ui/theme.dart'; import 'package:cutdex_ui/widgets.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('property list rows use the project item gap without a line', ( tester, ) async { await tester.pumpWidget( MaterialApp( theme: AppTheme.penDark, home: Theme( data: AppTheme.propertiesPanelTheme(AppTheme.penDark), child: Scaffold( body: AppItemGroup( children: [ AppItem( key: const Key('first-mask'), leading: IconButton( key: const Key('mask-visibility'), icon: const Icon(Icons.visibility_outlined), onPressed: () {}, ), actions: [ IconButton( key: const Key('mask-delete'), icon: const Icon(Icons.delete_outline), onPressed: () {}, ), ], child: const Text('蒙版 1'), ), const AppItem(key: Key('second-mask'), child: Text('蒙版 2')), ], ), ), ), ), ); expect( tester.getSize(find.byKey(const Key('first-mask'))).height, AppControlSize.propertyItem, ); expect( tester.getSize(find.byKey(const Key('second-mask'))).height, AppControlSize.propertyItem, ); expect( tester.getSize(find.byKey(const Key('mask-visibility'))).height, AppControlSize.propertyControl, ); expect( tester.getRect(find.byKey(const Key('second-mask'))).top - tester.getRect(find.byKey(const Key('first-mask'))).bottom, AppSidebarMetrics.projectGap, ); expect(find.byType(Divider), findsNothing); }); testWidgets('property list hover and selection use translucent ink', ( tester, ) async { for (final theme in [AppTheme.penLight, AppTheme.penDark]) { Future mount({required bool selected}) => tester.pumpWidget( MaterialApp( theme: theme, home: Theme( data: AppTheme.propertiesPanelTheme(theme), child: Scaffold( body: AppItem( selected: selected, onPressed: () {}, child: const Text('蒙版 1'), ), ), ), ), ); Finder row() => find.descendant(of: find.byType(AppItem), matching: find.byType(T)); final ink = theme.colorScheme.onSurface; await mount(selected: false); expect( tester.widget(row()).color, Colors.transparent, ); expect( tester.widget(row()).hoverColor, ink.withValues( alpha: theme.brightness == Brightness.dark ? .078 : .058, ), ); await mount(selected: true); expect( tester.widget(row()).color, ink.withValues(alpha: .05), ); expect( tester.widget(row()).hoverColor, ink.withValues(alpha: .05), ); } }); }