Unverified Commit 1ef6e998 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove physicalGeometry (#138103)

Looks like this was proactively added in https://github.com/flutter/engine/pull/20496, but never wired up to anything on any platform. It is also unused in framework and customer code; we never exposed this on e.g. MediaQuery.

Related engine PR: https://github.com/flutter/engine/pull/47825
parent 3215c492
...@@ -745,79 +745,19 @@ class TestFlutterView implements FlutterView { ...@@ -745,79 +745,19 @@ class TestFlutterView implements FlutterView {
platformDispatcher.onMetricsChanged?.call(); platformDispatcher.onMetricsChanged?.call();
} }
/// The physical geometry to use for this test.
///
/// Defaults to the value provided by [FlutterView.physicalGeometry]. This
/// can only be set in a test environment to emulate different view
/// configurations. A standard [FlutterView] is not mutable from the framework.
///
/// This property and [physicalSize] are dependent on one another. If both
/// properties are set through their test setters, the final result will be
/// that [physicalGeometry] determines the location and [physicalSize]
/// determines the size of the [physicalGeometry] [Rect]. If only
/// [physicalSize] is set, the final result is that the default value of
/// [physicalGeometry] determines the location and [physicalSize] determines
/// the size of the [physicalGeometry] [Rect]. If only [physicalGeometry]
/// is set, it will determine both the location and size of the
/// [physicalGeometry] [Rect].
///
/// See also:
///
/// * [FlutterView.physicalGeometry] for the standard implementation
/// * [resetPhysicalGeometry] to reset this value specifically
/// * [reset] to reset all test values for this view
@override
Rect get physicalGeometry {
Rect value = _physicalGeometry ?? _view.physicalGeometry;
if (_physicalSize != null) {
value = value.topLeft & _physicalSize!;
}
return value;
}
Rect? _physicalGeometry;
set physicalGeometry(Rect value) {
_physicalGeometry = value;
platformDispatcher.onMetricsChanged?.call();
}
/// Resets [physicalGeometry] to the default value for this view.
///
/// This will also reset [physicalSize] as the values are dependent
/// on one another.
void resetPhysicalGeometry() {
_physicalGeometry = null;
_physicalSize = null;
platformDispatcher.onMetricsChanged?.call();
}
/// The physical size to use for this test. /// The physical size to use for this test.
/// ///
/// Defaults to the value provided by [FlutterView.physicalSize]. This /// Defaults to the value provided by [FlutterView.physicalSize]. This
/// can only be set in a test environment to emulate different view /// can only be set in a test environment to emulate different view
/// configurations. A standard [FlutterView] is not mutable from the framework. /// configurations. A standard [FlutterView] is not mutable from the framework.
/// ///
/// This property and [physicalGeometry] are dependent on one another. If both
/// properties are set through their test setters, the final result will be
/// that [physicalGeometry] determines the location and [physicalSize]
/// determines the size of the [physicalGeometry] [Rect]. If only
/// [physicalSize] is set, the final result is that the default value of
/// [physicalGeometry] determines the location and [physicalSize] determines
/// the size of the [physicalGeometry] [Rect]. If only [physicalGeometry]
/// is set, it will determine both the location and size of the
/// [physicalGeometry] [Rect].
///
/// See also: /// See also:
/// ///
/// * [FlutterView.physicalSize] for the standard implementation /// * [FlutterView.physicalSize] for the standard implementation
/// * [resetPhysicalSize] to reset this value specifically /// * [resetPhysicalSize] to reset this value specifically
/// * [reset] to reset all test values for this view /// * [reset] to reset all test values for this view
@override @override
Size get physicalSize { Size get physicalSize => _physicalSize ?? _view.physicalSize;
// This has to be able to default to `_view.physicalSize` as web_ui handles
// `physicalSize` and `physicalGeometry` differently than dart:ui, where
// the values are both based off of `physicalGeometry`.
return _physicalSize ?? _physicalGeometry?.size ?? _view.physicalSize;
}
Size? _physicalSize; Size? _physicalSize;
set physicalSize(Size value) { set physicalSize(Size value) {
_physicalSize = value; _physicalSize = value;
...@@ -825,11 +765,9 @@ class TestFlutterView implements FlutterView { ...@@ -825,11 +765,9 @@ class TestFlutterView implements FlutterView {
} }
/// Resets [physicalSize] to the default value for this view. /// Resets [physicalSize] to the default value for this view.
///
/// This will also reset [physicalGeometry] as the values are dependent
/// on one another.
void resetPhysicalSize() { void resetPhysicalSize() {
resetPhysicalGeometry(); _physicalSize = null;
platformDispatcher.onMetricsChanged?.call();
} }
/// The system gesture insets to use for this test. /// The system gesture insets to use for this test.
...@@ -952,7 +890,6 @@ class TestFlutterView implements FlutterView { ...@@ -952,7 +890,6 @@ class TestFlutterView implements FlutterView {
/// * [resetDevicePixelRatio] to reset [devicePixelRatio] specifically /// * [resetDevicePixelRatio] to reset [devicePixelRatio] specifically
/// * [resetDisplayFeatures] to reset [displayFeatures] specifically /// * [resetDisplayFeatures] to reset [displayFeatures] specifically
/// * [resetPadding] to reset [padding] specifically /// * [resetPadding] to reset [padding] specifically
/// * [resetPhysicalGeometry] to reset [physicalGeometry] specifically
/// * [resetPhysicalSize] to reset [physicalSize] specifically /// * [resetPhysicalSize] to reset [physicalSize] specifically
/// * [resetSystemGestureInsets] to reset [systemGestureInsets] specifically /// * [resetSystemGestureInsets] to reset [systemGestureInsets] specifically
/// * [resetViewInsets] to reset [viewInsets] specifically /// * [resetViewInsets] to reset [viewInsets] specifically
...@@ -962,8 +899,7 @@ class TestFlutterView implements FlutterView { ...@@ -962,8 +899,7 @@ class TestFlutterView implements FlutterView {
resetDevicePixelRatio(); resetDevicePixelRatio();
resetDisplayFeatures(); resetDisplayFeatures();
resetPadding(); resetPadding();
resetPhysicalGeometry(); resetPhysicalSize();
// Skipping resetPhysicalSize because resetPhysicalGeometry resets both values.
resetSystemGestureInsets(); resetSystemGestureInsets();
resetViewInsets(); resetViewInsets();
resetViewPadding(); resetViewPadding();
...@@ -1879,14 +1815,6 @@ class TestWindow implements SingletonFlutterWindow { ...@@ -1879,14 +1815,6 @@ class TestWindow implements SingletonFlutterWindow {
@override @override
FrameData get frameData => platformDispatcher.frameData; FrameData get frameData => platformDispatcher.frameData;
@Deprecated(
'Use WidgetTester.platformDispatcher.physicalGeometry instead. '
'Deprecated to prepare for the upcoming multi-window support. '
'This feature was deprecated after v3.9.0-0.1.pre.'
)
@override
Rect get physicalGeometry => _view.physicalGeometry;
@Deprecated( @Deprecated(
'Use WidgetTester.platformDispatcher.systemFontFamily instead. ' 'Use WidgetTester.platformDispatcher.systemFontFamily instead. '
'Deprecated to prepare for the upcoming multi-window support. ' 'Deprecated to prepare for the upcoming multi-window support. '
......
...@@ -112,39 +112,6 @@ void main() { ...@@ -112,39 +112,6 @@ void main() {
); );
}); });
testWidgets('can fake physicalGeometry', (WidgetTester tester) async {
verifyPropertyFaked<Rect>(
tester: tester,
realValue: trueImplicitView().physicalGeometry,
fakeValue: const Rect.fromLTWH(0, 0, 550, 850),
propertyRetriever: () => boundImplicitView().physicalGeometry,
propertyFaker: (_, Rect fakeValue) {
tester.view.physicalGeometry = fakeValue;
},
);
});
testWidgets('can reset physicalGeometry', (WidgetTester tester) async {
verifyPropertyReset<Rect>(
tester: tester,
fakeValue: const Rect.fromLTWH(0, 0, 35, 475),
propertyRetriever: () => boundImplicitView().physicalGeometry,
propertyResetter: () {
tester.view.resetPhysicalGeometry();
},
propertyFaker: (Rect fakeValue) {
tester.view.physicalGeometry = fakeValue;
},
);
});
testWidgets('updating physicalGeometry also updates physicalSize', (WidgetTester tester) async {
const Rect testGeometry = Rect.fromLTWH(0, 0, 450, 575);
tester.view.physicalGeometry = testGeometry;
expect(tester.view.physicalSize, testGeometry.size);
});
testWidgets('can fake physicalSize', (WidgetTester tester) async { testWidgets('can fake physicalSize', (WidgetTester tester) async {
verifyPropertyFaked<Size>( verifyPropertyFaked<Size>(
tester: tester, tester: tester,
...@@ -171,17 +138,6 @@ void main() { ...@@ -171,17 +138,6 @@ void main() {
); );
}); });
testWidgets('updating physicalSize also updates physicalGeometry', (WidgetTester tester) async {
const Rect testGeometry = Rect.fromLTWH(0, 0, 450, 575);
const Size testSize = Size(50, 50);
const Rect expectedGeometry = Rect.fromLTWH(0, 0, 50, 50);
tester.view.physicalGeometry = testGeometry;
tester.view.physicalSize = testSize;
expect(tester.view.physicalGeometry, expectedGeometry);
});
testWidgets('can fake systemGestureInsets', (WidgetTester tester) async { testWidgets('can fake systemGestureInsets', (WidgetTester tester) async {
verifyPropertyFaked<ViewPadding>( verifyPropertyFaked<ViewPadding>(
tester: tester, tester: tester,
...@@ -272,7 +228,6 @@ void main() { ...@@ -272,7 +228,6 @@ void main() {
tester.view.devicePixelRatio = 7; tester.view.devicePixelRatio = 7;
tester.view.displayFeatures = <DisplayFeature>[const DisplayFeature(bounds: Rect.fromLTWH(0, 0, 20, 300), type: DisplayFeatureType.unknown, state: DisplayFeatureState.unknown)]; tester.view.displayFeatures = <DisplayFeature>[const DisplayFeature(bounds: Rect.fromLTWH(0, 0, 20, 300), type: DisplayFeatureType.unknown, state: DisplayFeatureState.unknown)];
tester.view.padding = FakeViewPadding.zero; tester.view.padding = FakeViewPadding.zero;
tester.view.physicalGeometry = const Rect.fromLTWH(0, 0, 505, 805);
tester.view.systemGestureInsets = FakeViewPadding.zero; tester.view.systemGestureInsets = FakeViewPadding.zero;
tester.view.viewInsets = FakeViewPadding.zero; tester.view.viewInsets = FakeViewPadding.zero;
tester.view.viewPadding = FakeViewPadding.zero; tester.view.viewPadding = FakeViewPadding.zero;
...@@ -356,9 +311,6 @@ class _FlutterViewSnapshotMatcher extends Matcher { ...@@ -356,9 +311,6 @@ class _FlutterViewSnapshotMatcher extends Matcher {
paddingMatcher.describeMismatch(actual.padding, mismatchDescription, matchState, verbose); paddingMatcher.describeMismatch(actual.padding, mismatchDescription, matchState, verbose);
} }
if (actual.physicalGeometry != expected.physicalGeometry) {
mismatchDescription.add('actual.physicalGeometry (${actual.physicalGeometry}) did not match expected.physicalGeometry (${expected.physicalGeometry})');
}
if (actual.physicalSize != expected.physicalSize) { if (actual.physicalSize != expected.physicalSize) {
mismatchDescription.add('actual.physicalSize (${actual.physicalSize}) did not match expected.physicalSize (${expected.physicalSize})'); mismatchDescription.add('actual.physicalSize (${actual.physicalSize}) did not match expected.physicalSize (${expected.physicalSize})');
} }
...@@ -397,7 +349,6 @@ class _FlutterViewSnapshotMatcher extends Matcher { ...@@ -397,7 +349,6 @@ class _FlutterViewSnapshotMatcher extends Matcher {
actual.displayFeatures.equals(expected.displayFeatures) && actual.displayFeatures.equals(expected.displayFeatures) &&
actual.gestureSettings == expected.gestureSettings && actual.gestureSettings == expected.gestureSettings &&
matchesViewPadding(expected.padding).matches(actual.padding, matchState) && matchesViewPadding(expected.padding).matches(actual.padding, matchState) &&
actual.physicalGeometry == expected.physicalGeometry &&
actual.physicalSize == expected.physicalSize && actual.physicalSize == expected.physicalSize &&
matchesViewPadding(expected.systemGestureInsets).matches(actual.padding, matchState) && matchesViewPadding(expected.systemGestureInsets).matches(actual.padding, matchState) &&
actual.viewId == expected.viewId && actual.viewId == expected.viewId &&
...@@ -412,7 +363,6 @@ class FlutterViewSnapshot { ...@@ -412,7 +363,6 @@ class FlutterViewSnapshot {
displayFeatures = <DisplayFeature>[...view.displayFeatures], displayFeatures = <DisplayFeature>[...view.displayFeatures],
gestureSettings = view.gestureSettings, gestureSettings = view.gestureSettings,
padding = view.padding, padding = view.padding,
physicalGeometry = view.physicalGeometry,
physicalSize = view.physicalSize, physicalSize = view.physicalSize,
systemGestureInsets = view.systemGestureInsets, systemGestureInsets = view.systemGestureInsets,
viewId = view.viewId, viewId = view.viewId,
...@@ -423,7 +373,6 @@ class FlutterViewSnapshot { ...@@ -423,7 +373,6 @@ class FlutterViewSnapshot {
final List<DisplayFeature> displayFeatures; final List<DisplayFeature> displayFeatures;
final GestureSettings gestureSettings; final GestureSettings gestureSettings;
final ViewPadding padding; final ViewPadding padding;
final Rect physicalGeometry;
final Size physicalSize; final Size physicalSize;
final ViewPadding systemGestureInsets; final ViewPadding systemGestureInsets;
final Object viewId; final Object viewId;
......
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