重构录制页面,更新对话框逻辑,优化赛事信息粘贴功能,调整相关文本标签。

This commit is contained in:
2026-06-05 15:46:16 +08:00
parent 016aad49b7
commit 0183bd9a6d
6 changed files with 400 additions and 135 deletions

View File

@@ -0,0 +1,130 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:recording_tool/features/dialog/dialog-record.dart';
import 'package:recording_tool/features/recording/widgets/widget_recording_saved_dialog.dart';
import 'package:recording_tool/gen/assets.gen.dart';
void main() {
Future<void> pumpDialogHost(WidgetTester tester, Widget child) async {
await tester.pumpWidget(
ScreenUtilInit(
designSize: const Size(375, 812),
builder: (context, _) {
return MaterialApp(home: Scaffold(body: child));
},
),
);
}
testWidgets('single button dialog shows configured content and closes', (
tester,
) async {
var tapped = false;
await pumpDialogHost(
tester,
Builder(
builder: (context) {
return TextButton(
onPressed: () {
RecordDialog.showSingle(
context,
title: '无选手信息!',
buttonText: '粘贴',
onPressed: () => tapped = true,
);
},
child: const Text('show'),
);
},
),
);
await tester.tap(find.text('show'));
await tester.pumpAndSettle();
expect(find.byType(Image), findsOneWidget);
expect(find.image(AssetImage(Assets.images.imageDialogBg.path)), findsOne);
expect(find.text('无选手信息!'), findsOneWidget);
expect(find.text('粘贴'), findsOneWidget);
await tester.tap(find.text('粘贴'));
await tester.pumpAndSettle();
expect(tapped, isTrue);
expect(find.text('无选手信息!'), findsNothing);
});
testWidgets('double button dialog dispatches each action', (tester) async {
var leftTapped = false;
var rightTapped = false;
await pumpDialogHost(
tester,
Builder(
builder: (context) {
return TextButton(
onPressed: () {
RecordDialog.showDouble(
context,
title: '本轮比赛视频已保存到相册\n请选择后续录制信息',
leftText: '继续本轮',
rightText: '录制新轮',
onLeftPressed: () => leftTapped = true,
onRightPressed: () => rightTapped = true,
);
},
child: const Text('show'),
);
},
),
);
await tester.tap(find.text('show'));
await tester.pumpAndSettle();
await tester.tap(find.text('继续本轮'));
await tester.pumpAndSettle();
expect(leftTapped, isTrue);
expect(rightTapped, isFalse);
await tester.tap(find.text('show'));
await tester.pumpAndSettle();
await tester.tap(find.text('录制新轮'));
await tester.pumpAndSettle();
expect(rightTapped, isTrue);
});
testWidgets('recording saved dialog follows design title only', (
tester,
) async {
await pumpDialogHost(
tester,
Builder(
builder: (context) {
return TextButton(
onPressed: () {
showRecordingSavedDialog(
context,
sessionTitle: '王东方 丨李想 空中格斗赛',
onContinueRound: () {},
onRecordNewRound: () {},
);
},
child: const Text('show'),
);
},
),
);
await tester.tap(find.text('show'));
await tester.pumpAndSettle();
expect(find.text('王东方 丨李想 空中格斗赛'), findsNothing);
expect(find.text('本轮比赛视频已保存到相册\n请选择后续录制信息'), findsOneWidget);
expect(find.text('继续本轮'), findsOneWidget);
expect(find.text('录制新轮'), findsOneWidget);
});
}

View File

@@ -34,7 +34,7 @@ void main() {
await tester.pumpWidget(const ProviderScope(child: FlutterTemplateApp()));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 1));
}
testWidgets('recording app renders recording page', (tester) async {
@@ -66,7 +66,7 @@ void main() {
clipboardText = validClipboardText;
await tester.tap(find.text('粘贴赛事信息'));
await tester.pumpAndSettle();
await tester.pump(const Duration(milliseconds: 500));
expect(find.text('王东方 丨李想 空中格斗赛'), findsOneWidget);
expect(find.text('粘贴赛事信息'), findsNothing);
@@ -84,7 +84,7 @@ void main() {
await tester.pump();
expect(find.text('王东方 丨李想 空中格斗赛'), findsNothing);
expect(find.text('赛事信息'), findsOneWidget);
expect(find.text('选手信息'), findsOneWidget);
await tester.pump(const Duration(seconds: 2));
});