Files
SpotiFLAC-Mobile/test/view_display_test.dart
zarzet f05bec0440 fix(desktop): do not crash while the window moves between screens
FlutterView.display throws a null check error when the engine has replaced
its display list and the view does not yet name one of the new displays,
which happens while a window is dragged on Windows. Every read of the
display now goes through displayOf, which gives null in that case.

Fixes #930
2026-11-18 21:48:21 +07:00

23 lines
665 B
Dart

import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';
import 'package:mornye/utils/view_display.dart';
/// A view whose display the engine no longer lists, as while a desktop
/// window is dragged to another screen.
class _MovingView extends Fake implements FlutterView {
@override
Display get display => (null as Display?)!;
}
void main() {
testWidgets('a view between screens has no display instead of an error', (
tester,
) async {
expect(() => _MovingView().display, throwsA(isA<Error>()));
expect(displayOf(_MovingView()), isNull);
expect(displayOf(null), isNull);
expect(displayOf(tester.view), isNotNull);
});
}