fix: automate graduate timetable read and refine blue glass Dock

This commit is contained in:
Codex
2026-10-13 17:50:04 +08:00
parent 8f20a341c4
commit 476ef097ee
23 changed files with 1072 additions and 176 deletions
+78
View File
@@ -0,0 +1,78 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:timezone/data/latest.dart' as tzdata;
import 'package:hepan_everyday/widgets/glass_dock.dart';
import 'package:hepan_everyday/app/hepan_app.dart';
import 'navigation_test.dart' show uiController;
void main() {
setUpAll(tzdata.initializeTimeZones);
testWidgets('held cursor enlarges before dragging and returns on release', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(child: GlassDock(selectedIndex: 0, onSelected: (_) {})),
),
),
);
await tester.pumpAndSettle();
final lens = find
.descendant(
of: find.byType(GlassDock),
matching: find.byType(BackdropFilter),
)
.last;
final resting = tester.getSize(lens);
final gesture = await tester.startGesture(
tester.getCenter(find.byKey(const Key('dock-cursor'))),
);
await tester.pump(const Duration(milliseconds: 110));
await tester.pump(const Duration(milliseconds: 200));
final held = tester.getSize(lens);
expect(held.width, greaterThan(resting.width * 1.12));
expect(held.height, greaterThan(resting.height * 1.12));
await gesture.cancel();
await tester.pumpAndSettle();
expect(tester.getSize(lens).width, closeTo(resting.width, 0.5));
expect(tester.getSize(lens).height, closeTo(resting.height, 0.5));
});
testWidgets(
'Dock stays visible while sliding down instead of abruptly fading',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final c = uiController();
await c.initialize();
await c.showDemo();
await tester.pumpWidget(HepanApp(controller: c));
await tester.pumpAndSettle();
final dock = find.byType(GlassDock);
final before = tester.getRect(dock);
final gesture = await tester.startGesture(
tester.getCenter(find.text('周三')),
);
await gesture.moveBy(const Offset(0, -80));
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
final fading = find.ancestor(
of: dock,
matching: find.byType(FadeTransition),
);
final opacity = fading.evaluate().isEmpty
? 1.0
: tester.widget<FadeTransition>(fading.first).opacity.value;
expect(opacity, greaterThan(0.95));
expect(tester.getRect(dock).top, greaterThan(before.top));
expect(tester.getRect(dock).top, lessThan(844));
await gesture.up();
await tester.pumpAndSettle();
expect(dock.hitTestable(), findsNothing);
c.dispose();
},
);
}