提交 1d905916 编写于 作者: A Adam Barth

Add some basic tests for the material buttons

Specifically, RaisedButton, FlatButton, and FloatingActionButton. These just
test that these classes work in their default configurations.

R=ianh@google.com, jackson@chromium.org

Review URL: https://codereview.chromium.org/1193453005.
上级 9cdd8bb8
import 'dart:async';
import 'dart:sky' as sky;
import "dart:sky.internals" as internals;
import 'package:sky/widgets/basic.dart';
import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/object.dart';
......@@ -156,3 +158,29 @@ class TestRenderView extends RenderView {
}
}
class TestApp extends App {
TestApp({
this.builder,
RenderView renderViewOverride
}) : super(renderViewOverride: renderViewOverride);
Function builder;
Widget build() {
return builder();
}
}
class WidgetTester {
TestRenderView renderView = new TestRenderView();
Future test(Function builder) {
new TestApp(renderViewOverride: renderView, builder: builder);
return new Future.microtask(renderView.checkFrame);
}
Future endTest() {
return new Future.microtask(renderView.endTest);
}
}
CONSOLE: TestRenderView enabled
CONSOLE:
PAINT FOR FRAME #1 ----------------------------------------------
1 | TestDisplayList() constructor: 800.0 x 600.0
------------------------------------------------------------------------
CONSOLE:
PAINT FOR FRAME #2 ----------------------------------------------
2 | TestDisplayList() constructor: 800.0 x 600.0
2 | paintChild RenderPositionedBox at Point(0.0, 0.0)
2 | | TestDisplayList() constructor: 800.0 x 600.0
2 | | paintChild RenderPadding at Point(348.0, 274.0)
2 | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | paintChild RenderConstrainedBox at Point(8.0, 8.0)
2 | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | drawRRect(Instance of 'RRect', Paint(Color(0xffe0e0e0)))
2 | | | | paintChild RenderPositionedBox at Point(8.0, 0.0)
2 | | | | | TestDisplayList() constructor: 800.0 x 600.0
2 | | | | | paintChild RenderParagraph at Point(6.0, 10.0)
2 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
------------------------------------------------------------------------
CONSOLE:
PAINT FOR FRAME #3 ----------------------------------------------
3 | TestDisplayList() constructor: 800.0 x 600.0
3 | paintChild RenderPositionedBox at Point(0.0, 0.0)
3 | | TestDisplayList() constructor: 800.0 x 600.0
3 | | paintChild RenderPadding at Point(348.0, 274.0)
3 | | | TestDisplayList() constructor: 800.0 x 600.0
3 | | | paintChild RenderConstrainedBox at Point(8.0, 8.0)
3 | | | | TestDisplayList() constructor: 800.0 x 600.0
3 | | | | drawRRect(Instance of 'RRect', Paint(Color(0xfffafafa)))
3 | | | | paintChild RenderPositionedBox at Point(8.0, 0.0)
3 | | | | | TestDisplayList() constructor: 800.0 x 600.0
3 | | | | | paintChild RenderParagraph at Point(6.0, 10.0)
3 | | | | | | TestDisplayList() constructor: 800.0 x 600.0
------------------------------------------------------------------------
CONSOLE:
PAINT FOR FRAME #4 ----------------------------------------------
4 | TestDisplayList() constructor: 800.0 x 600.0
4 | paintChild RenderPositionedBox at Point(0.0, 0.0)
4 | | TestDisplayList() constructor: 800.0 x 600.0
4 | | paintChild RenderDecoratedBox at Point(372.0, 272.0)
4 | | | TestDisplayList() constructor: 800.0 x 600.0
4 | | | drawCircle(28.0, 28.0, 28.0, Paint(Color(0xfff44336)))
4 | | | saveLayer(Rect.fromLTRB(0.0, 0.0, 56.0, 56.0), Paint(Color(0xff000000)))
4 | | | clipPath(Instance of 'Path')
4 | | | paintChild RenderParagraph at Point(22.0, 20.0)
4 | | | | TestDisplayList() constructor: 800.0 x 600.0
4 | | | restore
------------------------------------------------------------------------
PAINTED 4 FRAMES
// 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 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/flat_button.dart';
import 'package:sky/widgets/floating_action_button.dart';
import 'package:sky/widgets/raised_button.dart';
import '../resources/display_list.dart';
main() async {
WidgetTester tester = new WidgetTester();
await tester.test(() {
return new Center(child: new RaisedButton(child: new Text("ENGAGE")));
});
await tester.test(() {
return new Center(child: new FlatButton(child: new Text("ENGAGE")));
});
await tester.test(() {
return new Center(child: new FloatingActionButton(child: new Text("+")));
});
await tester.endTest();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册