Unverified Commit 43249469 authored by Kenzie (Schmoll) Davisson's avatar Kenzie (Schmoll) Davisson Committed by GitHub

Add service extensions to expose debug rendering toggles (#91499)

parent e95b5c22
......@@ -109,6 +109,36 @@ mixin RendererBinding on BindingBase, ServicesBinding, SchedulerBinding, Gesture
};
},
);
registerBoolServiceExtension(
name: 'debugDisableClipLayers',
getter: () async => debugDisableClipLayers,
setter: (bool value) {
if (debugDisableClipLayers == value)
return Future<void>.value();
debugDisableClipLayers = value;
return _forceRepaint();
},
);
registerBoolServiceExtension(
name: 'debugDisablePhysicalShapeLayers',
getter: () async => debugDisablePhysicalShapeLayers,
setter: (bool value) {
if (debugDisablePhysicalShapeLayers == value)
return Future<void>.value();
debugDisablePhysicalShapeLayers = value;
return _forceRepaint();
},
);
registerBoolServiceExtension(
name: 'debugDisableOpacityLayers',
getter: () async => debugDisableOpacityLayers,
setter: (bool value) {
if (debugDisableOpacityLayers == value)
return Future<void>.value();
debugDisableOpacityLayers = value;
return _forceRepaint();
},
);
return true;
}());
......
......@@ -173,7 +173,7 @@ void main() {
const int disabledExtensions = kIsWeb ? 2 : 0;
// If you add a service extension... TEST IT! :-)
// ...then increment this number.
expect(binding.extensions.length, 30 + widgetInspectorExtensionCount - disabledExtensions);
expect(binding.extensions.length, 33 + widgetInspectorExtensionCount - disabledExtensions);
expect(console, isEmpty);
debugPrint = debugPrintThrottled;
......@@ -612,6 +612,132 @@ void main() {
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - debugDisableClipLayers', () async {
Map<String, dynamic> result;
Future<Map<String, dynamic>> pendingResult;
bool completed;
expect(binding.frameScheduled, isFalse);
expect(debugDisableClipLayers, false);
result = await binding.testExtension('debugDisableClipLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisableClipLayers, false);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisableClipLayers', <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(debugDisableClipLayers, true);
result = await binding.testExtension('debugDisableClipLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugDisableClipLayers, true);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisableClipLayers', <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(debugDisableClipLayers, false);
result = await binding.testExtension('debugDisableClipLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisableClipLayers, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - debugDisablePhysicalShapeLayers', () async {
Map<String, dynamic> result;
Future<Map<String, dynamic>> pendingResult;
bool completed;
expect(binding.frameScheduled, isFalse);
expect(debugDisablePhysicalShapeLayers, false);
result = await binding.testExtension('debugDisablePhysicalShapeLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisablePhysicalShapeLayers, false);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisablePhysicalShapeLayers', <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(debugDisablePhysicalShapeLayers, true);
result = await binding.testExtension('debugDisablePhysicalShapeLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugDisablePhysicalShapeLayers, true);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisablePhysicalShapeLayers', <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(debugDisablePhysicalShapeLayers, false);
result = await binding.testExtension('debugDisablePhysicalShapeLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisablePhysicalShapeLayers, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - debugDisableOpacityLayers', () async {
Map<String, dynamic> result;
Future<Map<String, dynamic>> pendingResult;
bool completed;
expect(binding.frameScheduled, isFalse);
expect(debugDisableOpacityLayers, false);
result = await binding.testExtension('debugDisableOpacityLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisableOpacityLayers, false);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisableOpacityLayers', <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(debugDisableOpacityLayers, true);
result = await binding.testExtension('debugDisableOpacityLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'true'});
expect(debugDisableOpacityLayers, true);
expect(binding.frameScheduled, isFalse);
pendingResult = binding.testExtension('debugDisableOpacityLayers', <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(debugDisableOpacityLayers, false);
result = await binding.testExtension('debugDisableOpacityLayers', <String, String>{});
expect(result, <String, String>{'enabled': 'false'});
expect(debugDisableOpacityLayers, false);
expect(binding.frameScheduled, isFalse);
});
test('Service extensions - reassemble', () async {
Map<String, dynamic> result;
Future<Map<String, dynamic>> pendingResult;
......
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