9adee6cc60
Keep the public Cupertino-compatible parameters while retaining only the Material implementations and tests. The app is Material-only, so deleting unreachable Cupertino branches reduces dead code without changing the active path.
79 lines
2.4 KiB
Dart
79 lines
2.4 KiB
Dart
import 'package:flutter/cupertino.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,
|
|
cupertinoIcon: CupertinoIcons.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);
|
|
});
|
|
}
|