mirror of
https://github.com/WT810787899/YuChuan.git
synced 2026-12-05 08:00:43 +00:00
- 应用图标:由 icon.png 生成 Android 各密度 mipmap 与 Windows app_icon.ico, 生成脚本 scripts/gen_icons.py 可重复执行(不引入额外 pub 依赖) - README:重写为「功能 / 用途 / 截图」(原内容是无关的模板残留) - .gitignore:排除构建产物(build/、target/)、本地备份、过程文档、 图标设计源文件与历史截图
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:rust_flutter_ui/services/single_instance.dart';
|
|
|
|
void main() {
|
|
test('单实例交接:清单送达运行中的实例并拿到 OK', () async {
|
|
final received = <String>[];
|
|
final infoFile =
|
|
File('${Directory.systemTemp.path}\\yuchuan_test_instance.json');
|
|
final server = await SingleInstance.startControlServer(
|
|
onShare: received.addAll,
|
|
writeInfoFile: true,
|
|
infoFile: infoFile,
|
|
);
|
|
expect(server, isNotNull);
|
|
|
|
final ok = await SingleInstance.handoffToRunningInstance(
|
|
['D:\\a.mp4', 'D:\\b.txt'],
|
|
infoFile: infoFile,
|
|
);
|
|
expect(ok, isTrue);
|
|
expect(received, ['D:\\a.mp4', 'D:\\b.txt']);
|
|
|
|
await server!.close();
|
|
try {
|
|
infoFile.deleteSync();
|
|
} catch (_) {}
|
|
});
|
|
|
|
test('单实例交接:没有运行中实例时按失败返回(照常启动)', () async {
|
|
final infoFile =
|
|
File('${Directory.systemTemp.path}\\yuchuan_test_instance_missing.json');
|
|
final ok = await SingleInstance.handoffToRunningInstance(
|
|
['D:\\a.mp4'],
|
|
infoFile: infoFile,
|
|
);
|
|
expect(ok, isFalse);
|
|
});
|
|
}
|