|
6 | 6 | // machines. |
7 | 7 | @Tags(<String>['reduced-test-set']) |
8 | 8 |
|
| 9 | +import 'package:flutter/rendering.dart'; |
9 | 10 | import 'package:flutter/widgets.dart'; |
10 | 11 | import 'package:flutter_test/flutter_test.dart'; |
11 | 12 |
|
@@ -392,4 +393,62 @@ void main() { |
392 | 393 | await gesture.up(); |
393 | 394 | await tester.pumpAndSettle(); |
394 | 395 | }); |
| 396 | + |
| 397 | + testWidgets('Clip behavior is updated as needed', (WidgetTester tester) async { |
| 398 | + // Regression test for https://github.com/flutter/flutter/issues/97867 |
| 399 | + await tester.pumpWidget(Directionality( |
| 400 | + textDirection: TextDirection.ltr, |
| 401 | + child: MediaQuery( |
| 402 | + data: const MediaQueryData(size: Size(800.0, 600.0)), |
| 403 | + child: ScrollConfiguration( |
| 404 | + behavior: const ScrollBehavior().copyWith(overscroll: false), |
| 405 | + child: Column( |
| 406 | + children: <Widget>[ |
| 407 | + StretchingOverscrollIndicator( |
| 408 | + axisDirection: AxisDirection.down, |
| 409 | + child: SizedBox( |
| 410 | + height: 300, |
| 411 | + child: ListView.builder( |
| 412 | + itemCount: 20, |
| 413 | + itemBuilder: (BuildContext context, int index){ |
| 414 | + return Padding( |
| 415 | + padding: const EdgeInsets.all(10.0), |
| 416 | + child: Text('Index $index'), |
| 417 | + ); |
| 418 | + }, |
| 419 | + ), |
| 420 | + ), |
| 421 | + ), |
| 422 | + Opacity( |
| 423 | + opacity: 0.5, |
| 424 | + child: Container( |
| 425 | + color: const Color(0xD0FF0000), |
| 426 | + height: 100, |
| 427 | + ), |
| 428 | + ) |
| 429 | + ], |
| 430 | + ) |
| 431 | + ), |
| 432 | + ) |
| 433 | + )); |
| 434 | + |
| 435 | + expect(find.text('Index 1'), findsOneWidget); |
| 436 | + expect(tester.getCenter(find.text('Index 1')).dy, 51.0); |
| 437 | + RenderClipRect renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first; |
| 438 | + // Currently not clipping |
| 439 | + expect(renderClip.clipBehavior, equals(Clip.none)); |
| 440 | + |
| 441 | + final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Index 1'))); |
| 442 | + // Overscroll the start. |
| 443 | + await gesture.moveBy(const Offset(0.0, 200.0)); |
| 444 | + await tester.pumpAndSettle(); |
| 445 | + expect(find.text('Index 1'), findsOneWidget); |
| 446 | + expect(tester.getCenter(find.text('Index 1')).dy, greaterThan(0)); |
| 447 | + renderClip = tester.allRenderObjects.whereType<RenderClipRect>().first; |
| 448 | + // Now clipping |
| 449 | + expect(renderClip.clipBehavior, equals(Clip.hardEdge)); |
| 450 | + |
| 451 | + await gesture.up(); |
| 452 | + await tester.pumpAndSettle(); |
| 453 | + }); |
395 | 454 | } |
0 commit comments