Files
EasyDesignCollection/test/tablet_screenshots_test.dart
T
admin fe5e0be131 feat(flow): 泳道拓宽计划(空泳道策略 + 多槽位泳道,三视图同步);发布 v1.3.4
- 空泳道策略(F2 文档设置 →「泳道」):动作全部移走的泳道可保留(默认,序号不变)
  或自动移除;条形空行 / 圆周空环 / 流程空列与左侧栏占位行同步
- 泳道加宽(1–5 槽):双击条形视图左侧泳道编号 / 右键空白泳道 / 左侧栏「N 槽」徽标;
  条形分子行(浅色虚线分隔)、圆周同色加宽环带 + 槽位虚线、流程图分子列且泳道带
  随内容智能加宽;拖拽动作同时换道 + 换槽位;旧数据零迁移(row 语义改为槽位并自动钳制)
- 流程图智能排开:同源同层扇出连线在空隙内均匀铺开;同层节点水平重叠自动推开
- 显示修复:画布左栏标题按真实行高排版(灰色副标题不再被换行标题压住,
  持续换行到泳道高度不足);多槽位采用「槽位紧凑 + 泳道间拉开」的间隔
- 「时序创建和编辑」更名为「文档设置」(含对话框标题/帮助/文档);新增自动保存
  (默认 10 分钟,可选 1/5/10/30 或关闭;写入文件并同步 .bak)
- 授权临时冻结(kLicenseRequired=false):桌面版导出无需 .lic;关于页授权状态
  「开放授权版本」、EDC 版权、开发者与交流群(邮箱 liuyu65@126.com、微信 online-goose)
- 更新体验:直接升级到最新版本提示、下载过程保持屏幕常亮提示、
  下载/上传统一限速 320KB/s(客户端限速 + 发布脚本 --limit-rate 320k)
- docs/HELP.md 与帮助中心同步更新;新增 docs/ROADMAP.md 开发路线图
- flutter analyze 0 问题、40 项测试全过;演示截图更新(含泳道加宽与拥挤场景验证图)
2026-10-10 09:21:45 +08:00

133 lines
5.1 KiB
Dart

// 平板版演示截图生成:把整个应用外壳在 1280×800(平板横屏基准)下渲染为 PNG。
// 运行方式:flutter test --update-goldens test\tablet_screenshots_test.dart
// 输出:demo/tablet-*.png
import 'package:flutter/material.dart' hide Action;
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/model/models.dart';
import 'package:sequence_diagram/state/app_controller.dart';
import 'package:sequence_diagram/theme/tokens.dart';
import 'package:sequence_diagram/ui/app_shell.dart';
import 'helpers.dart';
void main() {
testWidgets('generate tablet demo screenshots', (WidgetTester tester) async {
await tester.runAsync(() => loadZhFonts());
await tester.runAsync(() => loadMaterialIcons());
tester.view.physicalSize = const Size(1280, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.reset);
final AppController c = AppController(project: demoTiming());
addTearDown(c.dispose);
Widget shell(Tokens t) => RepaintBoundary(
key: const ValueKey<String>('shot'),
child: MaterialApp(
theme: buildTheme(t),
debugShowCheckedModeBanner: false,
home: AppShell(controller: c),
),
);
Future<void> shot(String path) async {
await tester.pump();
await expectLater(find.byKey(const ValueKey<String>('shot')), matchesGoldenFile(path));
}
await tester.pumpWidget(shell(Tokens.light));
await shot('../demo/tablet-bar-light.png');
// 展开左右侧栏(浮层)并钉住,展示停靠布局。
// 注意:不能用 find.byIcon(Icons.chevron_right)——画布右下角的预览卡里
// 也有同类图标且更早出现在组件树中,会误触「切换视图」;改为按坐标点贴边轨道。
await tester.tapAt(const Offset(10, 300));
await tester.pump();
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
await tester.tapAt(const Offset(1270, 300));
await tester.pump();
if (tester.any(find.byIcon(Icons.push_pin_outlined))) {
await tester.tap(find.byIcon(Icons.push_pin_outlined).first);
await tester.pump();
}
await shot('../demo/tablet-bar-light-panels.png');
// 圆周视图(浅色,含停靠侧栏)。
c.setViewMode(ViewMode.circular);
await shot('../demo/tablet-circular-light.png');
// 流程图视图(浅色):由时序图自动生成(泳道 = 轨道,只读)。
c.setViewMode(ViewMode.flow);
await shot('../demo/tablet-flow-light.png');
// 流程图导出菜单:SVG / PNG 之外额外提供 drawio 入口(仅流程图)。
await tester.tap(find.text('导出'));
await tester.pumpAndSettle();
await shot('../demo/tablet-flow-export-menu-light.png');
await tester.tapAt(const Offset(5, 5));
await tester.pumpAndSettle();
// 选中动作:右侧属性面板进入只读态(滑块 / 依赖编辑置灰)。
c.select('A2');
await shot('../demo/tablet-flow-selected-light.png');
c.select(null);
// 深色主题:条形、圆周与流程图。
// 注意:MaterialApp 的主题切换带 200ms 过渡动画,必须等动画结束再截图,
// 否则截到的是过渡起点(仍然是浅色)。
c.toggleTheme();
await tester.pumpWidget(shell(Tokens.dark));
await tester.pump(const Duration(milliseconds: 400));
c.setViewMode(ViewMode.bar);
await shot('../demo/tablet-bar-dark.png');
c.setViewMode(ViewMode.circular);
await shot('../demo/tablet-circular-dark.png');
c.setViewMode(ViewMode.flow);
await shot('../demo/tablet-flow-dark.png');
// ---- 1.3.4 泳道加宽(多槽位)演示(浅色)----
// L1 加宽为 2 槽,并把「定位夹紧」放到槽 2;三种视图各出一张对照图。
c.toggleTheme();
await tester.pumpWidget(shell(Tokens.light));
await tester.pump(const Duration(milliseconds: 400));
c.setLaneSlots(0, 2);
c.moveActionTo('A2', 0, 1);
c.select(null);
c.setViewMode(ViewMode.bar);
await shot('../demo/tablet-bar-slots-light.png');
c.setViewMode(ViewMode.circular);
await shot('../demo/tablet-circular-slots-light.png');
c.setViewMode(ViewMode.flow);
await shot('../demo/tablet-flow-slots-light.png');
// ---- 拥挤场景复核:单泳道 5 槽 + 10 个动作(标题持续换行、灰字不被压住)----
final Project base = demoTiming();
final List<Action> many = <Action>[...base.actions];
for (int i = 0; i < 8; i++) {
many.add(Action(
id: 'X$i',
name: '动作 ${i + 6}',
stationId: 'ST1',
driver: '气缸 Y${i + 1}',
startAngle: 5.0 + i * 12.0,
durationAngle: 8,
layer: 0,
row: i % 5,
color: kActionPalette[i % kActionPalette.length],
));
}
c.loadProject(base.copyWith(
actions: many,
laneSlots: <int, int>{0: 5},
autoSaveEnabled: false,
));
c.select(null);
c.setViewMode(ViewMode.bar);
await shot('../demo/tablet-bar-crowded-light.png');
});
}