import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pangolin_vpn/core/responsive/form_factor.dart'; Future _ffAt(WidgetTester tester, Size size) async { late FormFactor ff; tester.view.physicalSize = size; tester.view.devicePixelRatio = 1.0; addTearDown(tester.view.reset); await tester.pumpWidget(MediaQuery( data: MediaQueryData.fromView(tester.view), child: Builder(builder: (c) { ff = c.formFactor; return const SizedBox(); }), )); return ff; } void main() { testWidgets('iPad 竖屏(768) → tablet', (t) async { expect(await _ffAt(t, const Size(768, 1024)), FormFactor.tablet); }); testWidgets('iPad 横屏(1024) → tablet', (t) async { expect(await _ffAt(t, const Size(1024, 768)), FormFactor.tablet); }); testWidgets('iPhone(390) → mobile', (t) async { expect(await _ffAt(t, const Size(390, 844)), FormFactor.mobile); }); }