完善遥控权限、控制发送和急停反馈

This commit is contained in:
2026-11-21 14:37:46 +08:00
parent c284aefc7d
commit 9a8a42a0a1
55 changed files with 5009 additions and 1308 deletions

View File

@@ -10,6 +10,7 @@ import 'package:maibu_satabot_v2/features/device_control_mode/domain/entities/de
import 'package:maibu_satabot_v2/features/device_control_mode/domain/usecases/device_control_mode_usecases.dart';
import 'package:maibu_satabot_v2/features/device_control_mode/presentation/cubit/control_mode_entry_cubit.dart';
import 'package:maibu_satabot_v2/features/device_control_mode/presentation/widgets/control_mode_entry_gate.dart';
import 'package:maibu_satabot_v2/features/device_control_mode/presentation/widgets/mode_independent_control.dart';
import 'support/control_mode_fakes.dart';
final _translations = <String, AppLocalizations>{};
@@ -215,6 +216,94 @@ void main() {
expect(drives, 1);
});
testWidgets('independent emergency and settings stay usable before mode confirmation', (
tester,
) async {
repo.initial = '2';
sl.registerSingleton(WatchDeviceControlModeUseCase(repo));
sl.registerSingleton(ChangeDeviceControlModeUseCase(repo));
var stops = 0;
var originalStops = 0;
var drives = 0;
var activations = 0;
await tester.pumpWidget(
app(
ControlModeEntryGate(
deviceId: 'SN002',
target: ControlModeTarget.remote,
cancelToPreview: true,
emergencyStopControl: TextButton(
onPressed: () => stops++,
child: const Text('independent stop'),
),
onReady: () => activations++,
child: Scaffold(
body: Column(
children: [
ModeIndependentControl(
child: TextButton(
key: const Key('original-stop'),
onPressed: () => originalStops++,
child: const Text('original stop'),
),
),
Builder(
builder: (context) => ModeIndependentControl(
child: IconButton(
key: const Key('independent-settings'),
icon: const Icon(Icons.settings),
onPressed: () => showDialog<void>(
context: context,
builder: (dialogContext) => AlertDialog(
title: const Text('video settings'),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(),
child: const Text('close settings'),
),
],
),
),
),
),
),
TextButton(
key: const Key('blocked-drive'),
onPressed: () => drives++,
child: const Text('drive'),
),
],
),
),
),
),
);
await tester.pumpAndSettle();
// 模式弹窗内急停可用,不会触发模式切换或激活遥控。
await tester.tap(find.text('independent stop').last);
expect(stops, 1);
expect(repo.requests, isEmpty);
expect(activations, 0);
await tester.tap(find.byIcon(Icons.close_rounded).first);
await tester.pumpAndSettle();
expect(find.text('independent stop'), findsNothing);
await tester.tap(find.byKey(const Key('original-stop')));
expect(originalStops, 1);
expect(stops, 1);
await tester.tap(find.byKey(const Key('independent-settings')));
await tester.pumpAndSettle();
expect(find.text('video settings'), findsOneWidget);
await tester.tap(find.text('close settings'));
await tester.pumpAndSettle();
await tester.tap(
find.byKey(const Key('blocked-drive')),
warnIfMissed: false,
);
expect(drives, 0);
expect(activations, 0);
expect(repo.requests, isEmpty);
});
testWidgets('取消遥控模式确认返回来源页,不激活控制或下发切换', (tester) async {
repo.initial = '2';
sl.registerSingleton(WatchDeviceControlModeUseCase(repo));