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

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

Issue 1192003003: Clean up the tests to be more maintainable. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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/box_layout-expected.txt ('k') | sky/tests/widgets/buttons.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 import 'dart:async'; 2 import 'dart:async';
3 import 'dart:sky' as sky; 3 import 'dart:sky' as sky;
4 import "dart:sky.internals" as internals; 4 import "dart:sky.internals" as internals;
5 5
6 import 'package:sky/widgets/basic.dart'; 6 import 'package:sky/widgets/basic.dart';
7 import 'package:sky/rendering/box.dart'; 7 import 'package:sky/rendering/box.dart';
8 import 'package:sky/rendering/object.dart'; 8 import 'package:sky/rendering/object.dart';
9 9
10 typedef void Logger (String s); 10 typedef void Logger (String s);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 117 }
118 } 118 }
119 119
120 class TestRenderView extends RenderView { 120 class TestRenderView extends RenderView {
121 121
122 TestRenderView([ RenderBox child = null ]) : super(child: child) { 122 TestRenderView([ RenderBox child = null ]) : super(child: child) {
123 print("TestRenderView enabled"); 123 print("TestRenderView enabled");
124 attach(); 124 attach();
125 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures 125 rootConstraints = new ViewConstraints(width: 800.0, height: 600.0); // arbit rary figures
126 scheduleInitialLayout(); 126 scheduleInitialLayout();
127 checkFrame(); 127 syncCheckFrame();
128 } 128 }
129 129
130 int frame = 0; 130 int frame = 0;
131 131
132 String lastPaint = ''; 132 String lastPaint = '';
133 void log(String s) { 133 void log(String s) {
134 lastPaint += "\n$s"; 134 lastPaint += "\n$s";
135 } 135 }
136 136
137 void paintFrame() { 137 void paintFrame() {
138 RenderObject.debugDoingPaint = true; 138 RenderObject.debugDoingPaint = true;
139 frame += 1; 139 frame += 1;
140 lastPaint = ''; 140 lastPaint = '';
141 log("PAINT FOR FRAME #${frame} --------------------------------------------- -"); 141 log("PAINT FOR FRAME #${frame} --------------------------------------------- -");
142 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig ht, log, indent: "${frame} |"); 142 var canvas = new TestDisplayList(rootConstraints.width, rootConstraints.heig ht, log, indent: "${frame} |");
143 paint(canvas); 143 paint(canvas);
144 log("----------------------------------------------------------------------- -"); 144 log("----------------------------------------------------------------------- -");
145 RenderObject.debugDoingPaint = false; 145 RenderObject.debugDoingPaint = false;
146 } 146 }
147 147
148 // TEST API: 148 // TEST API:
149 149
150 void checkFrame() { 150 void syncCheckFrame() {
151 RenderObject.flushLayout(); 151 RenderObject.flushLayout();
152 paintFrame(); 152 paintFrame();
153 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better 153 print(lastPaint); // TODO(ianh): figure out how to make this fit the unit te sting framework better
154 } 154 }
155 155
156 Future checkFrame() {
157 return new Future.microtask(syncCheckFrame);
158 }
159
156 void endTest() { 160 void endTest() {
157 internals.notifyTestComplete("PAINTED $frame FRAMES"); 161 internals.notifyTestComplete("PAINTED $frame FRAMES");
158 } 162 }
159 163
160 } 164 }
161 165
162 class TestApp extends App { 166 class TestApp extends App {
163 TestApp({ this.builder }); 167 TestApp({ this.builder });
164 168
165 Function builder; 169 Function builder;
166 170
167 Widget build() { 171 Widget build() {
168 return builder(); 172 return builder();
169 } 173 }
170 } 174 }
171 175
172 class WidgetTester { 176 class WidgetTester {
173 TestRenderView renderView = new TestRenderView(); 177 TestRenderView renderView = new TestRenderView();
174 178
175 Future test(Function builder) { 179 Future test(Function builder) {
176 runApp(new TestApp(builder: builder), renderViewOverride: renderView); 180 runApp(new TestApp(builder: builder), renderViewOverride: renderView);
177 return new Future.microtask(renderView.checkFrame); 181 return renderView.checkFrame();
178 } 182 }
179 183
180 Future endTest() { 184 void endTest() {
181 return new Future.microtask(renderView.endTest); 185 renderView.endTest();
182 } 186 }
183 } 187 }
OLDNEW
« no previous file with comments | « sky/tests/raw/box_layout-expected.txt ('k') | sky/tests/widgets/buttons.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698