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 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
8 import 'package:sky/framework/app.dart'; | 9 import 'package:sky/framework/app.dart'; |
9 import 'package:sky/framework/rendering/render_block.dart'; | 10 import 'package:sky/framework/rendering/render_block.dart'; |
10 import 'package:sky/framework/rendering/render_box.dart'; | 11 import 'package:sky/framework/rendering/render_box.dart'; |
11 import 'package:sky/framework/rendering/render_flex.dart'; | 12 import 'package:sky/framework/rendering/render_flex.dart'; |
12 | 13 |
13 class RenderSolidColor extends RenderDecoratedBox { | 14 class RenderSolidColor extends RenderDecoratedBox { |
14 final sky.Size desiredSize; | 15 final sky.Size desiredSize; |
15 final int backgroundColor; | 16 final int backgroundColor; |
16 | 17 |
(...skipping 11 matching lines...) Expand all Loading... |
28 } | 29 } |
29 | 30 |
30 void handlePointer(sky.PointerEvent event) { | 31 void handlePointer(sky.PointerEvent event) { |
31 if (event.type == 'pointerdown') | 32 if (event.type == 'pointerdown') |
32 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); | 33 decoration = new BoxDecoration(backgroundColor: 0xFFFF0000); |
33 else if (event.type == 'pointerup') | 34 else if (event.type == 'pointerup') |
34 decoration = new BoxDecoration(backgroundColor: backgroundColor); | 35 decoration = new BoxDecoration(backgroundColor: backgroundColor); |
35 } | 36 } |
36 } | 37 } |
37 | 38 |
38 AppView app; | 39 TestApp app; |
39 | 40 |
40 void main() { | 41 void main() { |
41 initUnit(); | 42 initUnit(); |
42 | 43 |
43 test("should flex", () { | 44 test("should flex", () { |
44 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); | 45 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical); |
45 | 46 |
46 RenderDecoratedBox root = new RenderDecoratedBox( | 47 RenderDecoratedBox root = new RenderDecoratedBox( |
47 decoration: new BoxDecoration(backgroundColor: 0xFF000000), | 48 decoration: new BoxDecoration(backgroundColor: 0xFF000000), |
48 child: flexRoot | 49 child: flexRoot |
(...skipping 30 matching lines...) Expand all Loading... |
79 addFlexChildSolidColor(row, 0x77FF00FF, flex: 1); | 80 addFlexChildSolidColor(row, 0x77FF00FF, flex: 1); |
80 addFlexChildSolidColor(row, 0xFF0000FF, flex: 2); | 81 addFlexChildSolidColor(row, 0xFF0000FF, flex: 2); |
81 | 82 |
82 var decoratedRow = new RenderDecoratedBox( | 83 var decoratedRow = new RenderDecoratedBox( |
83 decoration: new BoxDecoration(backgroundColor: 0xFF333333), | 84 decoration: new BoxDecoration(backgroundColor: 0xFF333333), |
84 child: row | 85 child: row |
85 ); | 86 ); |
86 | 87 |
87 flexRoot.add(decoratedRow); | 88 flexRoot.add(decoratedRow); |
88 decoratedRow.parentData.flex = 3; | 89 decoratedRow.parentData.flex = 3; |
89 | 90 app = new TestApp(root); |
90 app = new AppView(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 |