Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: sky/tests/resources/display_list.dart

Issue 1153053012: Make our raw/ tests actually check the paint output. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: use hex for the colours in the test output Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/tests/raw/render_flex-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 import 'package:sky/framework/rendering/render_node.dart';
3 import 'package:sky/framework/rendering/render_box.dart';
4 import 'dart:sky' as sky;
5
6 typedef void Logger (String s);
7
8 class TestDisplayList extends RenderNodeDisplayList {
9 TestDisplayList(double width, double height, this.logger, { this.indent: '' }) :
10 this.width = width,
11 this.height = height,
12 super(width, height) {
13 log("TestDisplayList() constructor: $width x $height");
14 }
15
16 final String indent;
17 final double width;
18 final double height;
19
20 Logger logger;
21 void log(String s) {
22 logger("${indent} ${s}");
23 }
24
25 String explainPaint(sky.Paint paint) {
26 return "Paint(0x${paint.color.toRadixString(16).padLeft(8, '0')})";
27 }
28
29 void save() {
30 log("save");
31 }
32
33 void saveLayer(sky.Rect bounds, sky.Paint paint) {
34 log("saveLayer(${bounds.top}:${bounds.left}:${bounds.bottom}:${bounds.right} , ${explainPaint(paint)})");
35 }
36
37 void restore() {
38 log("restore");
39 }
40
41 void translate(double dx, double dy) {
42 log("translate($dx, $dy)");
43 }
44
45 void scale(double sx, double sy) {
46 log("scale($sx, $sy)");
47 }
48
49 void rotateDegrees(double degrees) {
50 log("rotateDegrees($degrees)");
51 }
52
53 void skew(double sx, double sy) {
54 log("skew($sx, $sy)");
55 }
56
57 void concat(List<double> matrix9) {
58 log("concat($matrix9)");
59 }
60
61 void clipRect(sky.Rect rect) {
62 log("clipRect(${rect.top}:${rect.left}:${rect.bottom}:${rect.right})");
63 }
64
65 void drawPicture(sky.Picture picture) {
66 log("drawPicture()");
67 }
68
69 void drawPaint(sky.Paint paint) {
70 log("drawPaint(${explainPaint(paint)})");
71 }
72
73 void drawRect(sky.Rect rect, sky.Paint paint) {
74 log("drawRect(${rect.top}:${rect.left}:${rect.bottom}:${rect.right}, ${expla inPaint(paint)})");
75 }
76
77 void drawOval(sky.Rect rect, sky.Paint paint) {
78 log("drawOval(${rect.top}:${rect.left}:${rect.bottom}:${rect.right}, ${expla inPaint(paint)})");
79 }
80
81 void drawCircle(double x, double y, double radius, sky.Paint paint) {
82 log("drawCircle($x, $y, $radius, ${explainPaint(paint)})");
83 }
84
85 void drawPath(sky.Path path, sky.Paint paint) {
86 log("drawPath(Path, ${explainPaint(paint)})");
87 }
88
89 void paintChild(RenderNode child, sky.Point position) {
90 log("paintChild at ${position.x},${position.y}");
91 child.paint(new TestDisplayList(width, height, logger, indent: "$indent |") );
92 }
93 }
94
95 class TestView extends RenderView {
96
97 TestView({
98 RenderBox child,
99 Duration timeForRotation
100 }) : super(child: child, timeForRotation: timeForRotation) {
101 print("TestView enabled");
102 }
103
104 int frame = 0;
105
106 String lastPaint = '';
107 void log(String s) {
108 lastPaint += "\n$s";
109 }
110
111 void paintFrame() {
112 RenderNode.debugDoingPaint = true;
113 frame += 1;
114 log("PAINT FOR FRAME #${frame} --------------------------------------------- -");
115 var canvas = new TestDisplayList(sky.view.width, sky.view.height, log, inden t: "${frame} |");
116 paint(canvas);
117 log("----------------------------------------------------------------------- -");
118 RenderNode.debugDoingPaint = false;
119 }
120
121 }
122
123 class TestApp {
124
125 TestApp(RenderBox root) {
126 _renderView = new TestView(child: root);
127 _renderView.attach();
128 _renderView.layout(new ViewConstraints(width: sky.view.width, height: sky.vi ew.height));
129 _renderView.paintFrame();
130 print(_renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better
131 }
132
133 RenderView _renderView;
134
135 RenderBox get root => _renderView.child;
136 void set root(RenderBox value) {
137 _renderView.child = value;
138 }
139 void _beginFrame(double timeStamp) {
140 RenderNode.flushLayout();
141 _renderView.paintFrame();
142 print(_renderView.lastPaint); // TODO(ianh): figure out how to make this fit the unit testing framework better
143 }
144
145 }
OLDNEW
« no previous file with comments | « sky/tests/raw/render_flex-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698