Files
admin 0a3f2c5cc6 v1.3.13: 模块化注册架构 + PDS流程设计套件更名 + 依赖/圆周交互修复
- 模块化:EdcModule 契约 + registry + 模块独立目录;发布包增加 modules/registry.json
- 更名:PDS流程设计套件 / ProcessDesignSuite;同步构建、发布脚本与文档
- 时序图:依赖偏移以时间显示/编辑;紧贴依赖隐藏箭头并在接缝显示标签;动作条磁吸
- 圆周:依赖标签沿圆弧方向、环间空隙;动作旋转磁吸增强;短弧标签优先动作名
- 清理:release 移至源码同级(本地不入库);tool 合并到 tools;发布说明迁移 docs/release-notes
2026-11-22 10:02:54 +08:00

73 lines
2.1 KiB
Dart

// 动作条整体拖拽吸附:起点/终点同时匹配最近端点、整 5° 与分区边界。
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/modules/sequence/layout/snap.dart';
import 'package:sequence_diagram/model/models.dart';
Project _project(List<Action> actions) {
return Project(
name: 'snap',
cycle: const Cycle(durationMs: 2400),
stations: const <Station>[
Station(id: 'ST1', name: 'S', order: 0, color: 0xFF4CC9F0),
],
actions: actions,
units: const UnitSettings(),
viewState: const ViewState(mode: ViewMode.bar),
);
}
Action _a(String id, double start, double duration) {
return Action(
id: id,
name: id,
stationId: 'ST1',
driver: '',
startAngle: start,
durationAngle: duration,
layer: 0,
color: 0xFF4CC9F0,
);
}
void main() {
test('整体拖动:起点吸附到上游动作结束角', () {
final Project p = _project(<Action>[_a('A1', 0, 40), _a('A2', 80, 40)]);
final (double start, double? guide) = snapActionStart(
project: p,
excludeId: 'A2',
rawStart: 41.5,
duration: 40,
toleranceDeg: 3.5,
);
expect(start, closeTo(40, 0.001));
expect(guide, closeTo(40, 0.001));
});
test('整体拖动:终点吸附到下游动作起始角', () {
final Project p = _project(<Action>[_a('A1', 100, 40), _a('A2', 63, 38)]);
final (double start, double? guide) = snapActionStart(
project: p,
excludeId: 'A2',
rawStart: 63,
duration: 38,
toleranceDeg: 2.5,
);
// 末端 101 距 A1 起点 100 仅 1°,优先于起点附近的 5° 网格。
expect(start, closeTo(62, 0.001));
expect(guide, closeTo(100, 0.001));
});
test('整体拖动:容差外不吸附', () {
final Project p = _project(<Action>[_a('A1', 0, 40), _a('A2', 123.4, 40)]);
final (double start, double? guide) = snapActionStart(
project: p,
excludeId: 'A2',
rawStart: 123.4,
duration: 40,
toleranceDeg: 1.0,
);
expect(start, closeTo(123.4, 0.001));
expect(guide, isNull);
});
}