forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Widget wrapper around Grid and test RenderGrid
- Loading branch information
1 parent
7051cf7
commit 6a5e0aa
Showing
3 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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()) | ||
]; | ||
|
||
RenderBox grid = new RenderGrid(children: children, maxChildExtent: 100.0); | ||
RenderingTester tester = 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)); | ||
|
||
tester.pumpFrame(phase: EnginePhase.layout); | ||
|
||
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"); | ||
}); | ||
} |