Commit 230f1081 authored by Devon Carew's avatar Devon Carew Committed by GitHub

expose debugPaintBaselinesEnabled (#10276)

* expose debugPaintBaselinesEnabled

* Update binding.dart

review comments
parent d4828986
......@@ -49,7 +49,7 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
super.initServiceExtensions();
assert(() {
// this service extension only works in checked mode
// these service extensions only work in checked mode
registerBoolServiceExtension(
name: 'debugPaint',
getter: () async => debugPaintSizeEnabled,
......@@ -60,6 +60,27 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
return _forceRepaint();
}
);
registerBoolServiceExtension(
name: 'debugPaintBaselinesEnabled',
getter: () async => debugPaintBaselinesEnabled,
setter: (bool value) {
if (debugPaintBaselinesEnabled == value)
return new Future<Null>.value();
debugPaintBaselinesEnabled = value;
return _forceRepaint();
}
);
registerBoolServiceExtension(
name: 'repaintRainbow',
getter: () async => debugRepaintRainbowEnabled,
setter: (bool value) {
final bool repaint = debugRepaintRainbowEnabled && !value;
debugRepaintRainbowEnabled = value;
if (repaint)
return _forceRepaint();
return new Future<Null>.value();
}
);
return true;
});
......@@ -77,22 +98,6 @@ abstract class RendererBinding extends BindingBase implements SchedulerBinding,
name: 'debugDumpSemanticsTree',
callback: () { debugDumpSemanticsTree(); return debugPrintDone; }
);
assert(() {
// this service extension only works in checked mode
registerBoolServiceExtension(
name: 'repaintRainbow',
getter: () async => debugRepaintRainbowEnabled,
setter: (bool value) {
final bool repaint = debugRepaintRainbowEnabled && !value;
debugRepaintRainbowEnabled = value;
if (repaint)
return _forceRepaint();
return new Future<Null>.value();
}
);
return true;
});
}
/// Creates a [RenderView] object to be the root of the
......
......@@ -230,6 +230,48 @@ void main() {
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - debugPaintBaselinesEnabled', () async {
Map<String, String> result;
Future<Map<String, String>> pendingResult;
bool completed;
expect(binding.frameScheduled, isFalse);
expect(debugPaintBaselinesEnabled, false);
result = await binding.testExtension('debugPaintBaselinesEnabled', <String, String>{});
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugPaintBaselinesEnabled, false);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugPaintBaselinesEnabled', <String, String>{ 'enabled': 'true' });
completed = false;
pendingResult.whenComplete(() { completed = true; });
await binding.flushMicrotasks();
expect(binding.frameScheduled, isTrue);
expect(completed, isFalse);
await binding.doFrame();
await binding.flushMicrotasks();
expect(completed, isTrue);
expect(binding.frameScheduled, isFalse);
result = await pendingResult;
expect(result, <String, String>{ 'enabled': 'true' });
expect(debugPaintBaselinesEnabled, true);
result = await binding.testExtension('debugPaintBaselinesEnabled', <String, String>{});
expect(result, <String, String>{ 'enabled': 'true' });
expect(debugPaintBaselinesEnabled, true);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugPaintBaselinesEnabled', <String, String>{ 'enabled': 'false' });
await binding.flushMicrotasks();
expect(binding.frameScheduled, isTrue);
await binding.doFrame();
expect(binding.frameScheduled, isFalse);
result = await pendingResult;
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugPaintBaselinesEnabled, false);
result = await binding.testExtension('debugPaintBaselinesEnabled', <String, String>{});
expect(result, <String, String>{ 'enabled': 'false' });
expect(debugPaintBaselinesEnabled, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - evict', () async {
Map<String, String> result;
bool completed;
......@@ -417,7 +459,7 @@ void main() {
test('Service extensions - posttest', () async {
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect(binding.extensions.length, 14);
expect(binding.extensions.length, 15);
expect(console, isEmpty);
debugPrint = debugPrintThrottled;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment