70 lines
2.4 KiB
Dart
70 lines
2.4 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/index.dart';
|
|
import 'package:pj_supermarket_cloud/pages/terminal/menu_query/controller.dart';
|
|
import 'package:pj_supermarket_cloud/pages/terminal/menu_query/widgets/query_method_panel.dart';
|
|
|
|
void main() {
|
|
testWidgets('手动模式保留开始按钮,自动模式改为饭卡等待状态且仍可切换方式', (tester) async {
|
|
await tester.binding.setSurfaceSize(const Size(1920, 1080));
|
|
addTearDown(() => tester.binding.setSurfaceSize(null));
|
|
var startCalls = 0;
|
|
ReservationRecognitionMethod? selectedMethod;
|
|
|
|
await tester.pumpWidget(
|
|
_testApp(
|
|
QueryMethodPanel(
|
|
methods: ReservationRecognitionMethod.values,
|
|
selected: ReservationRecognitionMethod.card,
|
|
status: ReservationMenuQueryStatus.idle,
|
|
autoRecognitionEnabled: false,
|
|
onSelect: (method) => selectedMethod = method,
|
|
onStart: () => startCalls++,
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.text('开始识别'), findsOneWidget);
|
|
await tester.tap(find.text('开始识别'));
|
|
await tester.pump(const Duration(milliseconds: 250));
|
|
expect(startCalls, 1);
|
|
|
|
await tester.pumpWidget(
|
|
_testApp(
|
|
QueryMethodPanel(
|
|
methods: ReservationRecognitionMethod.values,
|
|
selected: ReservationRecognitionMethod.card,
|
|
status: ReservationMenuQueryStatus.recognizing,
|
|
autoRecognitionEnabled: true,
|
|
onSelect: (method) => selectedMethod = method,
|
|
onStart: () => startCalls++,
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.text('开始识别'), findsNothing);
|
|
expect(find.text('请放置饭卡'), findsOneWidget);
|
|
await tester.tap(find.text('人脸查询'));
|
|
await tester.pump(const Duration(milliseconds: 250));
|
|
expect(selectedMethod, ReservationRecognitionMethod.face);
|
|
expect(startCalls, 1);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|
|
|
|
/// 构建与终端设计基准一致的主题和尺寸环境,只验证本组件的可见状态与点击链路。
|
|
Widget _testApp(Widget child) {
|
|
return ScreenUtilInit(
|
|
designSize: const Size(1920, 1080),
|
|
builder: (_, __) => MaterialApp(
|
|
home: FTheme(
|
|
data: FThemes.zinc.light,
|
|
child: Scaffold(body: child),
|
|
),
|
|
),
|
|
);
|
|
}
|