1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | import 'package:flutter/material.dart'; |
6 | import 'package:flutter_api_samples/widgets/basic/overflowbox.0.dart' as example; |
7 | import 'package:flutter_test/flutter_test.dart'; |
8 | |
9 | void main() { |
10 | testWidgets('OverflowBox allows child widget to overflow parent container', ( |
11 | WidgetTester tester, |
12 | ) async { |
13 | const Size containerSize = Size(100, 100); |
14 | const Size maxSize = Size(200, 200); |
15 | |
16 | await tester.pumpWidget(const example.OverflowBoxApp()); |
17 | |
18 | // The parent container has fixed width and height of 100 pixels. |
19 | expect(tester.getSize(find.byType(Container).first), containerSize); |
20 | |
21 | final OverflowBox overflowBox = tester.widget(find.byType(OverflowBox)); |
22 | // The OverflowBox imposes its own constraints of maxWidth and maxHeight of |
23 | // 200 on its child which allows the child to overflow the parent container. |
24 | expect(overflowBox.maxWidth, maxSize.width); |
25 | expect(overflowBox.maxHeight, maxSize.height); |
26 | |
27 | // The child widget overflows the parent container. |
28 | expect(tester.getSize(find.byType(FlutterLogo)), greaterThan(containerSize)); |
29 | expect(tester.getSize(find.byType(FlutterLogo)), maxSize); |
30 | }); |
31 | } |
32 |