mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This patch makes Center and Align expand by default, which is usually what you want. It also adds a ShrinkWrap option to let you shrink wrap in one or both directions if that's really what you want to do.
43 lines
1.8 KiB
Dart
43 lines
1.8 KiB
Dart
import 'package:sky/rendering.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'rendering_tester.dart';
|
|
|
|
void main() {
|
|
test('RenderPositionedBox expands', () {
|
|
RenderConstrainedBox sizer = new RenderConstrainedBox(
|
|
additionalConstraints: new BoxConstraints.tight(new Size(100.0, 100.0)),
|
|
child: new RenderDecoratedBox(decoration: new BoxDecoration())
|
|
);
|
|
RenderPositionedBox positioner = new RenderPositionedBox(child: sizer);
|
|
layout(positioner, constraints: new BoxConstraints.loose(new Size(200.0, 200.0)));
|
|
|
|
expect(positioner.size.width, equals(200.0), reason: "positioner width");
|
|
expect(positioner.size.height, equals(200.0), reason: "positioner height");
|
|
});
|
|
|
|
test('RenderPositionedBox shrink wraps', () {
|
|
RenderConstrainedBox sizer = new RenderConstrainedBox(
|
|
additionalConstraints: new BoxConstraints.tight(new Size(100.0, 100.0)),
|
|
child: new RenderDecoratedBox(decoration: new BoxDecoration())
|
|
);
|
|
RenderPositionedBox positioner = new RenderPositionedBox(child: sizer, shrinkWrap: ShrinkWrap.width);
|
|
RenderingTester tester = layout(positioner, constraints: new BoxConstraints.loose(new Size(200.0, 200.0)));
|
|
|
|
expect(positioner.size.width, equals(100.0), reason: "positioner width");
|
|
expect(positioner.size.height, equals(200.0), reason: "positioner height");
|
|
|
|
positioner.shrinkWrap = ShrinkWrap.height;
|
|
tester.pumpFrame(phase: EnginePhase.layout);
|
|
|
|
expect(positioner.size.width, equals(200.0), reason: "positioner width");
|
|
expect(positioner.size.height, equals(100.0), reason: "positioner height");
|
|
|
|
positioner.shrinkWrap = ShrinkWrap.both;
|
|
tester.pumpFrame(phase: EnginePhase.layout);
|
|
|
|
expect(positioner.size.width, equals(100.0), reason: "positioner width");
|
|
expect(positioner.size.height, equals(100.0), reason: "positioner height");
|
|
});
|
|
}
|