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,54 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ttstd_sender/core/diagnostic_log.dart';
|
||||
|
||||
void main() {
|
||||
test(
|
||||
'asynchronous logs preserve order, redact tokens and finish after dispose',
|
||||
() async {
|
||||
final log = DiagnosticLog(
|
||||
'ttstd_log_test_${DateTime.now().microsecondsSinceEpoch}.log');
|
||||
log.start();
|
||||
final file = File(log.path);
|
||||
addTearDown(() async {
|
||||
await log.flush();
|
||||
if (await file.exists()) await file.delete();
|
||||
});
|
||||
log.write('first #token=secret');
|
||||
log.write('second');
|
||||
log.dispose();
|
||||
await log.flush();
|
||||
final text = await file.readAsString();
|
||||
expect(text, contains('first #token=[redacted]'));
|
||||
expect(text, isNot(contains('secret')));
|
||||
expect(text.indexOf('first'), lessThan(text.indexOf('second')));
|
||||
expect(text.indexOf('second'), lessThan(text.indexOf('=== stopped ===')));
|
||||
});
|
||||
|
||||
test('log rotation and failed writes do not prevent later writes', () async {
|
||||
final log = DiagnosticLog(
|
||||
'ttstd_log_test_${DateTime.now().microsecondsSinceEpoch}.log');
|
||||
log.start();
|
||||
final file = File(log.path);
|
||||
addTearDown(() async {
|
||||
log.dispose();
|
||||
await log.flush();
|
||||
if (await file.exists()) await file.delete();
|
||||
});
|
||||
await file.writeAsString('x' * (2 * 1024 * 1024 + 1));
|
||||
log.write('after rotation');
|
||||
await log.flush();
|
||||
expect(
|
||||
await file.readAsString(),
|
||||
allOf(contains('log rotated:'), contains('after rotation'),
|
||||
isNot(startsWith('xxx'))));
|
||||
await file.delete();
|
||||
log.write('unavailable file');
|
||||
await log.flush();
|
||||
await file.writeAsString('recovered\n');
|
||||
log.write('after recovery');
|
||||
await log.flush();
|
||||
expect(await file.readAsString(), contains('after recovery'));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ttstd_sender/core/pairing_input.dart';
|
||||
import '../fixtures/pairing_qr.dart';
|
||||
|
||||
void main() {
|
||||
test('parses pairing links in copied text and validates identity fields', () {
|
||||
expect(parsePairingText('配对信息:\n$pairingText\n').ip, '192.168.100.141');
|
||||
for (final invalid in [
|
||||
'hello',
|
||||
'$pairingText\n$pairingText',
|
||||
pairingText.replaceFirst('41001', '70000'),
|
||||
pairingText.replaceFirst('192.168.100.141', 'invalid'),
|
||||
'lancast://pair?ip=127.0.0.1&port=41001',
|
||||
'$pairingText&tls=invalid'
|
||||
]) {
|
||||
expect(() => parsePairingText(invalid), throwsFormatException);
|
||||
}
|
||||
});
|
||||
test('decodes color, grayscale and rotated QR images', () {
|
||||
for (final bytes in [
|
||||
pairingQr(),
|
||||
pairingQr(grayscale: true),
|
||||
pairingQr(rotate: true)
|
||||
]) {
|
||||
final result = parsePairingImage(bytes);
|
||||
expect(result.deviceId, 'test-qr');
|
||||
expect(result.ip, '192.168.100.141');
|
||||
}
|
||||
});
|
||||
test('rejects malformed or oversized image data', () {
|
||||
expect(() => parsePairingImage(Uint8List.fromList([1, 2, 3])),
|
||||
throwsFormatException);
|
||||
expect(() => parsePairingImage(Uint8List(maxPairingImageBytes + 1)),
|
||||
throwsFormatException);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user