52 lines
1.6 KiB
Dart
52 lines
1.6 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,
|
|
featureKey: 'read_card_test',
|
|
);
|
|
},
|
|
child: const Text('读取饭卡'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
await tester.tap(find.text('读取饭卡'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byType(FTextField), findsNWidgets(2));
|
|
expect(find.text('备注(可选)'), findsOneWidget);
|
|
|
|
await tester.tap(find.text('取消'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(result, isNull);
|
|
expect(find.byType(FTextField), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|