feat(desktop): 支持粘贴配对并修复串流与设备切换
- 支持 Ctrl+V 粘贴配对文本和二维码图片,预览确认后识别校验 - 修复控制发送阻塞、TLS 读写争锁、设备切换沿用旧连接及串流误关窗 - 优化媒体加密上下文、UDP 接收缓冲和异步诊断日志 - 安装器按路径停止主控与信令进程,统一递增版本、打包和清理旧产物 - 发布 0.1.3+4,通过三端编译、20 项 Flutter 测试和 58 项 Rust 单元测试
This commit is contained in:
1 parent
f6b7730684
commit
3cd72d70e1
38 files changed
+1173
-196
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ttstd_sender/core/pairing.dart';
|
||||
import 'package:ttstd_sender/core/pairing_input.dart';
|
||||
import 'package:ttstd_sender/features/discovery/pairing_paste_dialog.dart';
|
||||
import 'fixtures/pairing_qr.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> open(WidgetTester tester, PairingPasteDialog dialog,
|
||||
void Function(PairingUri?) result) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () async => result(await showDialog<PairingUri>(
|
||||
context: context, builder: (_) => dialog)),
|
||||
child: const Text('open'),
|
||||
))));
|
||||
await tester.tap(find.text('open'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('Ctrl+V previews text; only confirmation returns a pairing',
|
||||
(tester) async {
|
||||
PairingUri? result;
|
||||
await open(
|
||||
tester,
|
||||
PairingPasteDialog(
|
||||
readClipboard: () async =>
|
||||
PairingClipboardContent(text: pairingText)),
|
||||
(value) => result = value);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyV);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlLeft);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(pairingText), findsOneWidget);
|
||||
expect(result, isNull);
|
||||
await tester.tap(find.text('确认配对'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(result?.ip, '192.168.100.141');
|
||||
});
|
||||
|
||||
testWidgets('pasting image does not decode until confirmation',
|
||||
(tester) async {
|
||||
var decodes = 0;
|
||||
PairingUri? result;
|
||||
await open(
|
||||
tester,
|
||||
PairingPasteDialog(
|
||||
readClipboard: () async =>
|
||||
PairingClipboardContent(image: pairingQr()),
|
||||
decodeImage: (_) async {
|
||||
decodes++;
|
||||
return parsePairingText(pairingText);
|
||||
},
|
||||
),
|
||||
(value) => result = value);
|
||||
await tester.tap(find.text('粘贴'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(Image), findsOneWidget);
|
||||
expect(decodes, 0);
|
||||
expect(result, isNull);
|
||||
await tester.tap(find.text('确认配对'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(decodes, 1);
|
||||
expect(result?.deviceId, 'test-qr');
|
||||
});
|
||||
|
||||
testWidgets('invalid text remains in dialog and can be replaced or cancelled',
|
||||
(tester) async {
|
||||
var text = 'invalid text';
|
||||
PairingUri? result;
|
||||
await open(
|
||||
tester,
|
||||
PairingPasteDialog(
|
||||
readClipboard: () async => PairingClipboardContent(text: text)),
|
||||
(value) => result = value);
|
||||
await tester.tap(find.text('粘贴'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('配对链接无效'), findsNothing);
|
||||
await tester.tap(find.text('确认配对'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('配对链接无效'), findsOneWidget);
|
||||
expect(find.byType(PairingPasteDialog), findsOneWidget);
|
||||
text = pairingText;
|
||||
await tester.tap(find.text('粘贴'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('配对链接无效'), findsNothing);
|
||||
await tester.tap(find.text('取消'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(result, isNull);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user