test(client): 锁定 form_factor 断点(iPad→tablet, iPhone→mobile)

This commit is contained in:
wangjia
2026-06-22 20:51:34 +08:00
parent 53a2ee0b74
commit 99695e8861
@@ -0,0 +1,27 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pangolin_vpn/core/responsive/form_factor.dart';
Future<FormFactor> _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);
});
}