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() { // tablet 阈值 ≥900,对齐 iPad 设计源(横屏侧栏布局)。 testWidgets('iPad 横屏(1024) → tablet', (t) async { expect(await _ffAt(t, const Size(1024, 768)), FormFactor.tablet); }); testWidgets('iPad 12.9″ 竖屏(1024) → tablet', (t) async { expect(await _ffAt(t, const Size(1024, 1366)), FormFactor.tablet); }); testWidgets('iPad 11″ 竖屏(834) → mobile(窄屏回落底 Tab)', (t) async { expect(await _ffAt(t, const Size(834, 1194)), FormFactor.mobile); }); testWidgets('iPad 标准竖屏(768) → mobile', (t) async { expect(await _ffAt(t, const Size(768, 1024)), FormFactor.mobile); }); testWidgets('断点边界:900 → tablet, 899 → mobile', (t) async { expect(await _ffAt(t, const Size(900, 1200)), FormFactor.tablet); expect(await _ffAt(t, const Size(899, 1200)), FormFactor.mobile); }); testWidgets('iPhone(390) → mobile', (t) async { expect(await _ffAt(t, const Size(390, 844)), FormFactor.mobile); }); }