f4ef9b32a5
- 流程图视图:泳道 = 轨道、FS/SS 依赖连线、关键路径高亮、相位阶段栏 (每个动作行归属覆盖占比最大的分区,重叠分区台阶错位) - 无前置依赖的动作从「开始」并列引出(并行分支),无后继动作汇入「结束」 - 流程图只读:AI 生成 / 撤销重做 / 动作增删 / 属性与依赖编辑等入口自动置灰, 左栏视图模式只保留条形 / 圆周(流程图入口在顶部工具栏) - 导出升级:导出按钮合并为下拉菜单,SVG / PNG 三种视图通用; 流程图额外支持 drawio(diagrams.net 可继续编辑泳道 / 相位 / 依赖) - 连线走线统一收敛到 FlowLayout.routes,画布 / SVG / drawio 共用同一几何 - 默认示例升级为完整「装配线节拍」(8 动作 / 3 工位 / 4 相位分区) - 版本号 1.3.0+16,更新说明 release/RELEASE_NOTES_v1.3.0.md
62 lines
2.0 KiB
Dart
62 lines
2.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:sequence_diagram/model/models.dart';
|
|
import 'package:sequence_diagram/model/units.dart';
|
|
|
|
void main() {
|
|
group('units', () {
|
|
test('time conversion', () {
|
|
const UnitSettings u = UnitSettings(timeUnit: TimeUnit.s);
|
|
expect(tfmt(2400, u), '2.400 s');
|
|
expect(tfmt(467, u), '0.467 s');
|
|
const UnitSettings ms = UnitSettings(timeUnit: TimeUnit.ms);
|
|
expect(tfmt(467, ms), '467 ms');
|
|
expect(parseDuration('700ms', u), 700);
|
|
expect(parseDuration('0.7s', u), 700);
|
|
expect(parseDuration('0.7', u), 700);
|
|
});
|
|
|
|
test('phase conversion', () {
|
|
expect(pfmt(105, const UnitSettings()), '105.0°');
|
|
expect(pfmt(105, const UnitSettings(phaseUnit: PhaseUnit.percent)), '29.17%');
|
|
expect(parsePhase('29.17%'), closeTo(105.012, 0.01));
|
|
expect(parsePhase('105°'), 105);
|
|
});
|
|
|
|
test('snap and normalize', () {
|
|
expect(snapTo(103, 5), 105);
|
|
expect(normalizeAngle(-10), 350);
|
|
expect(normalizeAngle(370), 10);
|
|
});
|
|
});
|
|
|
|
group('model', () {
|
|
test('wrap detection', () {
|
|
final Action a = Action(
|
|
id: 'A8',
|
|
name: '清洁',
|
|
stationId: 'ST3',
|
|
driver: '',
|
|
startAngle: 340,
|
|
durationAngle: 45,
|
|
layer: 7,
|
|
color: kActionPalette[0],
|
|
);
|
|
expect(a.wrap, isTrue);
|
|
expect(a.endAngle, 385);
|
|
});
|
|
|
|
test('json round trip', () {
|
|
final Project p = Project.demo();
|
|
final String encoded = p.encode();
|
|
final Project decoded = Project.decode(encoded);
|
|
expect(decoded.actions.length, p.actions.length);
|
|
expect(decoded.stations.length, p.stations.length);
|
|
expect(decoded.phaseZones.length, p.phaseZones.length);
|
|
final Action withDeps = decoded.actions.firstWhere((Action a) => a.deps.isNotEmpty);
|
|
expect(withDeps.deps.first.type, DepType.fs);
|
|
expect(decoded.cycle.durationMs, 2400);
|
|
expect(decoded.actions.last.color, p.actions.last.color);
|
|
});
|
|
});
|
|
}
|