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/app.dart'; | 8 import 'package:sky/framework/app.dart'; |
9 import 'package:sky/framework/layout2.dart'; | 9 import 'package:sky/framework/rendering/render_block.dart'; |
| 10 import 'package:sky/framework/rendering/render_box.dart'; |
| 11 import 'package:sky/framework/rendering/render_flex.dart'; |
10 | 12 |
11 class RenderSolidColor extends RenderDecoratedBox { | 13 class RenderSolidColor extends RenderDecoratedBox { |
12 final sky.Size desiredSize; | 14 final sky.Size desiredSize; |
13 final int backgroundColor; | 15 final int backgroundColor; |
14 | 16 |
15 RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infin
ite() }) | 17 RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infin
ite() }) |
16 : backgroundColor = backgroundColor, | 18 : backgroundColor = backgroundColor, |
17 super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) { | 19 super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) { |
18 } | 20 } |
19 | 21 |
(...skipping 14 matching lines...) Expand all Loading... |
34 } | 36 } |
35 | 37 |
36 AppView app; | 38 AppView app; |
37 | 39 |
38 void main() { | 40 void main() { |
39 initUnit(); | 41 initUnit(); |
40 | 42 |
41 test("should flex", () { | 43 test("should flex", () { |
42 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); | 44 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); |
43 | 45 |
44 RenderNode root = new RenderDecoratedBox( | 46 RenderDecoratedBox root = new RenderDecoratedBox( |
45 decoration: new BoxDecoration(backgroundColor: 0xFF000000), | 47 decoration: new BoxDecoration(backgroundColor: 0xFF000000), |
46 child: flexRoot | 48 child: flexRoot |
47 ); | 49 ); |
48 | 50 |
49 void addFlexChildSolidColor(RenderFlex parent, int backgroundColor, { int fl
ex: 0 }) { | 51 void addFlexChildSolidColor(RenderFlex parent, int backgroundColor, { int fl
ex: 0 }) { |
50 RenderNode child = new RenderSolidColor(backgroundColor); | 52 RenderSolidColor child = new RenderSolidColor(backgroundColor); |
51 parent.add(child); | 53 parent.add(child); |
52 child.parentData.flex = flex; | 54 child.parentData.flex = flex; |
53 } | 55 } |
54 | 56 |
55 // Yellow bar at top | 57 // Yellow bar at top |
56 addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1); | 58 addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1); |
57 | 59 |
58 // Turquoise box | 60 // Turquoise box |
59 flexRoot.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.
0, 100.0))); | 61 flexRoot.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.
0, 100.0))); |
60 | 62 |
(...skipping 25 matching lines...) Expand all Loading... |
86 decoratedRow.parentData.flex = 3; | 88 decoratedRow.parentData.flex = 3; |
87 | 89 |
88 app = new AppView(root); | 90 app = new AppView(root); |
89 | 91 |
90 expect(root.size.width, equals(sky.view.width)); | 92 expect(root.size.width, equals(sky.view.width)); |
91 expect(root.size.height, equals(sky.view.height)); | 93 expect(root.size.height, equals(sky.view.height)); |
92 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); | 94 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); |
93 | 95 |
94 }); | 96 }); |
95 } | 97 } |
OLD | NEW |