80 lines
2.9 KiB
Dart
80 lines
2.9 KiB
Dart
|
|
// 平板/多分辨率布局回归测试:在多种分辨率、主题、视图模式下泵出整个外壳,
|
|||
|
|
// 并展开/停靠侧栏,确保无溢出异常(RenderFlex overflow 会导致测试失败)。
|
|||
|
|
import 'package:flutter/material.dart';
|
|||
|
|
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() {
|
|||
|
|
const List<(String, Size, double)> cases = <(String, Size, double)>[
|
|||
|
|
('tablet-landscape', Size(1280, 800), 1.0),
|
|||
|
|
('tablet-landscape-2x', Size(1280, 800), 2.0), // 物理 2560×1600
|
|||
|
|
('wide-1920', Size(1920, 1080), 1.0),
|
|||
|
|
('small-960', Size(960, 600), 1.0),
|
|||
|
|
('phone-landscape-800', Size(800, 480), 1.0),
|
|||
|
|
('portrait-800x1280', Size(800, 1280), 1.0),
|
|||
|
|
('portrait-600x960', Size(600, 960), 1.0),
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
for (final (String name, Size size, double dpr) in cases) {
|
|||
|
|
testWidgets('layout @ $name ${size.width}x${size.height} dpr=$dpr 无溢出', (WidgetTester tester) async {
|
|||
|
|
tester.view.physicalSize = size * dpr;
|
|||
|
|
tester.view.devicePixelRatio = dpr;
|
|||
|
|
addTearDown(tester.view.reset);
|
|||
|
|
|
|||
|
|
final AppController c = AppController(project: demoTiming());
|
|||
|
|
addTearDown(c.dispose);
|
|||
|
|
|
|||
|
|
await tester.pumpWidget(MaterialApp(
|
|||
|
|
theme: buildTheme(Tokens.light),
|
|||
|
|
home: AppShell(controller: c),
|
|||
|
|
));
|
|||
|
|
await tester.pump();
|
|||
|
|
|
|||
|
|
// 条形视图:深浅主题各渲染一次。
|
|||
|
|
c.toggleTheme();
|
|||
|
|
await tester.pump();
|
|||
|
|
c.toggleTheme();
|
|||
|
|
await tester.pump();
|
|||
|
|
|
|||
|
|
// 展开左侧栏(浮层)并钉住(停靠,压缩画布宽度)。
|
|||
|
|
if (tester.any(find.byIcon(Icons.chevron_right))) {
|
|||
|
|
await tester.tap(find.byIcon(Icons.chevron_right).first);
|
|||
|
|
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();
|
|||
|
|
}
|
|||
|
|
// 展开右侧栏(浮层)并钉住。
|
|||
|
|
if (tester.any(find.byIcon(Icons.chevron_left))) {
|
|||
|
|
await tester.tap(find.byIcon(Icons.chevron_left).first);
|
|||
|
|
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();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 圆周视图 + 深色主题 + 缩放。
|
|||
|
|
c.setViewMode(ViewMode.circular);
|
|||
|
|
await tester.pump();
|
|||
|
|
c.toggleTheme();
|
|||
|
|
await tester.pump();
|
|||
|
|
c.setZoom(1.4);
|
|||
|
|
await tester.pump();
|
|||
|
|
|
|||
|
|
// 回到条形视图,选中一个动作(右侧栏渲染属性面板)。
|
|||
|
|
c.setViewMode(ViewMode.bar);
|
|||
|
|
c.select('A3');
|
|||
|
|
await tester.pump();
|
|||
|
|
c.toggleTheme();
|
|||
|
|
await tester.pump();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|