import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:timezone/data/latest.dart' as tzdata; import 'package:hepan_everyday/app/hepan_app.dart'; import 'package:hepan_everyday/app/app_controller.dart'; import '../support/fakes.dart'; AppController uiController() => AppController( MemoryStore(), FakeNotifications(), FakeCalendar(), () => DateTime.utc(2026, 10, 12), ); void main() { setUpAll(tzdata.initializeTimeZones); testWidgets('two icon tabs navigate to profile and timetable', ( tester, ) async { final controller = uiController(); await controller.initialize(); await tester.pumpWidget(HepanApp(controller: controller)); await tester.pumpAndSettle(); expect(find.bySemanticsLabel('个人设置'), findsOneWidget); await tester.tap(find.bySemanticsLabel('个人设置')); await tester.pumpAndSettle(); expect(find.text('登录学校账户'), findsOneWidget); expect(find.text('课表设置'), findsOneWidget); await tester.tap(find.bySemanticsLabel('课表')); await tester.pumpAndSettle(); expect(find.text('体验示例课表'), findsOneWidget); controller.dispose(); }); testWidgets('demo reaches Sunday and the last lesson on a small display', ( tester, ) async { tester.view.physicalSize = const Size(360, 800); tester.view.devicePixelRatio = 1; addTearDown(tester.view.resetPhysicalSize); addTearDown(tester.view.resetDevicePixelRatio); final controller = uiController(); await controller.initialize(); await controller.showDemo(); await tester.pumpWidget(HepanApp(controller: controller)); await tester.pumpAndSettle(); expect(find.text('示例课表'), findsOneWidget); expect(find.text('11'), findsOneWidget); await tester.ensureVisible(find.text('周一')); expect(tester.getRect(find.text('周日')).right, lessThanOrEqualTo(360)); await tester.drag(find.text('周一'), const Offset(-200, 0)); await tester.pumpAndSettle(); expect(tester.takeException(), isNull); expect(find.text('周日'), findsOneWidget); expect(tester.getCenter(find.text('周日')).dx, lessThan(360)); controller.dispose(); }); }