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:
Hixie
2015-06-11 15:36:40 -07:00
parent bdd3313417
commit 6c121f9a97
8 changed files with 63 additions and 60 deletions

View File

@@ -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:

View File

@@ -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);
});
}

View File

@@ -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.

View File

@@ -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));
});

View File

@@ -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:

View File

@@ -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
});
}

View File

@@ -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:

View File

@@ -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));