提交 a68b53ae 编写于 作者: A Adam Barth

Fix the Sky tests

Instead of triggering layout synchronously during AppView construction, we now
schedule the initial layout using a magic bootstrapping function.

TBR=ianh@google.com

Review URL: https://codereview.chromium.org/1172123003.
上级 4011ec97
......@@ -25,7 +25,7 @@ class AppView {
_renderView = new RenderView(child: root);
_renderView.attach();
_renderView.rootConstraints = _viewConstraints;
_renderView.layout(_renderView.rootConstraints);
_renderView.scheduleInitialLayout();
}
RenderView _renderView;
......
......@@ -956,8 +956,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
markNeedsLayout();
}
ViewConstraints get constraints => super.constraints as ViewConstraints;
void performLayout() {
if (_rootConstraints.orientation != _orientation) {
if (_orientation != null && child != null)
......
......@@ -119,6 +119,14 @@ abstract class RenderObject extends AbstractNode {
scheduler.ensureVisualUpdate();
}
}
void scheduleInitialLayout() {
assert(attached);
assert(parent == null);
assert(_relayoutSubtreeRoot == null);
_relayoutSubtreeRoot = this;
_nodesNeedingLayout.add(this);
scheduler.ensureVisualUpdate();
}
static void flushLayout() {
_debugDoingLayout = true;
List<RenderObject> dirtyNodes = _nodesNeedingLayout;
......
......@@ -7,6 +7,7 @@ import '../resources/third_party/unittest/unittest.dart';
import '../resources/unit.dart';
import '../resources/display_list.dart';
import 'package:sky/framework/rendering/box.dart';
import 'package:sky/framework/rendering/object.dart';
void main() {
initUnit();
......@@ -22,7 +23,10 @@ void main() {
child: paddingBox
);
TestView renderView = new TestView(child: root);
renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
renderView.attach();
renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height);
renderView.scheduleInitialLayout();
RenderObject.flushLayout();
expect(coloredBox.size.width, equals(sky.view.width - 20));
expect(coloredBox.size.height, equals(sky.view.height - 20));
});
......
......@@ -7,6 +7,7 @@ import '../resources/unit.dart';
import '../resources/display_list.dart';
import 'dart:sky' as sky;
import 'package:sky/framework/rendering/box.dart';
import 'package:sky/framework/rendering/object.dart';
void main() {
initUnit();
......@@ -18,7 +19,10 @@ void main() {
)
);
TestView renderView = new TestView(child: root);
renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
renderView.attach();
renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height);
renderView.scheduleInitialLayout();
RenderObject.flushLayout();
expect(root.size.width, equals(sky.view.width));
expect(root.size.height, equals(sky.view.height));
renderView.paintFrame();
......
......@@ -125,7 +125,9 @@ class TestApp {
TestApp(RenderBox root) {
_renderView = new TestView(child: root);
_renderView.attach();
_renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.view.height));
_renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height);
_renderView.scheduleInitialLayout();
RenderObject.flushLayout();
_renderView.paintFrame();
print(_renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册