From 406d7dbae1776ef3dab5f1f03cd1b661149286af Mon Sep 17 00:00:00 2001 From: Hixie Date: Thu, 11 Jun 2015 15:36:40 -0700 Subject: [PATCH] Make it possible to test that the stock app doesn't crash on startup and paints the basic scaffold more or less correctly. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1177043008. --- examples/stocks2/lib/stock_app.dart | 4 +- sdk/lib/framework/app.dart | 15 ++-- sdk/lib/framework/widgets/ui_node.dart | 16 ++-- tests/framework/stocks-expected.txt | 59 +++++++++++++ tests/framework/stocks.dart | 24 ++++++ tests/raw/box_layout-expected.txt | 12 +-- tests/raw/box_layout.dart | 12 +-- tests/raw/padding_deflate-expected.txt | 10 ++- tests/raw/padding_deflate.dart | 14 ++-- tests/raw/render_box-expected.txt | 6 +- tests/raw/render_box.dart | 16 ++-- tests/raw/render_flex-expected.txt | 40 ++++----- tests/raw/render_flex.dart | 13 +-- tests/resources/display_list.dart | 100 ++++++++++++----------- tools/webkitpy/layout_tests/port/base.py | 6 +- 15 files changed, 220 insertions(+), 127 deletions(-) create mode 100644 tests/framework/stocks-expected.txt create mode 100644 tests/framework/stocks.dart diff --git a/examples/stocks2/lib/stock_app.dart b/examples/stocks2/lib/stock_app.dart index 66e4eb25a83..db559946e6d 100644 --- a/examples/stocks2/lib/stock_app.dart +++ b/examples/stocks2/lib/stock_app.dart @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:sky/framework/app.dart'; import 'package:sky/framework/editing2/input.dart'; +import 'package:sky/framework/rendering/box.dart'; import 'package:sky/framework/theme2/colors.dart' as colors; import 'package:sky/framework/widgets/drawer.dart'; import 'package:sky/framework/widgets/drawer_header.dart'; @@ -32,7 +34,7 @@ class StocksApp extends App { List _stocks = []; - StocksApp() : super() { + StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride) { // if (debug) // new Timer(new Duration(seconds: 1), dumpState); new StockDataFetcher((StockData data) { diff --git a/sdk/lib/framework/app.dart b/sdk/lib/framework/app.dart index 7785088e697..701821c24f4 100644 --- a/sdk/lib/framework/app.dart +++ b/sdk/lib/framework/app.dart @@ -16,7 +16,7 @@ class PointerState { class AppView { - AppView([RenderBox root = null]) { + AppView({ RenderBox root: null, RenderView renderViewOverride }) { assert(_app == null); _app = this; @@ -25,10 +25,15 @@ class AppView { scheduler.init(); scheduler.addPersistentFrameCallback(_beginFrame); - _renderView = new RenderView(child: root); - _renderView.attach(); - _renderView.rootConstraints = _viewConstraints; - _renderView.scheduleInitialLayout(); + if (renderViewOverride == null) { + _renderView = new RenderView(child: root); + _renderView.attach(); + _renderView.rootConstraints = _viewConstraints; + _renderView.scheduleInitialLayout(); + } else { + _renderView = renderViewOverride; + } + assert(_renderView != null); assert(_app == this); } diff --git a/sdk/lib/framework/widgets/ui_node.dart b/sdk/lib/framework/widgets/ui_node.dart index d8d5968fe3a..44db51f5ca8 100644 --- a/sdk/lib/framework/widgets/ui_node.dart +++ b/sdk/lib/framework/widgets/ui_node.dart @@ -747,15 +747,15 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper { class UINodeAppView extends AppView { - UINodeAppView() { + UINodeAppView({ RenderView renderViewOverride: null }) + : super(renderViewOverride: renderViewOverride) { assert(_appView == null); } static UINodeAppView _appView; static AppView get appView => _appView; - static void initUINodeAppView() { - if (_appView == null) - _appView = new UINodeAppView(); + static void initUINodeAppView({ RenderView renderViewOverride: null }) { + _appView = new UINodeAppView(renderViewOverride: renderViewOverride); } void dispatchEvent(sky.Event event, HitTestResult result) { @@ -778,8 +778,8 @@ class UINodeAppView extends AppView { abstract class AbstractUINodeRoot extends Component { - AbstractUINodeRoot() : super(stateful: true) { - UINodeAppView.initUINodeAppView(); + AbstractUINodeRoot({ RenderView renderViewOverride }) : super(stateful: true) { + UINodeAppView.initUINodeAppView(renderViewOverride: renderViewOverride); _mounted = true; _scheduleComponentForRender(this); } @@ -800,7 +800,7 @@ abstract class AbstractUINodeRoot extends Component { abstract class App extends AbstractUINodeRoot { - App(); + App({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride); void _buildIfDirty() { super._buildIfDirty(); @@ -821,7 +821,7 @@ class RenderObjectToUINodeAdapter extends AbstractUINodeRoot { RenderObjectToUINodeAdapter( RenderObjectWithChildMixin container, this.builder - ) : _container = container { + ) : _container = container, super() { assert(builder != null); } diff --git a/tests/framework/stocks-expected.txt b/tests/framework/stocks-expected.txt new file mode 100644 index 00000000000..7ae6d8db419 --- /dev/null +++ b/tests/framework/stocks-expected.txt @@ -0,0 +1,59 @@ +CONSOLE: TestRenderView enabled +CONSOLE: +PAINT FOR FRAME #1 ---------------------------------------------- +1 | TestDisplayList() constructor: 800.0 x 600.0 +------------------------------------------------------------------------ +CONSOLE: unittest-suite-wait-for-done +CONSOLE: +PAINT FOR FRAME #2 ---------------------------------------------- +2 | TestDisplayList() constructor: 800.0 x 600.0 +2 | paintChild RenderStack at Point(0.0, 0.0) +2 | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | paintChild RenderScaffold at Point(0.0, 0.0) +2 | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | paintChild RenderSizeObserver at Point(0.0, 81.0) +2 | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | save +2 | | | | clipRect(Rect.fromLTRB(0.0, 0.0, 800.0, 519.0)) +2 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 519.0), Paint(Color(0xffffffff))) +2 | | | | save +2 | | | | concat([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]) +2 | | | | restore +2 | | | | restore +2 | | | paintChild RenderDecoratedBox at Point(0.0, 0.0) +2 | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 81.0), Paint(Color(0xff9c27b0))) +2 | | | | paintChild RenderFlex at Point(8.0, 0.0) +2 | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | paintChild RenderSizedBox at Point(0.0, 25.0) +2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderPadding at Point(0.0, 8.0) +2 | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | | paintChild RenderImage at Point(8.0, 8.0) +2 | | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderPadding at Point(40.0, 18.5) +2 | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | | paintChild RenderParagraph at Point(24.0, 0.0) +2 | | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderPadding at Point(704.0, 8.0) +2 | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | | paintChild RenderImage at Point(8.0, 8.0) +2 | | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | paintChild RenderPadding at Point(744.0, 8.0) +2 | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | | | | paintChild RenderImage at Point(8.0, 8.0) +2 | | | | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | paintChild RenderCustomPaint at Point(728.0, 528.0) +2 | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | drawCircle(28.0, 28.0, 28.0, Paint(Color(0xfff44336))) +2 | | | | saveLayer(Rect.fromLTRB(0.0, 0.0, 56.0, 56.0), Paint(Color(0xff000000))) +2 | | | | clipPath(Instance of 'Path') +2 | | | | paintChild RenderImage at Point(16.0, 16.0) +2 | | | | | TestDisplayList() constructor: 800.0 x 600.0 +2 | | | | restore +------------------------------------------------------------------------ +CONSOLE: PASS: launching stock app +CONSOLE: +CONSOLE: All 1 tests passed. +CONSOLE: unittest-suite-success +DONE diff --git a/tests/framework/stocks.dart b/tests/framework/stocks.dart new file mode 100644 index 00000000000..401f12f7e5b --- /dev/null +++ b/tests/framework/stocks.dart @@ -0,0 +1,24 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +import 'package:sky/framework/app.dart'; +import 'package:sky/framework/widgets/ui_node.dart'; + +import '../../examples/stocks2/lib/stock_app.dart'; +import '../resources/display_list.dart'; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; + +void main() { + initUnit(); + + TestRenderView testRenderView = new TestRenderView(); + + test("launching stock app", () { + new StocksApp(renderViewOverride: testRenderView); + new Future.microtask(testRenderView.checkFrame); + }); +} diff --git a/tests/raw/box_layout-expected.txt b/tests/raw/box_layout-expected.txt index a3d0b908bc2..87801ba731b 100644 --- a/tests/raw/box_layout-expected.txt +++ b/tests/raw/box_layout-expected.txt @@ -1,16 +1,16 @@ CONSOLE: unittest-suite-wait-for-done -CONSOLE: TestView enabled +CONSOLE: TestRenderView enabled CONSOLE: PAINT FOR FRAME #1 ---------------------------------------------- 1 | TestDisplayList() constructor: 800.0 x 600.0 -1 | paintChild at 0.0,0.0 +1 | paintChild RenderDecoratedBox at Point(0.0, 0.0) 1 | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff0000ff))) -1 | | paintChild at 0.0,0.0 +1 | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), Paint(Color(0xff0000ff))) +1 | | paintChild RenderPadding at Point(0.0, 0.0) 1 | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | paintChild at 50.0,50.0 +1 | | | paintChild RenderDecoratedBox at Point(50.0, 50.0) 1 | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | drawRect(0.0:0.0:100.0:700.0, Paint(Color(0xff00ff00))) +1 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 700.0, 100.0), Paint(Color(0xff00ff00))) ------------------------------------------------------------------------ CONSOLE: PASS: padding CONSOLE: diff --git a/tests/raw/box_layout.dart b/tests/raw/box_layout.dart index 8f0f7286e18..65e4213fb60 100644 --- a/tests/raw/box_layout.dart +++ b/tests/raw/box_layout.dart @@ -1,14 +1,14 @@ -import '../resources/third_party/unittest/unittest.dart'; -import '../resources/unit.dart'; -import '../resources/display_list.dart'; import 'dart:math' as math; import 'dart:sky' as sky; + import 'package:sky/framework/app.dart'; -import 'package:sky/framework/rendering/box.dart'; import 'package:sky/framework/rendering/block.dart'; +import 'package:sky/framework/rendering/box.dart'; import 'package:sky/framework/rendering/object.dart'; -TestApp app; +import '../resources/display_list.dart'; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; void main() { initUnit(); @@ -19,6 +19,6 @@ void main() { var padding = new RenderPadding(padding: new EdgeDims.all(50.0), child: inner); var block = new RenderBlock(children: [padding]); var outer = new RenderDecoratedBox(decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF0000FF)), child: block); - app = new TestApp(outer); + new TestRenderView(outer); }); } diff --git a/tests/raw/padding_deflate-expected.txt b/tests/raw/padding_deflate-expected.txt index a6444cb469e..ebc2a1baae2 100644 --- a/tests/raw/padding_deflate-expected.txt +++ b/tests/raw/padding_deflate-expected.txt @@ -1,5 +1,13 @@ CONSOLE: unittest-suite-wait-for-done -CONSOLE: TestView enabled +CONSOLE: TestRenderView enabled +CONSOLE: +PAINT FOR FRAME #1 ---------------------------------------------- +1 | TestDisplayList() constructor: 800.0 x 600.0 +1 | paintChild RenderDecoratedBox at Point(0.0, 0.0) +1 | | TestDisplayList() constructor: 800.0 x 600.0 +1 | | paintChild RenderDecoratedBox at Point(10.0, 10.0) +1 | | | TestDisplayList() constructor: 800.0 x 600.0 +------------------------------------------------------------------------ CONSOLE: PASS: should not have a 0 sized colored Box CONSOLE: CONSOLE: All 1 tests passed. diff --git a/tests/raw/padding_deflate.dart b/tests/raw/padding_deflate.dart index 091db772f8e..80533cd1671 100644 --- a/tests/raw/padding_deflate.dart +++ b/tests/raw/padding_deflate.dart @@ -3,12 +3,14 @@ // found in the LICENSE file. import 'dart:sky' as sky; -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'; +import '../resources/display_list.dart'; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; + void main() { initUnit(); @@ -22,11 +24,7 @@ void main() { decoration: new BoxDecoration(), child: paddingBox ); - TestView renderView = new TestView(child: root); - renderView.attach(); - renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height); - renderView.scheduleInitialLayout(); - RenderObject.flushLayout(); + new TestRenderView(root); expect(coloredBox.size.width, equals(sky.view.width - 20)); expect(coloredBox.size.height, equals(sky.view.height - 20)); }); diff --git a/tests/raw/render_box-expected.txt b/tests/raw/render_box-expected.txt index 49a9ef1b30e..4e08ce89160 100644 --- a/tests/raw/render_box-expected.txt +++ b/tests/raw/render_box-expected.txt @@ -1,11 +1,11 @@ CONSOLE: unittest-suite-wait-for-done -CONSOLE: TestView enabled +CONSOLE: TestRenderView enabled CONSOLE: PAINT FOR FRAME #1 ---------------------------------------------- 1 | TestDisplayList() constructor: 800.0 x 600.0 -1 | paintChild at 0.0,0.0 +1 | paintChild RenderSizedBox at Point(0.0, 0.0) 1 | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff00ff00))) +1 | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), Paint(Color(0xff00ff00))) ------------------------------------------------------------------------ CONSOLE: PASS: should size to render view CONSOLE: diff --git a/tests/raw/render_box.dart b/tests/raw/render_box.dart index 25ff3bb8d79..e322213d566 100644 --- a/tests/raw/render_box.dart +++ b/tests/raw/render_box.dart @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import '../resources/third_party/unittest/unittest.dart'; -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'; +import '../resources/display_list.dart'; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; + void main() { initUnit(); @@ -18,14 +20,8 @@ void main() { decoration: new BoxDecoration(backgroundColor: const sky.Color(0xFF00FF00)) ) ); - TestView renderView = new TestView(child: root); - renderView.attach(); - renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height); - renderView.scheduleInitialLayout(); - RenderObject.flushLayout(); + new TestRenderView(root); expect(root.size.width, equals(sky.view.width)); expect(root.size.height, equals(sky.view.height)); - renderView.paintFrame(); - print(renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better }); } diff --git a/tests/raw/render_flex-expected.txt b/tests/raw/render_flex-expected.txt index a3253435609..137e7512f04 100644 --- a/tests/raw/render_flex-expected.txt +++ b/tests/raw/render_flex-expected.txt @@ -1,37 +1,37 @@ CONSOLE: unittest-suite-wait-for-done -CONSOLE: TestView enabled +CONSOLE: TestRenderView enabled CONSOLE: PAINT FOR FRAME #1 ---------------------------------------------- 1 | TestDisplayList() constructor: 800.0 x 600.0 -1 | paintChild at 0.0,0.0 +1 | paintChild RenderDecoratedBox at Point(0.0, 0.0) 1 | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | drawRect(0.0:0.0:600.0:800.0, Paint(Color(0xff000000))) -1 | | paintChild at 0.0,0.0 +1 | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), Paint(Color(0xff000000))) +1 | | paintChild RenderSolidColor at Point(0.0, 0.0) 1 | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | drawRect(0.0:0.0:82.5:800.0, Paint(Color(0xffffff00))) -1 | | paintChild at 350.0,82.5 +1 | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 82.5), Paint(Color(0xffffff00))) +1 | | paintChild RenderSolidColor at Point(350.0, 82.5) 1 | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | drawRect(0.0:0.0:100.0:100.0, Paint(Color(0x7700ffff))) -1 | | paintChild at 0.0,182.5 +1 | | | drawRect(Rect.fromLTRB(0.0, 0.0, 100.0, 100.0), Paint(Color(0x7700ffff))) +1 | | paintChild RenderPadding at Point(0.0, 182.5) 1 | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | paintChild at 10.0,10.0 +1 | | | paintChild RenderDecoratedBox at Point(10.0, 10.0) 1 | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | drawRect(0.0:0.0:150.0:780.0, Paint(Color(0xffffffff))) -1 | | | | paintChild at 0.0,0.0 +1 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 780.0, 150.0), Paint(Color(0xffffffff))) +1 | | | | paintChild RenderSolidColor at Point(0.0, 0.0) 1 | | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | | drawRect(0.0:0.0:50.0:780.0, Paint(Color(0xff00ff00))) -1 | | | | paintChild at 0.0,50.0 +1 | | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 780.0, 50.0), Paint(Color(0xff00ff00))) +1 | | | | paintChild RenderSolidColor at Point(0.0, 50.0) 1 | | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | | drawRect(0.0:0.0:100.0:780.0, Paint(Color(0x7700ffff))) -1 | | paintChild at 0.0,352.5 +1 | | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 780.0, 100.0), Paint(Color(0x7700ffff))) +1 | | paintChild RenderDecoratedBox at Point(0.0, 352.5) 1 | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | drawRect(0.0:0.0:247.5:800.0, Paint(Color(0xff333333))) -1 | | | paintChild at 0.0,0.0 +1 | | | drawRect(Rect.fromLTRB(0.0, 0.0, 800.0, 247.5), Paint(Color(0xff333333))) +1 | | | paintChild RenderSolidColor at Point(0.0, 0.0) 1 | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | drawRect(0.0:0.0:247.5:266.6666564941406, Paint(Color(0x77ff00ff))) -1 | | | paintChild at 266.6666666666667,0.0 +1 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 266.6666564941406, 247.5), Paint(Color(0x77ff00ff))) +1 | | | paintChild RenderSolidColor at Point(266.6666666666667, 0.0) 1 | | | | TestDisplayList() constructor: 800.0 x 600.0 -1 | | | | drawRect(0.0:0.0:247.5:533.3333129882812, Paint(Color(0xff0000ff))) +1 | | | | drawRect(Rect.fromLTRB(0.0, 0.0, 533.3333129882812, 247.5), Paint(Color(0xff0000ff))) ------------------------------------------------------------------------ CONSOLE: PASS: should flex CONSOLE: diff --git a/tests/raw/render_flex.dart b/tests/raw/render_flex.dart index 49baa219a52..a19861aa07a 100644 --- a/tests/raw/render_flex.dart +++ b/tests/raw/render_flex.dart @@ -2,15 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import '../resources/third_party/unittest/unittest.dart'; -import '../resources/unit.dart'; -import '../resources/display_list.dart'; import 'dart:sky' as sky; + import 'package:sky/framework/app.dart'; import 'package:sky/framework/rendering/block.dart'; import 'package:sky/framework/rendering/box.dart'; import 'package:sky/framework/rendering/flex.dart'; +import '../resources/display_list.dart'; +import '../resources/third_party/unittest/unittest.dart'; +import '../resources/unit.dart'; + class RenderSolidColor extends RenderDecoratedBox { final sky.Size desiredSize; final sky.Color backgroundColor; @@ -48,8 +50,6 @@ class RenderSolidColor extends RenderDecoratedBox { } } -TestApp app; - void main() { initUnit(); @@ -99,7 +99,8 @@ void main() { flexRoot.add(decoratedRow); decoratedRow.parentData.flex = 3; - app = new TestApp(root); + + new TestRenderView(root); expect(root.size.width, equals(sky.view.width)); expect(root.size.height, equals(sky.view.height)); diff --git a/tests/resources/display_list.dart b/tests/resources/display_list.dart index 95ed3aca955..71f5202ac71 100644 --- a/tests/resources/display_list.dart +++ b/tests/resources/display_list.dart @@ -1,8 +1,9 @@ -import 'package:sky/framework/rendering/object.dart'; -import 'package:sky/framework/rendering/box.dart'; import 'dart:sky' as sky; +import 'package:sky/framework/rendering/box.dart'; +import 'package:sky/framework/rendering/object.dart'; + typedef void Logger (String s); class TestDisplayList extends RenderObjectDisplayList { @@ -22,7 +23,8 @@ class TestDisplayList extends RenderObjectDisplayList { logger("${indent} ${s}"); } - String explainPaint(sky.Paint paint) { + String explainPaint(Paint paint) { + assert(paint.toString() == "Instance of 'Paint'"); // if this assertion fails, remove all calls to explainPaint with just inlining $paint return "Paint(${paint.color})"; } @@ -30,8 +32,8 @@ class TestDisplayList extends RenderObjectDisplayList { log("save"); } - void saveLayer(sky.Rect bounds, sky.Paint paint) { - log("saveLayer(${bounds.top}:${bounds.left}:${bounds.bottom}:${bounds.right}, ${explainPaint(paint)})"); + void saveLayer(Rect bounds, Paint paint) { + log("saveLayer($bounds, ${explainPaint(paint)})"); } void restore() { @@ -58,47 +60,68 @@ class TestDisplayList extends RenderObjectDisplayList { log("concat($matrix9)"); } - void clipRect(sky.Rect rect) { - log("clipRect(${rect.top}:${rect.left}:${rect.bottom}:${rect.right})"); + void clipRect(Rect rect) { + log("clipRect($rect)"); + } + + void clipRRect(sky.RRect rrect) { + log("clipRRect()"); + } + + void clipPath(Path path) { + log("clipPath($path)"); + } + + void drawLine(double x0, double y0, double x1, double y1, Paint paint) { + log("drawLine($x0, $y0, $x1, $y1, ${explainPaint(paint)})"); } void drawPicture(sky.Picture picture) { - log("drawPicture()"); + log("drawPicture($picture)"); } - void drawPaint(sky.Paint paint) { + void drawPaint(Paint paint) { log("drawPaint(${explainPaint(paint)})"); } - void drawRect(sky.Rect rect, sky.Paint paint) { - log("drawRect(${rect.top}:${rect.left}:${rect.bottom}:${rect.right}, ${explainPaint(paint)})"); + void drawRect(Rect rect, Paint paint) { + log("drawRect($rect, ${explainPaint(paint)})"); } - void drawOval(sky.Rect rect, sky.Paint paint) { - log("drawOval(${rect.top}:${rect.left}:${rect.bottom}:${rect.right}, ${explainPaint(paint)})"); + void drawRRect(sky.RRect rrect, Paint paint) { + log("drawRRect($rrect, ${explainPaint(paint)})"); } - void drawCircle(double x, double y, double radius, sky.Paint paint) { + void drawOval(Rect rect, Paint paint) { + log("drawOval($rect, ${explainPaint(paint)})"); + } + + void drawCircle(double x, double y, double radius, Paint paint) { log("drawCircle($x, $y, $radius, ${explainPaint(paint)})"); } - void drawPath(sky.Path path, sky.Paint paint) { - log("drawPath(Path, ${explainPaint(paint)})"); + void drawPath(Path path, Paint paint) { + log("drawPath($path, ${explainPaint(paint)})"); } - void paintChild(RenderObject child, sky.Point position) { - log("paintChild at ${position.x},${position.y}"); + void drawImage(sky.Image image, double x, double y, Paint paint) { + log("drawImage($image, $x, $y, ${explainPaint(paint)})"); + } + + void paintChild(RenderObject child, Point position) { + log("paintChild ${child.runtimeType} at $position"); child.paint(new TestDisplayList(width, height, logger, indent: "$indent |")); } } -class TestView extends RenderView { +class TestRenderView extends RenderView { - TestView({ - RenderBox child, - Duration timeForRotation - }) : super(child: child, timeForRotation: timeForRotation) { - print("TestView enabled"); + TestRenderView([ RenderBox child = null ]) : super(child: child) { + print("TestRenderView enabled"); + attach(); + rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbitrary figures + scheduleInitialLayout(); + checkFrame(); } int frame = 0; @@ -111,37 +134,18 @@ class TestView extends RenderView { void paintFrame() { RenderObject.debugDoingPaint = true; frame += 1; + lastPaint = ''; log("PAINT FOR FRAME #${frame} ----------------------------------------------"); - var canvas = new TestDisplayList(sky.view.width, sky.view.height, log, indent: "${frame} |"); + var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.height, log, indent: "${frame} |"); paint(canvas); log("------------------------------------------------------------------------"); RenderObject.debugDoingPaint = false; } -} - -class TestApp { - - TestApp(RenderBox root) { - _renderView = new TestView(child: root); - _renderView.attach(); - _renderView.rootConstraints = new ViewConstraints(width: sky.view.width, height: sky.view.height); - _renderView.scheduleInitialLayout(); + void checkFrame() { RenderObject.flushLayout(); - _renderView.paintFrame(); - print(_renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better - } - - RenderView _renderView; - - RenderBox get root => _renderView.child; - void set root(RenderBox value) { - _renderView.child = value; - } - void _beginFrame(double timeStamp) { - RenderObject.flushLayout(); - _renderView.paintFrame(); - print(_renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better + paintFrame(); + print(lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better } } diff --git a/tools/webkitpy/layout_tests/port/base.py b/tools/webkitpy/layout_tests/port/base.py index b1845e9fbfe..9b4899b4149 100644 --- a/tools/webkitpy/layout_tests/port/base.py +++ b/tools/webkitpy/layout_tests/port/base.py @@ -247,11 +247,7 @@ class Port(object): return False def default_timeout_ms(self): - # TODO(esprehn): Remove this hack. - timeout_ms = 30 * 1000 - # if self.get_option('configuration') == 'Debug': - # # Debug is usually 2x-3x slower than Release. - # return 3 * timeout_ms + timeout_ms = 4000 return timeout_ms def driver_stop_timeout(self):