| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import '../resources/third_party/unittest/unittest.dart'; | 5 import '../resources/third_party/unittest/unittest.dart'; |
| 6 import '../resources/unit.dart'; | 6 import '../resources/unit.dart'; |
| 7 import 'dart:sky' as sky; | 7 import 'dart:sky' as sky; |
| 8 import 'package:sky/framework/layout2.dart'; | 8 import 'package:sky/framework/layout2.dart'; |
| 9 | 9 |
| 10 class RenderSizedBox extends RenderBox { | |
| 11 final sky.Size desiredSize; | |
| 12 | |
| 13 RenderSizedBox({ this.desiredSize }); | |
| 14 | |
| 15 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { | |
| 16 return new BoxDimensions.withConstraints(constraints, | |
| 17 width: desiredSize.width, | |
| 18 height: desiredSize.height); | |
| 19 } | |
| 20 | |
| 21 void performLayout() { | |
| 22 size = constraints.constrain(desiredSize); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 void main() { | 10 void main() { |
| 27 initUnit(); | 11 initUnit(); |
| 28 | 12 |
| 29 test("should size to render view", () { | 13 test("should size to render view", () { |
| 30 RenderSizedBox root = new RenderSizedBox(desiredSize: new sky.Size.infinite(
)); | 14 RenderSizedBox root = new RenderSizedBox( |
| 15 new RenderDecoratedBox(new BoxDecoration(backgroundColor: 0xFF00FF00))); |
| 31 RenderView renderView = new RenderView(child: root); | 16 RenderView renderView = new RenderView(child: root); |
| 32 renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.vie
w.height)); | 17 renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.vie
w.height)); |
| 33 expect(root.size.width, equals(sky.view.width)); | 18 expect(root.size.width, equals(sky.view.width)); |
| 34 expect(root.size.height, equals(sky.view.height)); | 19 expect(root.size.height, equals(sky.view.height)); |
| 35 }); | 20 }); |
| 36 } | 21 } |
| OLD | NEW |