| 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'; | |
| 6 import '../resources/unit.dart'; | |
| 7 import '../resources/display_list.dart'; | |
| 8 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
| 6 |
| 9 import 'package:sky/framework/app.dart'; | 7 import 'package:sky/framework/app.dart'; |
| 10 import 'package:sky/framework/rendering/block.dart'; | 8 import 'package:sky/framework/rendering/block.dart'; |
| 11 import 'package:sky/framework/rendering/box.dart'; | 9 import 'package:sky/framework/rendering/box.dart'; |
| 12 import 'package:sky/framework/rendering/flex.dart'; | 10 import 'package:sky/framework/rendering/flex.dart'; |
| 13 | 11 |
| 12 import '../resources/display_list.dart'; |
| 13 import '../resources/third_party/unittest/unittest.dart'; |
| 14 import '../resources/unit.dart'; |
| 15 |
| 14 class RenderSolidColor extends RenderDecoratedBox { | 16 class RenderSolidColor extends RenderDecoratedBox { |
| 15 final sky.Size desiredSize; | 17 final sky.Size desiredSize; |
| 16 final sky.Color backgroundColor; | 18 final sky.Color backgroundColor; |
| 17 | 19 |
| 18 RenderSolidColor(sky.Color backgroundColor, { this.desiredSize: sky.Size.infin
ite }) | 20 RenderSolidColor(sky.Color backgroundColor, { this.desiredSize: sky.Size.infin
ite }) |
| 19 : backgroundColor = backgroundColor, | 21 : backgroundColor = backgroundColor, |
| 20 super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) { | 22 super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) { |
| 21 } | 23 } |
| 22 | 24 |
| 23 double getMinIntrinsicWidth(BoxConstraints constraints) { | 25 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 } | 43 } |
| 42 | 44 |
| 43 void handleEvent(sky.Event event, BoxHitTestEntry entry) { | 45 void handleEvent(sky.Event event, BoxHitTestEntry entry) { |
| 44 if (event.type == 'pointerdown') | 46 if (event.type == 'pointerdown') |
| 45 decoration = new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000
)); | 47 decoration = new BoxDecoration(backgroundColor: const sky.Color(0xFFFF0000
)); |
| 46 else if (event.type == 'pointerup') | 48 else if (event.type == 'pointerup') |
| 47 decoration = new BoxDecoration(backgroundColor: backgroundColor); | 49 decoration = new BoxDecoration(backgroundColor: backgroundColor); |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 | 52 |
| 51 TestApp app; | |
| 52 | |
| 53 void main() { | 53 void main() { |
| 54 initUnit(); | 54 initUnit(); |
| 55 | 55 |
| 56 test("should flex", () { | 56 test("should flex", () { |
| 57 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); | 57 RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); |
| 58 | 58 |
| 59 RenderDecoratedBox root = new RenderDecoratedBox( | 59 RenderDecoratedBox root = new RenderDecoratedBox( |
| 60 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)
), | 60 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF000000)
), |
| 61 child: flexRoot | 61 child: flexRoot |
| 62 ); | 62 ); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 92 addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1); | 92 addFlexChildSolidColor(row, const sky.Color(0x77FF00FF), flex: 1); |
| 93 addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2); | 93 addFlexChildSolidColor(row, const sky.Color(0xFF0000FF), flex: 2); |
| 94 | 94 |
| 95 var decoratedRow = new RenderDecoratedBox( | 95 var decoratedRow = new RenderDecoratedBox( |
| 96 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)
), | 96 decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF333333)
), |
| 97 child: row | 97 child: row |
| 98 ); | 98 ); |
| 99 | 99 |
| 100 flexRoot.add(decoratedRow); | 100 flexRoot.add(decoratedRow); |
| 101 decoratedRow.parentData.flex = 3; | 101 decoratedRow.parentData.flex = 3; |
| 102 app = new TestApp(root); | 102 |
| 103 new TestRenderView(root); |
| 103 | 104 |
| 104 expect(root.size.width, equals(sky.view.width)); | 105 expect(root.size.width, equals(sky.view.width)); |
| 105 expect(root.size.height, equals(sky.view.height)); | 106 expect(root.size.height, equals(sky.view.height)); |
| 106 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); | 107 expect(renderBlock.size.width, equals(sky.view.width - 20.0)); |
| 107 | 108 |
| 108 }); | 109 }); |
| 109 } | 110 } |
| OLD | NEW |