feat: migrate Flutter to Cupertino with daily logs and computer groups
This commit is contained in:
1 parent
c568749d23
commit
87e1fff59b
22 files changed
+808
-55
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:ads_manager/ui/app_widgets.dart';
|
||||
import 'package:ads_manager/ui/manager_model.dart';
|
||||
import 'package:ads_manager/ui/manager_view.dart';
|
||||
import 'package:ads_manager/data/manager_repository.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Cupertino workbench shows computers without refresh layout shift',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(1280, 820);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final m = ManagerModel();
|
||||
m.devices = [
|
||||
const Device('phone-one', false, agentId: 'home', computerName: '家里电脑'),
|
||||
const Device(
|
||||
'phone-two',
|
||||
false,
|
||||
agentId: 'office',
|
||||
computerName: '办公室电脑',
|
||||
),
|
||||
];
|
||||
final key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
RepaintBoundary(
|
||||
key: key,
|
||||
child: AdsCupertinoApp(
|
||||
home: ManagerView(model: m, onQuit: () async {}),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('办公室电脑'), findsWidgets);
|
||||
final before = tester.getTopLeft(find.text('phone-one'));
|
||||
await m.action(() async {
|
||||
m.refreshing = true;
|
||||
});
|
||||
await tester.pump();
|
||||
expect(tester.getTopLeft(find.text('phone-one')), before);
|
||||
await m.action(() async {
|
||||
m.refreshing = false;
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
if (const bool.fromEnvironment('ADS_CAPTURE')) {
|
||||
await tester.runAsync(() async {
|
||||
final image =
|
||||
await (key.currentContext!.findRenderObject()!
|
||||
as RenderRepaintBoundary)
|
||||
.toImage();
|
||||
final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
await File('../work/flutter-cupertino.png')
|
||||
.writeAsBytes(bytes!.buffer.asUint8List());
|
||||
image.dispose();
|
||||
});
|
||||
}
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
m.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user