Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: sky/tests/raw/render_box.dart

Issue 1156303004: Use Point, Size, and Rect in layout2.dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: address review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/framework/layout2.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 { 10 class RenderSizedBox extends RenderBox {
11 final double desiredHeight; 11 final sky.Size desiredSize;
12 final double desiredWidth;
13 12
14 RenderSizedBox({ this.desiredHeight: double.INFINITY, 13 RenderSizedBox({ this.desiredSize });
15 this.desiredWidth: double.INFINITY });
16 14
17 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) { 15 BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
18 return new BoxDimensions.withConstraints(constraints, 16 return new BoxDimensions.withConstraints(constraints,
19 height: desiredHeight, 17 width: desiredSize.width,
20 width: desiredWidth); 18 height: desiredSize.height);
21 } 19 }
22 20
23 void layout(BoxConstraints constraints, { RenderNode relayoutSubtreeRoot }) { 21 void performLayout() {
24 width = constraints.constrainWidth(desiredWidth); 22 size = constraints.constrain(desiredSize);
25 height = constraints.constrainHeight(desiredHeight);
26 layoutDone();
27 } 23 }
28 } 24 }
29 25
30 void main() { 26 void main() {
31 initUnit(); 27 initUnit();
32 28
33 test("should size to render view", () { 29 test("should size to render view", () {
34 RenderSizedBox root = new RenderSizedBox(); 30 RenderSizedBox root = new RenderSizedBox(desiredSize: new sky.Size.infinite( ));
35 RenderView renderView = new RenderView(child: root); 31 RenderView renderView = new RenderView(child: root);
36 renderView.layout(newWidth: sky.view.width, newHeight: sky.view.height); 32 renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.vie w.height));
37 expect(root.width, equals(sky.view.width)); 33 expect(root.size.width, equals(sky.view.width));
38 expect(root.height, equals(sky.view.height)); 34 expect(root.size.height, equals(sky.view.height));
39 }); 35 });
40 } 36 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/layout2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698