v1.3.10: 应用身份切换 cc.sincos.edc(彻底解决桌面名称); 移除尺寸标注与图元库自定义; 修复帮助中心空白与 Windows 更新包校验
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// 架构图属性面板回归:选中图形后「尺寸 · mm」可见、可改值驱动几何。
|
||||
// 架构图属性面板回归:选中图元后显示基本信息;已移除的「尺寸标注」不再出现。
|
||||
import 'package:flutter/material.dart' hide Action;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sequence_diagram/arch/arch_models.dart';
|
||||
@@ -8,7 +8,7 @@ import 'package:sequence_diagram/theme/tokens.dart';
|
||||
import 'package:sequence_diagram/ui/arch_panel.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('选中图元后右栏出现「尺寸 · mm」,改值直接缩放几何',
|
||||
testWidgets('选中图元:属性卡正常显示,且不再有「尺寸 · mm」区',
|
||||
(WidgetTester tester) async {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
c.addArchShape(const ArchShape(
|
||||
@@ -26,21 +26,12 @@ void main() {
|
||||
));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.textContaining('尺寸 · mm'), findsOneWidget);
|
||||
expect(find.textContaining('标注全部'), findsOneWidget);
|
||||
expect(find.text('80.0 mm'), findsOneWidget);
|
||||
expect(find.text('150.0 mm'), findsOneWidget);
|
||||
// 属性卡正常渲染(图元类型中文名)。
|
||||
expect(find.textContaining('图元'), findsWidgets);
|
||||
// 已移除:尺寸标注区不存在。
|
||||
expect(find.textContaining('尺寸 · mm'), findsNothing);
|
||||
|
||||
// 点宽度值 → 弹出改值对话框 → 输入 160 → 几何宽变 160。
|
||||
await tester.tap(find.text('80.0 mm'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('编辑宽度'), findsOneWidget);
|
||||
await tester.enterText(find.byType(TextField), '160');
|
||||
await tester.tap(find.text('确定'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(c.arch.shapeById('S1')!.rect.width, 160);
|
||||
|
||||
// 清理:先卸载组件树,再释放控制器(避免已释放断言)。
|
||||
// 清理:先卸载组件树,再释放控制器。
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
c.dispose();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// 图元库手绘识别测试:内置符号笔迹命中、乱涂拒绝、自定义图元可识别。
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -108,41 +107,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('自定义图元:保存到用户目录后能被识别', () async {
|
||||
final Directory tmp = await Directory.systemTemp.createTemp('edc-symr-');
|
||||
addTearDown(() async => tmp.delete(recursive: true));
|
||||
// 自定义三角形图元。
|
||||
await SymbolLibrary.saveUser(
|
||||
const LibSymbol(
|
||||
id: 'my-tri',
|
||||
name: '自定义三角',
|
||||
category: '自定义',
|
||||
prims: <SymPrim>[
|
||||
SymPrim(
|
||||
kind: SymPrimKind.polyline,
|
||||
pts: <double>[50, 10, 90, 80, 10, 80, 50, 10],
|
||||
),
|
||||
],
|
||||
pins: <SymPin>[],
|
||||
),
|
||||
dir: tmp,
|
||||
);
|
||||
final List<LibSymbol> catalog = await SymbolLibrary.all(dir: tmp);
|
||||
final ArchSymbolMatch? m = recognizeArchSymbol(
|
||||
<List<Offset>>[
|
||||
<Offset>[
|
||||
const Offset(50, 10),
|
||||
const Offset(90, 80),
|
||||
const Offset(10, 80),
|
||||
const Offset(50, 10),
|
||||
],
|
||||
],
|
||||
catalog,
|
||||
);
|
||||
expect(m, isNotNull, reason: '自定义图元应能被识别(图元库可扩展)');
|
||||
expect(m!.symbol.id, 'my-tri');
|
||||
});
|
||||
|
||||
test('空 / 过短笔迹:null', () {
|
||||
expect(recognizeArchSymbol(const <List<Offset>>[], SymbolLibrary.builtin), isNull);
|
||||
expect(
|
||||
|
||||
+1
-81
@@ -658,87 +658,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('尺寸编辑(识别后图形)', () {
|
||||
test('矩形宽 / 圆直径:直接缩放且中心保持', () {
|
||||
const ArchShape rect = ArchShape(
|
||||
id: 'D1',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(100, 100, 200, 120),
|
||||
);
|
||||
final ArchShape w = archShapeApplyDim(rect, ArchDimKind.width, 300);
|
||||
expect(w.rect.width, 300);
|
||||
expect(w.rect.center, rect.rect.center);
|
||||
expect(w.rect.height, 120);
|
||||
final ArchShape c = archShapeApplyDim(
|
||||
const ArchShape(
|
||||
id: 'D2',
|
||||
type: ArchShapeType.circle,
|
||||
rect: Rect.fromLTWH(0, 0, 80, 80),
|
||||
),
|
||||
ArchDimKind.diameter,
|
||||
120,
|
||||
);
|
||||
expect(c.rect.width, 120);
|
||||
expect(c.rect.height, 120);
|
||||
});
|
||||
|
||||
test('直线 / 曲线长度:按比例缩放保持形状', () {
|
||||
const ArchShape line = ArchShape(
|
||||
id: 'L1',
|
||||
type: ArchShapeType.line,
|
||||
rect: Rect.fromLTWH(0, 0, 100, 0),
|
||||
a: Offset(0, 0),
|
||||
b: Offset(100, 0),
|
||||
);
|
||||
expect(archShapeDimValue(line, ArchDimKind.length), 100);
|
||||
final ArchShape l2 = archShapeApplyDim(line, ArchDimKind.length, 250);
|
||||
expect(archShapeDimValue(l2, ArchDimKind.length), closeTo(250, 0.01));
|
||||
expect(l2.rect.center, line.rect.center);
|
||||
|
||||
const ArchShape curve = ArchShape(
|
||||
id: 'C1',
|
||||
type: ArchShapeType.curve,
|
||||
rect: Rect.fromLTWH(0, 0, 100, 50),
|
||||
pts: <Offset>[Offset(0, 0), Offset(100, 0), Offset(100, 50)],
|
||||
);
|
||||
expect(archShapeLength(curve), closeTo(150, 0.01));
|
||||
final ArchShape c2 = archShapeApplyDim(curve, ArchDimKind.length, 300);
|
||||
expect(archShapeLength(c2), closeTo(300, 0.5));
|
||||
final Rect b2 = archLinearBounds(c2);
|
||||
expect(b2.width / b2.height, closeTo(2.0, 0.01));
|
||||
});
|
||||
|
||||
test('尺寸标注 JSON 往返', () {
|
||||
const ArchShape s = ArchShape(
|
||||
id: 'S1',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(0, 0, 100, 80),
|
||||
dims: <ArchDimKind>{ArchDimKind.width, ArchDimKind.height},
|
||||
);
|
||||
final ArchShape back = ArchShape.fromJson(
|
||||
jsonDecode(jsonEncode(s.toJson())) as Map<String, dynamic>);
|
||||
expect(back.dims.contains(ArchDimKind.width), isTrue);
|
||||
expect(back.dims.contains(ArchDimKind.height), isTrue);
|
||||
});
|
||||
|
||||
test('控制器:改值缩放 + 标注开关', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
addTearDown(c.dispose);
|
||||
c.addArchShape(const ArchShape(
|
||||
id: 'S1',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(10, 10, 100, 60),
|
||||
));
|
||||
c.setArchShapeDim('S1', ArchDimKind.width, 260);
|
||||
expect(c.arch.shapeById('S1')!.rect.width, 260);
|
||||
c.toggleArchShapeDim('S1', ArchDimKind.width);
|
||||
expect(
|
||||
c.arch.shapeById('S1')!.dims.contains(ArchDimKind.width), isTrue);
|
||||
c.toggleArchShapeDim('S1', ArchDimKind.width);
|
||||
expect(
|
||||
c.arch.shapeById('S1')!.dims.contains(ArchDimKind.width), isFalse);
|
||||
});
|
||||
|
||||
group('默认画布', () {
|
||||
test('默认画布 A0:空文档内容边界 1189×841', () {
|
||||
final Rect b = ArchDoc.empty.contentBounds();
|
||||
expect(b.width, 1189);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// 帮助中心回归:垂直导航正常渲染、可切换分页,内容不为空。
|
||||
import 'package:flutter/material.dart' hide Action;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sequence_diagram/theme/tokens.dart';
|
||||
import 'package:sequence_diagram/ui/dialogs.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('帮助中心:垂直导航 + 内容非空 + 可切到「关于」', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: buildTheme(Tokens.light),
|
||||
home: const Scaffold(body: HelpDialog()),
|
||||
));
|
||||
await tester.pump();
|
||||
|
||||
// 左侧垂直导航:分页标题可见。
|
||||
expect(find.text('首页与模块'), findsOneWidget);
|
||||
expect(find.text('架构图 · 绘制识别'), findsOneWidget);
|
||||
expect(find.text('关于'), findsOneWidget);
|
||||
|
||||
// 内容区非空:首个分页的问答项存在(IndexedStack 全部子页在树中)。
|
||||
expect(find.text('打开软件是空白首页'), findsOneWidget);
|
||||
|
||||
// 切到「关于」分页:不应抛异常,且关于页内容在树中。
|
||||
await tester.tap(find.text('关于'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('EDC|易得设计'), findsWidgets);
|
||||
});
|
||||
}
|
||||
@@ -126,12 +126,6 @@ ArchDoc makeArch() => ArchDoc(
|
||||
symbolId: ArchShapeType.values[i] == ArchShapeType.symbol
|
||||
? 'pe-ground'
|
||||
: '',
|
||||
dims: i == 0
|
||||
? const <ArchDimKind>{
|
||||
ArchDimKind.width,
|
||||
ArchDimKind.height,
|
||||
}
|
||||
: const <ArchDimKind>{},
|
||||
),
|
||||
],
|
||||
strokes: const <ArchStroke>[
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// 图元库测试:内置符号完整性、JSON 往返、用户目录存取与合并覆盖、坐标换算。
|
||||
import 'dart:io';
|
||||
import 'dart:ui' show Path, Rect;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -57,50 +56,4 @@ void main() {
|
||||
expect(b.top, closeTo(20, 0.01));
|
||||
expect(b.bottom, closeTo(220, 0.01));
|
||||
});
|
||||
|
||||
test('用户目录存取 / 删除 / all() 合并与覆盖', () async {
|
||||
final Directory tmp = await Directory.systemTemp.createTemp('edc-sym-');
|
||||
addTearDown(() async => tmp.delete(recursive: true));
|
||||
expect(await SymbolLibrary.loadUser(dir: tmp), isEmpty);
|
||||
|
||||
const LibSymbol custom = LibSymbol(
|
||||
id: 'my-sym',
|
||||
name: '自定义符号',
|
||||
category: '自定义',
|
||||
prims: <SymPrim>[
|
||||
SymPrim(kind: SymPrimKind.circle, pts: <double>[50, 50], r: 30),
|
||||
],
|
||||
pins: <SymPin>[SymPin(id: '1', x: 50, y: 0)],
|
||||
);
|
||||
await SymbolLibrary.saveUser(custom, dir: tmp);
|
||||
final List<LibSymbol> loaded = await SymbolLibrary.loadUser(dir: tmp);
|
||||
expect(loaded.single.id, 'my-sym');
|
||||
|
||||
final List<LibSymbol> merged = await SymbolLibrary.all(dir: tmp);
|
||||
expect(merged.length, SymbolLibrary.builtin.length + 1);
|
||||
|
||||
// 用户符号覆盖同名内置 id。
|
||||
await SymbolLibrary.saveUser(
|
||||
const LibSymbol(
|
||||
id: 'motor-m',
|
||||
name: '电机(自定义)',
|
||||
category: '自定义',
|
||||
prims: <SymPrim>[
|
||||
SymPrim(kind: SymPrimKind.rect, pts: <double>[20, 20, 60, 60]),
|
||||
],
|
||||
pins: <SymPin>[SymPin(id: '1', x: 50, y: 0)],
|
||||
),
|
||||
dir: tmp,
|
||||
);
|
||||
final List<LibSymbol> merged2 = await SymbolLibrary.all(dir: tmp);
|
||||
expect(merged2.length, SymbolLibrary.builtin.length + 1);
|
||||
expect(
|
||||
merged2.firstWhere((LibSymbol s) => s.id == 'motor-m').name,
|
||||
'电机(自定义)',
|
||||
);
|
||||
|
||||
await SymbolLibrary.deleteUser('my-sym', dir: tmp);
|
||||
await SymbolLibrary.deleteUser('motor-m', dir: tmp);
|
||||
expect(await SymbolLibrary.loadUser(dir: tmp), isEmpty);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user