Files
biz_xfj_cloud/test/common/app_hardware_input_dialog_test.dart
T

50 lines
1.5 KiB
Dart

import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:forui/forui.dart';
import 'package:pj_supermarket_cloud/common/widgets/app/app_hardware_input_dialog.dart';
void main() {
testWidgets('手动饭卡输入取消后安全关闭弹窗', (tester) async {
String? result = 'pending';
await tester.pumpWidget(
ScreenUtilInit(
designSize: const Size(1920, 1080),
builder: (_, __) => MaterialApp(
home: FTheme(
data: FThemes.zinc.light,
child: Builder(
builder: (context) => Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
result = await appHardwareInputDialog(
context,
scene: HardwareInputScene.readCard,
);
},
child: const Text('读取饭卡'),
),
),
),
),
),
),
),
);
await tester.tap(find.text('读取饭卡'));
await tester.pumpAndSettle();
expect(find.byType(FTextField), findsOneWidget);
await tester.tap(find.text('取消'));
await tester.pumpAndSettle();
expect(result, isNull);
expect(find.byType(FTextField), findsNothing);
expect(tester.takeException(), isNull);
});
}