46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
void main() {
|
|
testWidgets('caption clicks select once and preserve text-field focus', (
|
|
tester,
|
|
) async {
|
|
final focus = FocusNode();
|
|
addTearDown(focus.dispose);
|
|
var selections = 0;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: Column(
|
|
children: [
|
|
TextField(focusNode: focus),
|
|
FloatingDestinationBar(
|
|
cupertino: false,
|
|
currentIndex: 0,
|
|
showLabels: true,
|
|
items: const [
|
|
FloatingDestinationItem(
|
|
label: 'Chat',
|
|
icon: Icon(Icons.chat),
|
|
),
|
|
],
|
|
onTap: (_) => selections++,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
focus.requestFocus();
|
|
await tester.pump();
|
|
expect(focus.hasFocus, isTrue);
|
|
await tester.tap(find.text('Chat'));
|
|
await tester.pump();
|
|
expect(selections, 1);
|
|
expect(focus.hasFocus, isTrue);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|