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

RenderView has to be a singleton for sanity during tests, otherwise they all end up in the dirty lists and we end up pumping all of them each frame.
41 lines
1.3 KiB
Dart
41 lines
1.3 KiB
Dart
import 'package:sky/rendering.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'rendering_tester.dart';
|
|
|
|
void main() {
|
|
test('Basic grid layout test', () {
|
|
List<RenderBox> children = [
|
|
new RenderDecoratedBox(decoration: new BoxDecoration()),
|
|
new RenderDecoratedBox(decoration: new BoxDecoration()),
|
|
new RenderDecoratedBox(decoration: new BoxDecoration()),
|
|
new RenderDecoratedBox(decoration: new BoxDecoration())
|
|
];
|
|
|
|
RenderGrid grid = new RenderGrid(children: children, maxChildExtent: 100.0);
|
|
layout(grid, constraints: const BoxConstraints(maxWidth: 200.0));
|
|
|
|
children.forEach((child) {
|
|
expect(child.size.width, equals(100.0), reason: "child width");
|
|
expect(child.size.height, equals(100.0), reason: "child height");
|
|
});
|
|
|
|
expect(grid.size.width, equals(200.0), reason: "grid width");
|
|
expect(grid.size.height, equals(200.0), reason: "grid height");
|
|
|
|
expect(grid.needsLayout, equals(false));
|
|
grid.maxChildExtent = 60.0;
|
|
expect(grid.needsLayout, equals(true));
|
|
|
|
pumpFrame();
|
|
|
|
children.forEach((child) {
|
|
expect(child.size.width, equals(50.0), reason: "child width");
|
|
expect(child.size.height, equals(50.0), reason: "child height");
|
|
});
|
|
|
|
expect(grid.size.width, equals(200.0), reason: "grid width");
|
|
expect(grid.size.height, equals(50.0), reason: "grid height");
|
|
});
|
|
}
|