import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:social_app/main.dart'; void main() { testWidgets('Login screen loads correctly', (WidgetTester tester) async { await tester.pumpWidget(const LinksyApp()); expect(find.text('linksy'), findsOneWidget); expect(find.text('继续'), findsOneWidget); expect(find.text('还没有账号?去注册'), findsOneWidget); }); testWidgets('Main content is vertically centered above footer', ( WidgetTester tester, ) async { await tester.pumpWidget(const LinksyApp()); final safeAreaRect = tester.getRect(find.byType(SafeArea)); final mainRect = tester.getRect( find.byKey(const Key('login_main_content')), ); final footerRect = tester.getRect(find.byKey(const Key('login_footer'))); final topSpace = mainRect.top - safeAreaRect.top; final bottomSpace = footerRect.top - mainRect.bottom; expect((topSpace - bottomSpace).abs(), lessThanOrEqualTo(2)); }); }