60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
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() {
|
|
for (final theme in [AppTheme.penLight, AppTheme.penDark]) {
|
|
testWidgets('toolbar menu feedback is neutral in ${theme.brightness}', (
|
|
tester,
|
|
) async {
|
|
var presses = 0;
|
|
final focus = FocusNode();
|
|
addTearDown(focus.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
theme: theme,
|
|
home: Scaffold(
|
|
body: AppToolbarDropdownButton(
|
|
buttonKey: const Key('trigger'),
|
|
focusNode: focus,
|
|
onPressed: () => presses++,
|
|
style: const ButtonStyle(
|
|
overlayColor: WidgetStatePropertyAll(Colors.blue),
|
|
),
|
|
child: const Text('Projects'),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final button = tester.widget<TextButton>(
|
|
find.byKey(const Key('trigger')),
|
|
);
|
|
for (final state in [
|
|
WidgetState.hovered,
|
|
WidgetState.focused,
|
|
WidgetState.pressed,
|
|
]) {
|
|
expect(
|
|
button.style!.backgroundColor!.resolve({state}),
|
|
Colors.transparent,
|
|
);
|
|
expect(
|
|
button.style!.overlayColor!.resolve({state}),
|
|
theme.colorScheme.onSurface.withValues(alpha: .05),
|
|
);
|
|
expect(
|
|
button.style!.overlayColor!.resolve({state, WidgetState.disabled}),
|
|
Colors.transparent,
|
|
);
|
|
}
|
|
await tester.tap(find.byKey(const Key('trigger')));
|
|
await tester.pump();
|
|
expect(presses, 1);
|
|
focus.requestFocus();
|
|
await tester.pump();
|
|
expect(focus.hasFocus, isTrue);
|
|
});
|
|
}
|
|
}
|