mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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.
This commit is contained in:
parent
e8b2d8ad89
commit
406d7dbae1
@ -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<Stock> _stocks = [];
|
||||
|
||||
StocksApp() : super() {
|
||||
StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride) {
|
||||
// if (debug)
|
||||
// new Timer(new Duration(seconds: 1), dumpState);
|
||||
new StockDataFetcher((StockData data) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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<RenderBox> container,
|
||||
this.builder
|
||||
) : _container = container {
|
||||
) : _container = container, super() {
|
||||
assert(builder != null);
|
||||
}
|
||||
|
||||
|
||||
59
tests/framework/stocks-expected.txt
Normal file
59
tests/framework/stocks-expected.txt
Normal file
@ -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
|
||||
24
tests/framework/stocks.dart
Normal file
24
tests/framework/stocks.dart
Normal file
@ -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);
|
||||
});
|
||||
}
|
||||
@ -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:
|
||||
|
||||
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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));
|
||||
});
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user