forked from firka/flutter
Add test case for AndroidView clipBehavior (#67913)
This commit is contained in:
@@ -1149,6 +1149,44 @@ void main() {
|
||||
expect(renderObject.clipBehavior, clip);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('clip is handled correctly during resizing', (WidgetTester tester) async {
|
||||
// Regressing test for https://github.com/flutter/flutter/issues/67343
|
||||
Widget buildView(double width, double height, Clip clipBehavior) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
height: height,
|
||||
child: AndroidView(
|
||||
viewType: 'webview',
|
||||
layoutDirection: TextDirection.ltr,
|
||||
clipBehavior: clipBehavior,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildView(200.0, 200.0, Clip.none));
|
||||
// Resize the view.
|
||||
await tester.pumpWidget(buildView(100.0, 100.0, Clip.none));
|
||||
// No clip happen when the clip behavior is `Clip.none` .
|
||||
expect(tester.layers.whereType<ClipRectLayer>(), hasLength(0));
|
||||
|
||||
// No clip when only the clip behavior changes while the size remains the same.
|
||||
await tester.pumpWidget(buildView(100.0, 100.0, Clip.hardEdge));
|
||||
expect(tester.layers.whereType<ClipRectLayer>(), hasLength(0));
|
||||
|
||||
// Resize trigger clip when the clip behavior is not `Clip.none` .
|
||||
await tester.pumpWidget(buildView(50.0, 100.0, Clip.hardEdge));
|
||||
expect(tester.layers.whereType<ClipRectLayer>(), hasLength(1));
|
||||
ClipRectLayer clipRectLayer = tester.layers.whereType<ClipRectLayer>().first;
|
||||
expect(clipRectLayer.clipRect, const Rect.fromLTWH(0.0, 0.0, 50.0, 100.0));
|
||||
|
||||
await tester.pumpWidget(buildView(50.0, 50.0, Clip.hardEdge));
|
||||
expect(tester.layers.whereType<ClipRectLayer>(), hasLength(1));
|
||||
clipRectLayer = tester.layers.whereType<ClipRectLayer>().first;
|
||||
expect(clipRectLayer.clipRect, const Rect.fromLTWH(0.0, 0.0, 50.0, 50.0));
|
||||
});
|
||||
});
|
||||
|
||||
group('AndroidViewSurface', () {
|
||||
|
||||
Reference in New Issue
Block a user