9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
77 lines
2.3 KiB
Dart
77 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
|
import 'package:pipelines_app/ui/navigation/bar_icon_button.dart';
|
|
|
|
Widget _row(List<Widget> children) {
|
|
final row = Center(
|
|
child: Row(mainAxisSize: MainAxisSize.min, children: children),
|
|
);
|
|
return MaterialApp(home: Scaffold(body: row));
|
|
}
|
|
|
|
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
|
|
key: key,
|
|
icon: Icons.refresh,
|
|
label: 'Refresh',
|
|
busy: busy,
|
|
onPressed: () {},
|
|
);
|
|
|
|
void main() {
|
|
const side = kMinInteractiveDimension;
|
|
|
|
testWidgets('bar actions are whole, evenly sized touch targets', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
_row([
|
|
_action(const ValueKey('a')),
|
|
_action(const ValueKey('b')),
|
|
_action(const ValueKey('c'), busy: true),
|
|
]),
|
|
);
|
|
for (final key in const ['a', 'b', 'c']) {
|
|
expect(tester.getSize(find.byKey(ValueKey(key))), Size(side, side));
|
|
}
|
|
// Adjacent actions abut: the spacing is the targets', not padding.
|
|
expect(
|
|
tester.getTopLeft(find.byKey(const ValueKey('b'))).dx -
|
|
tester.getTopLeft(find.byKey(const ValueKey('a'))).dx,
|
|
side,
|
|
);
|
|
expect(find.bySemanticsLabel('Refresh'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('search field is one stadium field with a clear', (tester) async {
|
|
final text = TextEditingController();
|
|
addTearDown(text.dispose);
|
|
var cleared = false;
|
|
await tester.pumpWidget(
|
|
_row([
|
|
SizedBox(
|
|
width: 300,
|
|
child: AppSearchField(
|
|
fieldKey: const ValueKey('field'),
|
|
controller: text,
|
|
placeholder: 'Search',
|
|
onCleared: () => cleared = true,
|
|
),
|
|
),
|
|
]),
|
|
);
|
|
final field = tester.widget<TextField>(find.byKey(const ValueKey('field')));
|
|
final border = field.decoration!.enabledBorder! as OutlineInputBorder;
|
|
expect(border.borderSide, BorderSide.none);
|
|
expect(field.decoration!.filled, isTrue);
|
|
expect(find.byTooltip('Clear search'), findsNothing);
|
|
|
|
await tester.enterText(find.byKey(const ValueKey('field')), 'abc');
|
|
await tester.pump();
|
|
await tester.tap(find.byTooltip('Clear search'));
|
|
await tester.pump();
|
|
expect(text.text, isEmpty);
|
|
expect(cleared, isTrue);
|
|
});
|
|
}
|