Dynamic view sizing (#138648)
Towards https://github.com/flutter/flutter/issues/134501. This change is based on https://github.com/flutter/engine/pull/48090. It changes the `RenderView` to be dynamically sized based on its content if the `FlutterView` it is configured with allows it (i.e. the `FlutterView` has loose `FlutterView.physicalConstraints`). For that, it uses those `physicalConstraints` as input to the layout algorithm by passing them on to its child (after translating them to logical constraints via the device pixel ratio). The resulting `Size` that the `RenderView` would like to be is then communicated back to the engine by passing it to the `FlutterView.render` call. Tests will fail until https://github.com/flutter/engine/pull/48090 has rolled into the framework.
This commit is contained in:
committed by
GitHub
parent
b417812547
commit
4f8a99147a
@@ -124,6 +124,19 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('faking physicalSize fakes physicalConstraints', (WidgetTester tester) async {
|
||||
const Size fakeSize = Size(50, 50);
|
||||
verifyPropertyFaked<ViewConstraints>(
|
||||
tester: tester,
|
||||
realValue: trueImplicitView().physicalConstraints,
|
||||
fakeValue: ViewConstraints.tight(fakeSize),
|
||||
propertyRetriever: () => boundImplicitView().physicalConstraints,
|
||||
propertyFaker: (_, __) {
|
||||
tester.view.physicalSize = fakeSize;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('can reset physicalSize', (WidgetTester tester) async {
|
||||
verifyPropertyReset<Size>(
|
||||
tester: tester,
|
||||
@@ -138,6 +151,47 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('resetting physicalSize resets physicalConstraints', (WidgetTester tester) async {
|
||||
const Size fakeSize = Size(50, 50);
|
||||
verifyPropertyReset<ViewConstraints>(
|
||||
tester: tester,
|
||||
fakeValue: ViewConstraints.tight(fakeSize),
|
||||
propertyRetriever: () => boundImplicitView().physicalConstraints,
|
||||
propertyResetter: () {
|
||||
tester.view.resetPhysicalSize();
|
||||
},
|
||||
propertyFaker: (_) {
|
||||
tester.view.physicalSize = fakeSize;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('can fake physicalConstraints', (WidgetTester tester) async {
|
||||
verifyPropertyFaked<ViewConstraints>(
|
||||
tester: tester,
|
||||
realValue: trueImplicitView().physicalConstraints,
|
||||
fakeValue: const ViewConstraints(minWidth: 1, maxWidth: 2, minHeight: 3, maxHeight: 4),
|
||||
propertyRetriever: () => boundImplicitView().physicalConstraints,
|
||||
propertyFaker: (_, ViewConstraints fakeValue) {
|
||||
tester.view.physicalConstraints = fakeValue;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('can reset physicalConstraints', (WidgetTester tester) async {
|
||||
verifyPropertyReset<ViewConstraints>(
|
||||
tester: tester,
|
||||
fakeValue: const ViewConstraints(minWidth: 1, maxWidth: 2, minHeight: 3, maxHeight: 4),
|
||||
propertyRetriever: () => boundImplicitView().physicalConstraints,
|
||||
propertyResetter: () {
|
||||
tester.view.resetPhysicalConstraints();
|
||||
},
|
||||
propertyFaker: (ViewConstraints fakeValue) {
|
||||
tester.view.physicalConstraints = fakeValue;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('can fake systemGestureInsets', (WidgetTester tester) async {
|
||||
verifyPropertyFaked<ViewPadding>(
|
||||
tester: tester,
|
||||
|
||||
@@ -83,7 +83,7 @@ No widgets found at Offset(1.0, 1.0).
|
||||
),
|
||||
);
|
||||
|
||||
final Size originalSize = tester.binding.createViewConfigurationFor(tester.binding.renderView).size; // ignore: deprecated_member_use
|
||||
final Size originalSize = tester.binding.renderView.size; // ignore: deprecated_member_use
|
||||
await tester.binding.setSurfaceSize(const Size(2000, 1800));
|
||||
try {
|
||||
await tester.pump();
|
||||
|
||||
Reference in New Issue
Block a user