forked from firka/flutter
Remove single view assumption from TestViewConfiguration (#122352)
Remove single view assumption from TestViewConfiguration
This commit is contained in:
committed by
GitHub
parent
47922979c6
commit
927289fb4e
@@ -31,13 +31,13 @@ Future<void> main() async {
|
||||
await tester.pump(); // Start 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),
|
||||
window: tester.view,
|
||||
view: tester.view,
|
||||
);
|
||||
final TestViewConfiguration small = TestViewConfiguration(
|
||||
final TestViewConfiguration small = TestViewConfiguration.fromView(
|
||||
size: const Size(355.0, 635.0),
|
||||
window: tester.view,
|
||||
view: tester.view,
|
||||
);
|
||||
final RenderView renderView = WidgetsBinding.instance.renderView;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark;
|
||||
|
||||
@@ -1919,9 +1919,9 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
|
||||
@override
|
||||
ViewConfiguration createViewConfiguration() {
|
||||
return TestViewConfiguration(
|
||||
return TestViewConfiguration.fromView(
|
||||
size: _surfaceSize ?? _kDefaultTestViewportSize,
|
||||
window: window,
|
||||
view: window,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1945,20 +1945,31 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
/// size is in logical pixels. The resulting ViewConfiguration maps the given
|
||||
/// size onto the actual display using the [BoxFit.contain] algorithm.
|
||||
class TestViewConfiguration extends ViewConfiguration {
|
||||
/// Creates a [TestViewConfiguration] with the given size. Defaults to 800x600.
|
||||
/// Deprecated. Will be removed in a future version of Flutter.
|
||||
///
|
||||
/// If a [window] instance is not provided it defaults to [ui.window].
|
||||
/// This property has been deprecated to prepare for Flutter's upcoming
|
||||
/// support for multiple views and multiple windows.
|
||||
///
|
||||
/// 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({
|
||||
Size size = _kDefaultTestViewportSize,
|
||||
ui.FlutterView? window,
|
||||
}) {
|
||||
return TestViewConfiguration._(size, window ?? ui.window);
|
||||
return TestViewConfiguration.fromView(size: size, view: window ?? ui.window);
|
||||
}
|
||||
|
||||
TestViewConfiguration._(Size size, ui.FlutterView window)
|
||||
: _paintMatrix = _getMatrix(size, window.devicePixelRatio, window),
|
||||
_hitTestMatrix = _getMatrix(size, 1.0, window),
|
||||
super(size: size, devicePixelRatio: window.devicePixelRatio);
|
||||
/// Creates a [TestViewConfiguration] with the given size and view.
|
||||
///
|
||||
/// The [size] defaults to 800x600.
|
||||
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) {
|
||||
final double inverseRatio = devicePixelRatio / window.devicePixelRatio;
|
||||
|
||||
@@ -120,9 +120,9 @@ https://flutter.dev/docs/testing/integration-tests#testing-on-firebase-test-lab
|
||||
ViewConfiguration createViewConfiguration() {
|
||||
final double devicePixelRatio = window.devicePixelRatio;
|
||||
final Size size = _surfaceSize ?? window.physicalSize / devicePixelRatio;
|
||||
return TestViewConfiguration(
|
||||
return TestViewConfiguration.fromView(
|
||||
size: size,
|
||||
window: window,
|
||||
view: window,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user