| 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 '../resources/display_list.dart'; | 7 import '../resources/display_list.dart'; |
| 8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
| 9 import 'package:sky/framework/app.dart'; | 9 import 'package:sky/framework/app.dart'; |
| 10 import 'package:sky/framework/rendering/block.dart'; | 10 import 'package:sky/framework/rendering/block.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 decoration = new BoxDecoration(backgroundColor: backgroundColor); | 35 decoration = new BoxDecoration(backgroundColor: backgroundColor); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 TestApp app; | 39 TestApp app; |
| 40 | 40 |
| 41 void main() { | 41 void main() { |
| 42 initUnit(); | 42 initUnit(); |
| 43 | 43 |
| 44 test("should flex", () { | 44 test("should flex", () { |
| 45 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); | 45 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); |
| 46 | 46 |
| 47 RenderDecoratedBox root = new RenderDecoratedBox( | 47 RenderDecoratedBox root = new RenderDecoratedBox( |
| 48 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)
), | 48 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)
), |
| 49 child: flexRoot | 49 child: flexRoot |
| 50 ); | 50 ); |
| 51 | 51 |
| 52 void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, {
int flex: 0 }) { | 52 void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, {
int flex: 0 }) { |
| 53 RenderSolidColor child = new RenderSolidColor(backgroundColor); | 53 RenderSolidColor child = new RenderSolidColor(backgroundColor); |
| 54 parent.add(child); | 54 parent.add(child); |
| 55 child.parentData.flex = flex; | 55 child.parentData.flex = flex; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 renderBlock.add(new RenderSolidColor(const sky.Color(0xFF00FF00), desiredSiz
e: new sky.Size(100.0, 50.0))); | 67 renderBlock.add(new RenderSolidColor(const sky.Color(0xFF00FF00), desiredSiz
e: new sky.Size(100.0, 50.0))); |
| 68 renderBlock.add(new RenderSolidColor(const sky.Color(0x7700FFFF), desiredSiz
e: new sky.Size(50.0, 100.0))); | 68 renderBlock.add(new RenderSolidColor(const sky.Color(0x7700FFFF), desiredSiz
e: new sky.Size(50.0, 100.0))); |
| 69 | 69 |
| 70 var renderDecoratedBlock = new RenderDecoratedBox( | 70 var renderDecoratedBlock = new RenderDecoratedBox( |
| 71 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFFFF)
), | 71 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFFFFFFFF)
), |
| 72 child: renderBlock | 72 child: renderBlock |
| 73 ); | 73 ); |
| 74 | 74 |
| 75 flexRoot.add(new RenderPadding(padding: const EdgeDims.all(10.0), child: ren
derDecoratedBlock)); | 75 flexRoot.add(new RenderPadding(padding: const EdgeDims.all(10.0), child: ren
derDecoratedBlock)); |
| 76 | 76 |
| 77 var row = new RenderFlex(direction: FlexDirection.Horizontal); | 77 var row = new RenderFlex(direction: FlexDirection.horizontal); |
| 78 | 78 |
| 79 // Purple and blue cells | 79 // Purple and blue cells |
| 80 addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1); | 80 addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1); |
| 81 addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2); | 81 addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2); |
| 82 | 82 |
| 83 var decoratedRow = new RenderDecoratedBox( | 83 var decoratedRow = new RenderDecoratedBox( |
| 84 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)
), | 84 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)
), |
| 85 child: row | 85 child: row |
| 86 ); | 86 ); |
| 87 | 87 |
| 88 flexRoot.add(decoratedRow); | 88 flexRoot.add(decoratedRow); |
| 89 decoratedRow.parentData.flex = 3; | 89 decoratedRow.parentData.flex = 3; |
| 90 app = new TestApp(root); | 90 app = new TestApp(root); |
| 91 | 91 |
| 92 expect(root.size.width, equals(sky.view.width)); | 92 expect(root.size.width, equals(sky.view.width)); |
| 93 expect(root.size.height, equals(sky.view.height)); | 93 expect(root.size.height, equals(sky.view.height)); |
| 94 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); | 94 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); |
| 95 | 95 |
| 96 }); | 96 }); |
| 97 } | 97 } |
| OLD | NEW |