Unverified Commit 927289fb authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove single view assumption from TestViewConfiguration (#122352)

Remove single view assumption from TestViewConfiguration
parent 47922979
...@@ -31,13 +31,13 @@ Future<void> main() async { ...@@ -31,13 +31,13 @@ Future<void> main() async {
await tester.pump(); // Start drawer animation await tester.pump(); // Start drawer animation
await tester.pump(const Duration(seconds: 1)); // Complete drawer animation await tester.pump(const Duration(seconds: 1)); // Complete drawer animation
final TestViewConfiguration big = TestViewConfiguration( final TestViewConfiguration big = TestViewConfiguration.fromView(
size: const Size(360.0, 640.0), size: const Size(360.0, 640.0),
window: tester.view, view: tester.view,
); );
final TestViewConfiguration small = TestViewConfiguration( final TestViewConfiguration small = TestViewConfiguration.fromView(
size: const Size(355.0, 635.0), size: const Size(355.0, 635.0),
window: tester.view, view: tester.view,
); );
final RenderView renderView = WidgetsBinding.instance.renderView; final RenderView renderView = WidgetsBinding.instance.renderView;
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark;
......
...@@ -1919,9 +1919,9 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1919,9 +1919,9 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
ViewConfiguration createViewConfiguration() { ViewConfiguration createViewConfiguration() {
return TestViewConfiguration( return TestViewConfiguration.fromView(
size: _surfaceSize ?? _kDefaultTestViewportSize, size: _surfaceSize ?? _kDefaultTestViewportSize,
window: window, view: window,
); );
} }
...@@ -1945,20 +1945,31 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1945,20 +1945,31 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
/// size is in logical pixels. The resulting ViewConfiguration maps the given /// size is in logical pixels. The resulting ViewConfiguration maps the given
/// size onto the actual display using the [BoxFit.contain] algorithm. /// size onto the actual display using the [BoxFit.contain] algorithm.
class TestViewConfiguration extends ViewConfiguration { class TestViewConfiguration extends ViewConfiguration {
/// Creates a [TestViewConfiguration] with the given size. Defaults to 800x600. /// Deprecated. Will be removed in a future version of Flutter.
///
/// This property has been deprecated to prepare for Flutter's upcoming
/// support for multiple views and multiple windows.
/// ///
/// If a [window] instance is not provided it defaults to [ui.window]. /// Use [TestViewConfiguration.fromView] instead.
@Deprecated(
'Use TestViewConfiguration.fromView instead. '
'Deprecated to prepare for the upcoming multi-window support. '
'This feature was deprecated after v3.7.0-32.0.pre.'
)
factory TestViewConfiguration({ factory TestViewConfiguration({
Size size = _kDefaultTestViewportSize, Size size = _kDefaultTestViewportSize,
ui.FlutterView? window, ui.FlutterView? window,
}) { }) {
return TestViewConfiguration._(size, window ?? ui.window); return TestViewConfiguration.fromView(size: size, view: window ?? ui.window);
} }
TestViewConfiguration._(Size size, ui.FlutterView window) /// Creates a [TestViewConfiguration] with the given size and view.
: _paintMatrix = _getMatrix(size, window.devicePixelRatio, window), ///
_hitTestMatrix = _getMatrix(size, 1.0, window), /// The [size] defaults to 800x600.
super(size: size, devicePixelRatio: window.devicePixelRatio); TestViewConfiguration.fromView({required ui.FlutterView view, super.size = _kDefaultTestViewportSize})
: _paintMatrix = _getMatrix(size, view.devicePixelRatio, view),
_hitTestMatrix = _getMatrix(size, 1.0, view),
super(devicePixelRatio: view.devicePixelRatio);
static Matrix4 _getMatrix(Size size, double devicePixelRatio, ui.FlutterView window) { static Matrix4 _getMatrix(Size size, double devicePixelRatio, ui.FlutterView window) {
final double inverseRatio = devicePixelRatio / window.devicePixelRatio; final double inverseRatio = devicePixelRatio / window.devicePixelRatio;
......
...@@ -120,9 +120,9 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab ...@@ -120,9 +120,9 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab
ViewConfiguration createViewConfiguration() { ViewConfiguration createViewConfiguration() {
final double devicePixelRatio = window.devicePixelRatio; final double devicePixelRatio = window.devicePixelRatio;
final Size size = _surfaceSize ?? window.physicalSize / devicePixelRatio; final Size size = _surfaceSize ?? window.physicalSize / devicePixelRatio;
return TestViewConfiguration( return TestViewConfiguration.fromView(
size: size, size: size,
window: window, view: window,
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment