89cc3189cc
- 产品名:时序图设计器 Sequence Diagram Studio(窗口标题/帮助关于/README/RC/素材同步) - 图标改为亮色渐变+白色时钟,深色任务栏下清晰可见 - 工具栏新增紧凑布局(图标化/导出菜单),1920x1080 及 150% 缩放(1280 逻辑宽)下完整显示 - 对话框以 1920x1080 为基准等比放大(<=1.75x),更小窗口不缩小 - 默认循环周期 2400ms -> 3600ms(3.6s = 360°) - 重新构建 dist
61 lines
1.9 KiB
Dart
61 lines
1.9 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);
|
|
expect(decoded.actions.last.deps.first.type, DepType.fs);
|
|
expect(decoded.cycle.durationMs, 3600);
|
|
expect(decoded.actions.last.color, p.actions.last.color);
|
|
});
|
|
});
|
|
}
|